|
7 | 7 | # See the LICENSE file in the source distribution for further information. |
8 | 8 |
|
9 | 9 | from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin |
| 10 | +from sos.utilities import find |
10 | 11 |
|
11 | 12 |
|
12 | | -class DRDB(Plugin, RedHatPlugin, UbuntuPlugin): |
| 13 | +class DRBD(Plugin, RedHatPlugin, UbuntuPlugin): |
13 | 14 |
|
14 | 15 | short_desc = 'Distributed Replicated Block Device (DRBD)' |
15 | 16 |
|
16 | 17 | plugin_name = 'drbd' |
17 | 18 | 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") |
19 | 41 |
|
20 | 42 | def setup(self): |
21 | 43 | 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", |
25 | 47 | "drbdsetup show all" |
26 | 48 | ]) |
| 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('/', '_')}") |
27 | 54 | self.add_copy_spec([ |
28 | 55 | "/etc/drbd.conf", |
29 | 56 | "/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/*" |
31 | 62 | ]) |
32 | 63 |
|
| 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 | + |
33 | 80 | # vim: set et ts=4 sw=4 : |
0 commit comments