From 61dd00557a636bbcaf6cee79c212bc53224ca6f6 Mon Sep 17 00:00:00 2001 From: "Nitin U. Yewale" Date: Wed, 4 Oct 2023 17:49:10 +0530 Subject: [PATCH] move per device data to subdirectories for nvme, scsi and block plugins. Signed-off-by: Nitin U. Yewale --- sos/report/plugins/block.py | 17 +++++++++++------ sos/report/plugins/nvme.py | 31 +++++++++++++++++++++---------- sos/report/plugins/scsi.py | 25 +++++++++++++------------ 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/sos/report/plugins/block.py b/sos/report/plugins/block.py index 915e6db1b6..d23199b851 100644 --- a/sos/report/plugins/block.py +++ b/sos/report/plugins/block.py @@ -19,8 +19,8 @@ class Block(Plugin, IndependentPlugin): files = ('/sys/block',) def setup(self): - _subdir1 = "udevadm_info_block" - _subdir2 = "fdisk_and_parted" + _subdir1 = "udevadm_block" + _subdir2 = "fdisk_parted" self.add_forbidden_path("/sys/block/*/queue/iosched") @@ -58,14 +58,19 @@ def setup(self): "udevadm info -a %(dev)s" ] + parted_cmds = [ + "parted -s %(dev)s unit s print" + ] + self.add_device_cmd(udevadm_cmds, devices='block', blacklist='ram.*', subdir=_subdir1) - self.add_device_cmd("parted -s %(dev)s unit s print", - blacklist="ram.*", devices="block", - tags="parted_s_sos", subdir=_subdir2) + + self.add_device_cmd(parted_cmds, devices='block', blacklist='ram.*', + subdir=_subdir2) + self.add_device_cmd("fdisk -l %(dev)s", blacklist="ram.*", devices="block", tags="fdisk_l_sos", - subdir=_subdir2) + subdir=_subdir2) lsblk = self.collect_cmd_output("lsblk -f -a -l") # for LUKS devices, collect cryptsetup luksDump diff --git a/sos/report/plugins/nvme.py b/sos/report/plugins/nvme.py index 014957bcf9..bb8bf0fe32 100644 --- a/sos/report/plugins/nvme.py +++ b/sos/report/plugins/nvme.py @@ -51,19 +51,30 @@ def setup(self): "nvme error-log %(dev)s" ] + nvme_commands = [ + "nvme list-ns %(dev)s", + "nvme list-ctrl %(dev)s", + "nvme id-ctrl -H %(dev)s", + "nvme id-ns -H %(dev)s", + "nvme show-regs %(dev)s" + ] + + subdirs = [ + "nvme_list-ns", + "nvme_list-ctrl", + "nvme_id-ctrl_-H", + "nvme_id-ns_-H", + "nvme_show-regs" + ] + self.add_device_cmd(smartctl_cmds, devices='block', whitelist='nvme.*', subdir=_subdir1) + self.add_device_cmd(nvme_logs_cmds, devices='block', whitelist='nvme.*', subdir=_subdir2) - self.add_device_cmd("nvme list-ns %(dev)s", whitelist='nvme.*', - devices='block', subdir=_subdir3) - self.add_device_cmd("nvme list-ctrl %(dev)s", whitelist='nvme.*', - devices='block', subdir=_subdir4) - self.add_device_cmd("nvme id-ctrl -H %(dev)s", whitelist='nvme.*', - devices='block', subdir=_subdir5) - self.add_device_cmd("nvme id-ns -H %(dev)s", whitelist='nvme.*', - devices='block', subdir=_subdir6) - self.add_device_cmd("nvme show-regs %(dev)s", whitelist='nvme.*', - devices='block', subdir=_subdir7) + + for cmd, dir in zip(nvme_commands, subdirs): + self.add_device_cmd(cmd, whitelist='nvme.*', + devices='block', subdir=dir) # vim: set et ts=4 sw=4 : diff --git a/sos/report/plugins/scsi.py b/sos/report/plugins/scsi.py index ef944efd0d..22ce05296f 100644 --- a/sos/report/plugins/scsi.py +++ b/sos/report/plugins/scsi.py @@ -29,9 +29,8 @@ class Scsi(Plugin, IndependentPlugin): profiles = ('storage', 'hardware') def setup(self): - _subdir1 = "udevadm_info_scsihosts" - _subdir2 = "sg_inq_devices" - _subdir3 = "sg_persist_devices" + _subdir1 = "udevadm_scsi" + _subdir2 = "sg_persists_inq" self.add_copy_spec([ "/proc/scsi", @@ -65,16 +64,18 @@ def setup(self): "lsscsi -L" ]) - scsi_hosts = glob("/sys/class/scsi_host/*") - self.add_device_cmd("udevadm info -a %(dev)s", devices=scsi_hosts, - subdir=_subdir1) - self.add_device_cmd("sg_inq %(dev)s", devices=block, - whitelist=['sd.*'], subdir=_subdir2) - - self.add_device_cmd([ + scsi_persist_inq_cmds = [ "sg_persist --in -k -d %(dev)s", "sg_persist --in -r -d %(dev)s", - "sg_persist --in -s -d %(dev)s" - ], devices='block', whitelist=['sd.*'], subdir=_subdir3) + "sg_persist --in -s -d %(dev)s", + "sg_inq %(dev)s" + ] + + scsi_hosts = glob("/sys/class/scsi_host/*") + self.add_device_cmd("udevadm info -a %(dev)s", + devices=scsi_hosts, subdir=_subdir1) + + self.add_device_cmd(scsi_persist_inq_cmds, devices='block', + whitelist=['sd.*'], subdir=_subdir2) # vim: set et ts=4 sw=4 :