Skip to content

Commit cb4fa98

Browse files
chrboeTurboTurtle
authored andcommitted
[drbd] Modernize and extend plugin
The current drbd plugin is aimed at older DRBD 8-based setups, and only collects some basic data. Extend the plugin to collect more valuable data for real-world support use cases. This version has DRBD 9 in mind, but stays backwards compatible to version 8. Signed-off-by: Christoph Böhmwalder <[email protected]>
1 parent d78e700 commit cb4fa98

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

sos/report/plugins/drbd.py

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,74 @@
77
# See the LICENSE file in the source distribution for further information.
88

99
from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin
10+
from sos.utilities import find
1011

1112

12-
class DRDB(Plugin, RedHatPlugin, UbuntuPlugin):
13+
class DRBD(Plugin, RedHatPlugin, UbuntuPlugin):
1314

1415
short_desc = 'Distributed Replicated Block Device (DRBD)'
1516

1617
plugin_name = 'drbd'
1718
profiles = ('storage',)
18-
packages = ('drbd*-utils',)
19+
commands = ('drbdsetup',)
20+
21+
# In case of kernel bugs, drbdsetup may hang indefinitely.
22+
# Set a shorter than default timeout.
23+
cmd_timeout = 60
24+
25+
def add_drbd_thread_stacks(self):
26+
stacks = ""
27+
for pid_file in find("*_pid", "/sys/kernel/debug/drbd/resources/"):
28+
with open(pid_file, 'r', encoding='utf-8') as f:
29+
pid = f.read().strip()
30+
stacks += f"--- {pid_file}: {pid} ---\n"
31+
if pid.isdigit():
32+
try:
33+
sfn = f"/proc/{pid}/stack"
34+
with open(sfn, 'r', encoding='utf-8') as sf:
35+
stacks += sf.read()
36+
except Exception as e:
37+
stacks += f"Could not read /proc/{pid}/stack: {e}\n"
38+
stacks += "\n"
39+
40+
self.add_string_as_file(stacks, "drbd_thread_stacks")
1941

2042
def setup(self):
2143
self.add_cmd_output([
22-
"drbd-overview",
23-
"drbdadm dump-xml",
24-
"drbdsetup status all",
44+
"drbdadm dump",
45+
"drbdadm -d -vvv adjust all",
46+
"drbdsetup status -vs all",
2547
"drbdsetup show all"
2648
])
49+
self.add_drbd_thread_stacks()
50+
for kmod in find("drbd*.ko*", "/lib/modules"):
51+
self.add_cmd_output([
52+
f"modinfo {kmod}",
53+
], suggest_filename=f"modinfo_{kmod.replace('/', '_')}")
2754
self.add_copy_spec([
2855
"/etc/drbd.conf",
2956
"/etc/drbd.d/*",
30-
"/proc/drbd"
57+
"/proc/drbd",
58+
"/sys/kernel/debug/drbd/*",
59+
"/var/lib/drbd/*",
60+
"/var/lib/drbd-support/*",
61+
"/var/lib/linstor.d/*"
3162
])
3263

64+
def postproc(self):
65+
# Scrub nodehash from /var/lib/drbd-support/registration.json
66+
nodehash_re = r'("nodehash"\s*:\s*")[a-zA-Z0-9]+"'
67+
repl = r'\1********"'
68+
self.do_path_regex_sub(
69+
'/var/lib/drbd-support/registration.json',
70+
nodehash_re, repl
71+
)
72+
73+
# Scrub shared secret from *.{conf,res} files and command outputs
74+
secret_re = r'(shared-secret\s+\"?).[^\"]+(\"?\s*;)'
75+
repl = r'\1********\2'
76+
self.do_path_regex_sub(r'.*\.(conf|res)', secret_re, repl)
77+
self.do_cmd_output_sub("drbdadm dump", secret_re, repl)
78+
self.do_cmd_output_sub("drbdsetup show all", secret_re, repl)
79+
3380
# vim: set et ts=4 sw=4 :

0 commit comments

Comments
 (0)