-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathzsys.apport
More file actions
67 lines (52 loc) · 2.71 KB
/
zsys.apport
File metadata and controls
67 lines (52 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'''apport package hook for zsys
(c) 2020 Canonical Ltd.
'''
from contextlib import suppress
from glob import glob
import os
import apport.hookutils
def add_info(report):
apport.hookutils.attach_related_packages(report, ["zfs-initramfs", "zfsutils-linux"])
report['ZFSModules'] = get_zfs_kernel_modules()
apport.hookutils.attach_file(report, '/proc/cmdline', 'ProcKernelCmdLine')
apport.hookutils.attach_file(report, '/boot/grub/grub.cfg', "Grub.cfg")
apport.hookutils.attach_file_if_exists(report, '/boot/grub/grub.cfg.new', "Grub.cfgFailed")
report['MountsGenerated'] = collect_generated_mount_units()
apport.hookutils.attach_file(report, '/proc/mounts', 'Mounts')
report['ZFSDatasets'] = apport.hookutils.command_output(['zfs', 'list', '-t', 'all'])
report['ZFSImportedPools'] = apport.hookutils.command_output(['zpool', 'list'])
report['ZFSPoolsStatus'] = apport.hookutils.command_output(['zpool', 'status'])
report['ZFSMounts'] = apport.hookutils.command_output(['zfs', 'mount'])
report['ZSYSDump'] = apport.hookutils.command_output(['zsysctl', 'service', 'dump'])
apport.hookutils.attach_file_if_exists(report, '/etc/zfs/zpool.cache', "ZFSPoolCache")
with suppress(FileNotFoundError):
zfs_listdir = '/etc/zfs/zfs-list.cache'
for f in os.listdir(zfs_listdir):
apport.hookutils.attach_file(report, os.path.join(zfs_listdir, f), "ZFSListcache-"+f)
report['ZSYSJournal'] = apport.hookutils.command_output(['journalctl', '/sbin/zsysd',
'-b', '-o', 'short-monotonic', '--lines', '3000'])
report['SystemdDefaultUnitsState'] = apport.hookutils.command_output(['systemctl', 'status', 'default.target']).strip()
# Add details about all failed units, if any
failed = []
out = apport.hookutils.command_output(['systemctl', '--state=failed', '--full', '--no-legend']).strip()
for line in out.splitlines():
unit = line.split()[0]
failed.append(apport.hookutils.command_output(['systemctl', 'status', '--full', unit]))
report['SystemdFailedUnits'] = '------\n'.join(failed)
def get_zfs_kernel_modules(module_list='/proc/modules'):
'''Get kernel loaded zfs modules and dependencies.'''
mods = []
with suppress(IOError):
with open(module_list) as f:
for l in f:
if "zfs" not in l:
continue
mods.append(l.strip())
return "\n".join(mods)
def collect_generated_mount_units():
'''Get mount units available through generators'''
r = []
gen_dir = "/run/systemd/generator/"
for f in glob(os.path.join(gen_dir, "*.mount")):
r.append(f[len(gen_dir):])
return "\n".join(r)