prometheus: do not set empty list as string as name (#62964)
This commit is contained in:
parent
5a0dd085e9
commit
e24269f671
|
@ -230,8 +230,13 @@ def units(ctn):
|
|||
manager = dbus.Interface(s, "org.freedesktop.systemd1.Manager")
|
||||
units = manager.ListUnits()
|
||||
n = len([u for u in units if u[3] == "failed" and not u[0].startswith("user@")])
|
||||
name = [u[0].replace('dbus.String', '') for u in units if u[3] == "failed" and not u[0].startswith("user@")]
|
||||
eo_units.labels(ctn, name, "failed").set(n)
|
||||
name = [
|
||||
u[0].replace('dbus.String', '') for u in units if u[3] == "failed" and not u[0].startswith("user@")
|
||||
]
|
||||
if name:
|
||||
eo_units.labels(ctn, name, "failed").set(n)
|
||||
else:
|
||||
eo_units.labels(ctn, "failed").set(n)
|
||||
|
||||
|
||||
def run_in_machines(ctn):
|
||||
|
|
Loading…
Reference in New Issue