mirror of
https://github.com/FAUSheppy/monitoring-tools
synced 2025-12-06 03:21:35 +01:00
fix: units not displayed correctly on systemd >= 252
This commit is contained in:
@@ -22,18 +22,21 @@ class SystemdStatus(nagiosplugin.Resource):
|
|||||||
p = subprocess.Popen(['systemctl', '--failed', '--no-legend'],
|
p = subprocess.Popen(['systemctl', '--failed', '--no-legend'],
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE,
|
||||||
pres, err = p.communicate()
|
universal_newlines=True)
|
||||||
|
|
||||||
|
stdout, err = p.communicate()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise nagiosplugin.CheckError(e)
|
raise nagiosplugin.CheckError(e)
|
||||||
|
|
||||||
if err:
|
if err:
|
||||||
raise nagiosplugin.CheckError(err)
|
raise nagiosplugin.CheckError(err)
|
||||||
|
|
||||||
if pres:
|
if stdout:
|
||||||
|
lines = list(filter(lambda x: "service" in x, stdout.split("\n")))
|
||||||
result = ""
|
result = ""
|
||||||
for line in io.StringIO(pres.decode('utf-8')):
|
for line in lines:
|
||||||
result = "%s %s" % (result, line.split(' ')[0])
|
result += "{}".format(line.split(' ')[1])
|
||||||
|
|
||||||
return [nagiosplugin.Metric('systemd', (False, result), context='systemd')]
|
return [nagiosplugin.Metric('systemd', (False, result), context='systemd')]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user