Skip to content

Commit

Permalink
[report] Add new section fstype section under hardware devices which
Browse files Browse the repository at this point in the history
lists devices by filesystem, based on lsbl -nrpo output. Devices with
no filesystem are placed into unknown section.

Signed-off-by: Lukas Herbolt <[email protected]>
  • Loading branch information
lherbolt committed Mar 5, 2024
1 parent 971859c commit 3b38f3a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion sos/report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ def _get_hardware_devices(self):
'fibre': self._get_fibre_devs()
},
'network': self._get_network_devs(),
'namespaced_network': self._get_network_namespace_devices()
'namespaced_network': self._get_network_namespace_devices(),
'fstype': self._get_devices_by_fstype()
}

def _check_container_runtime(self):
Expand Down Expand Up @@ -680,6 +681,21 @@ def _get_network_namespaces(self):
out_ns.append(line.partition(' ')[0])
return out_ns

def _get_devices_by_fstype(self):
_dev_fstypes = {}
_devs = sos_get_command_output("lsblk -nrpo FSTYPE,NAME")
if _devs['status'] != 0:
return _dev_fstypes
for line in (_devs['output'].splitlines()):
helper = line.strip().split()
if len(helper) == 1:
helper.insert(0, 'unknown')
if "ext" in helper[0]:
helper[0] = 'ext4'
_dev_fstypes.setdefault(helper[0], [])
_dev_fstypes[helper[0]].append(helper[1])
return _dev_fstypes

def get_commons(self):
return {
'cmddir': self.cmddir,
Expand Down

0 comments on commit 3b38f3a

Please sign in to comment.