diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-08-19 21:00:14 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-08-19 21:00:14 -0400 |
commit | 49c77b925af1c205747116a762000d99e192e2c8 (patch) | |
tree | 11865b566da05e3f83b9dc23af021d99e5b716cc /systemd.py | |
parent | 18cadd5fa404877c65b8e44664008aa561c2d61e (diff) |
Use custom collectd types for jobs and units
Diffstat (limited to 'systemd.py')
-rwxr-xr-x | systemd.py | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -34,19 +34,20 @@ def read(): dat = { # These are the values of the # basic/unit-name.h:UnitActiveStates enum. - 'NActiveUnits': 0, - 'NReloadingUnits': 0, - 'NInactiveUnits': 0, - 'NFailedUnits': 0, - 'NActivatingUnits': 0, - 'NDeactivatingUnits': 0 + ('sd_units', 'active'): 0, + ('sd_units', 'reloading'): 0, + ('sd_units', 'inactive'): 0, + ('sd_units', 'failed'): 0, + ('sd_units', 'activating'): 0, + ('sd_units', 'deactivating'): 0, } for unit in system_manager.ListUnits(): - key = str('N%sUnits' % unit[3].capitalize()) + key = ('sd_units', str(unit[3])) dat[key] = dat[key] + 1 - for prop in ['NJobs', 'NInstalledJobs', 'NFailedJobs']: - dat[prop] = int(get_property(system_manager, prop)) + dat[('sd_jobs', 'queued')] = int(get_property(system_manager, 'NJobs')) + dat[('sd_jobs', 'installed')] = int(get_property(system_manager, 'NInstalledJobs')) + dat[('sd_jobs', 'failed')] = int(get_property(system_manager, 'NFailedJobs')) return dat @@ -62,8 +63,8 @@ else: for (key, val) in iteritems(read()): collectd.Values( plugin='systemd', - type='count', - type_instance=key + type=key[0], + type_instance=key[1] ).dispatch( values=[val] ) |