aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAadhar Agarwal <aadagarwal@microsoft.com>2024-04-15 16:32:43 -0700
committerArif Ali <arif-ali@users.noreply.github.com>2024-04-19 09:21:25 +0100
commite35f1bd1b3eb7c53434b67af60aa792ab06196ab (patch)
tree2b899e1dcc9611ed54abd76215b38f5e466d7508
parent6d7572166826f7c4eb46597716ecc929bb78b112 (diff)
downloadsos-e35f1bd1b3eb7c53434b67af60aa792ab06196ab.tar.gz
[kdump] Create AzureKDump class
This change collects kdump information for Azure Linux. With this change, we will check the 'path' variable in /etc/kdump.conf to check where information is being dumped. If get_vm_core is set to true, collect the latest vm core created in the last 24 hours that is <= 2GB Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
-rw-r--r--sos/report/plugins/kdump.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/sos/report/plugins/kdump.py b/sos/report/plugins/kdump.py
index e31e9408..94401256 100644
--- a/sos/report/plugins/kdump.py
+++ b/sos/report/plugins/kdump.py
@@ -8,7 +8,7 @@
import platform
from sos.report.plugins import Plugin, PluginOpt, RedHatPlugin, DebianPlugin, \
- UbuntuPlugin, CosPlugin
+ UbuntuPlugin, CosPlugin, AzurePlugin
class KDump(Plugin):
@@ -124,4 +124,49 @@ class CosKDump(KDump, CosPlugin):
if self.get_option("collect-kdumps"):
self.add_copy_spec(["/var/kdump-*"])
+
+class AzureKDump(KDump, AzurePlugin):
+
+ files = ('/etc/kdump.conf',)
+ packages = ('kexec-tools',)
+
+ option_list = [
+ PluginOpt("get_vm_core", default=False, val_type=bool,
+ desc="collect vm core")
+ ]
+
+ def read_kdump_conffile(self):
+ """ Parse /etc/kdump file """
+ path = "/var/crash"
+
+ kdump = '/etc/kdump.conf'
+ with open(kdump, 'r', encoding='UTF-8') as file:
+ for line in file:
+ if line.startswith("path"):
+ path = line.split()[1]
+
+ return path
+
+ def setup(self):
+ super().setup()
+
+ self.add_copy_spec([
+ "/etc/kdump.conf",
+ "/usr/lib/udev/rules.d/*kexec.rules"
+ ])
+
+ try:
+ path = self.read_kdump_conffile()
+ except Exception: # pylint: disable=broad-except
+ # set no filesystem and default path
+ path = "/var/crash"
+
+ self.add_cmd_output(f"ls -alhR {path}")
+ self.add_copy_spec(f"{path}/*/vmcore-dmesg.txt")
+ self.add_copy_spec(f"{path}/*/kexec-dmesg.log")
+
+ # collect the latest vmcore created in the last 24hrs <= 2GB
+ if self.get_option("get_vm_core"):
+ self.add_copy_spec(f"{path}/*/vmcore", sizelimit=2048, maxage=24)
+
# vim: set et ts=4 sw=4 :