diff options
-rw-r--r-- | sos/plugins/block.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sos/plugins/block.py b/sos/plugins/block.py index 3a2d14d3..059686c5 100644 --- a/sos/plugins/block.py +++ b/sos/plugins/block.py @@ -19,6 +19,22 @@ class Block(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): verify_packages = ('util-linux',) files = ('/sys/block',) + def get_luks_devices(self, lsblk_file): + out = [] + try: + lsblk_out = open(lsblk_file).read() + except IOError: + return out + for line in lsblk_out.splitlines(): + # find in output lines like + # |-sda2 crypto_LUKS <uuid> + # and separate device name - it will be 1st string on the line + # after first '-' + if 'crypto_LUKS' in line: + dev = line.split()[0].split('-', 1)[1] + out.append(dev) + return out + def setup(self): self.add_cmd_output([ "lsblk", @@ -51,4 +67,10 @@ class Block(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin): "fdisk -l %s" % disk_path ]) + lsblk_file = self.get_cmd_output_now("lsblk -f -a") + # for LUKS devices, collect cryptsetup luksDump + if lsblk_file: + for dev in self.get_luks_devices(lsblk_file): + self.add_cmd_output('cryptsetup luksDump /dev/%s' % dev) + # vim: set et ts=4 sw=4 : |