diff --git a/sos/report/plugins/lvm2.py b/sos/report/plugins/lvm2.py index 62917b9a66..ef907af157 100644 --- a/sos/report/plugins/lvm2.py +++ b/sos/report/plugins/lvm2.py @@ -21,7 +21,9 @@ class Lvm2(Plugin, IndependentPlugin): PluginOpt('lvmdump', default=False, desc='collect an lvmdump tarball'), PluginOpt('lvmdump-am', default=False, desc=('attempt to collect lvmdump with advanced options and ' - 'raw metadata')) + 'raw metadata')), + PluginOpt('metadata', default=False, + desc=('attempt to collect headers and metadata via pvck')) ] def do_lvmdump(self, metadata=False): @@ -39,6 +41,24 @@ def do_lvmdump(self, metadata=False): self.add_cmd_output(cmd, chroot=self.tmp_in_sysroot()) + def get_pvck_output(self): + """ Collects the output of the command pvck for each block device + present in the system. + """ + + block_list = self.exec_cmd( + 'pvs -o pv_name --no-headings' + ) + if block_list['status'] == 0: + for line in block_list['output'].splitlines(): + cmds = [ + f"pvck --dump headers {line}", + f"pvck --dump metadata {line}", + f"pvck --dump metadata_all {line} -v", + f"pvck --dump metadata_search {line} -v" + ] + self.add_cmd_output(cmds, subdir="metadata") + def setup(self): # When running LVM2 comamnds: # - use nolocking if supported, else locking_type 0 (no locks) @@ -92,4 +112,7 @@ def setup(self): elif self.get_option('lvmdump-am'): self.do_lvmdump(metadata=True) + if self.get_option('metadata'): + self.get_pvck_output() + # vim: set et ts=4 sw=4 :