diff options
author | Mikel Olasagasti Uranga <mikel@olasagasti.info> | 2019-01-27 19:20:02 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2019-08-15 14:50:16 +0100 |
commit | 479eb02477a12729d5e3a412f6ddbe0c0200aef7 (patch) | |
tree | b41d36b09555167d1d4118dec3081cb2a7ea1062 | |
parent | 8eff8f82604cb83a4c43f4a3ba0308940863c1b5 (diff) | |
download | sos-479eb02477a12729d5e3a412f6ddbe0c0200aef7.tar.gz |
[kdump] Collect vmcore-dmesg.txt files based on path and device
kdump allows to configure to which filesystem and what path it will
write contents of '/proc/vmcore'. kdump plugin currently only checks against
a hardcoded path '/var/crash/*/vmcore-dmesg.txt'.
With this change it will check the 'path' variable and also
filesystems type ext2, ext3, ext4 or xfs against fstab. This will make
the plugin check in the correct path in the system.
Resolves: #1546
Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/kdump.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sos/plugins/kdump.py b/sos/plugins/kdump.py index 48522767..83b00280 100644 --- a/sos/plugins/kdump.py +++ b/sos/plugins/kdump.py @@ -27,12 +27,39 @@ class RedHatKDump(KDump, RedHatPlugin): files = ('/etc/kdump.conf',) packages = ('kexec-tools',) + def fstab_parse_fs(self, device): + with open('/etc/fstab', 'r') as fp: + for line in fp: + if line.startswith((device)): + return line.split()[1].rstrip('/') + return "" + + def read_kdump_conffile(self): + fs = "" + path = "/var/crash" + + with open('/etc/kdump.conf', 'r') as fp: + for line in fp: + if line.startswith("path"): + path = line.split()[1] + elif line.startswith(("ext2", "ext3", "ext4", "xfs")): + device = line.split()[1] + fs = self.fstab_parse_fs(device) + return fs + path + def setup(self): self.add_copy_spec([ "/etc/kdump.conf", "/etc/udev/rules.d/*kexec.rules", "/var/crash/*/vmcore-dmesg.txt" ]) + try: + path = self.read_kdump_conffile() + except Exception: + # set no filesystem and default path + path = "/var/crash" + + self.add_copy_spec("{}/*/vmcore-dmesg.txt".format(path)) class DebianKDump(KDump, DebianPlugin, UbuntuPlugin): |