summaryrefslogtreecommitdiffstats
path: root/debian/extra/systemd.py
blob: d79e0eb85f1d241dd72cd6f32ae6b12037885707 (plain)
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
'''apport package hook for systemd

(c) 2014 Canonical Ltd.
Author: Martin Pitt <martin.pitt@ubuntu.com>
'''

import os.path
import apport.hookutils

def add_info(report):
    apport.hookutils.attach_hardware(report)

    report['SystemdDelta'] = apport.hookutils.command_output(['systemd-delta'])

    if not os.path.exists('/run/systemd/system'):
        return

    # Add details about all failed units, if any
    out = apport.hookutils.command_output(['systemctl', '--state=failed', '--full',
                                           '--no-legend']).strip()
    if out:
        failed = ''
        for line in out.splitlines():
            unit = line.split()[0]
            if failed:
                failed += '------\n'
            failed += apport.hookutils.command_output(['systemctl', 'status', '--full', unit])
        report['SystemdFailedUnits'] = failed