Skip to content
Snippets Groups Projects
Verified Commit 2de25873 authored by Florian Pritz's avatar Florian Pritz
Browse files

zabbix/accounting: Discover .slice units


Signed-off-by: default avatarFlorian Pritz <bluewind@xinu.at>
parent 6ac9831c
No related branches found
No related tags found
No related merge requests found
......@@ -11,15 +11,23 @@ units = systemd1_manager.ListUnits()
discovered = []
def get_unit_prop(interface, propname):
def get_unit_prop_interface(obj, interface, propname):
try:
return unit_properties.Get('org.freedesktop.systemd1.Service', propname)
return obj.Get(interface, propname)
except dbus.exceptions.DBusException as err:
if err.get_dbus_name() == 'org.freedesktop.DBus.Error.UnknownProperty':
return None
else:
raise
def get_unit_prop(obj, propname):
interfaces = ['org.freedesktop.systemd1.Service', 'org.freedesktop.systemd1.Slice']
for interface in interfaces:
ret = get_unit_prop_interface(obj, interface, propname)
if ret:
return ret
return None
for u in units:
unit_properties = dbus.Interface(bus.get_object('org.freedesktop.systemd1', u[6]), dbus_interface='org.freedesktop.DBus.Properties')
if get_unit_prop(unit_properties, "CPUAccounting") or get_unit_prop(unit_properties, "MemoryAccounting"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment