summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-08-19 21:00:14 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-08-19 21:00:14 -0400
commit49c77b925af1c205747116a762000d99e192e2c8 (patch)
tree11865b566da05e3f83b9dc23af021d99e5b716cc
parent18cadd5fa404877c65b8e44664008aa561c2d61e (diff)
Use custom collectd types for jobs and units
-rw-r--r--read-systemd.conf2
-rwxr-xr-xsystemd.py23
-rw-r--r--systemd.types.db2
3 files changed, 16 insertions, 11 deletions
diff --git a/read-systemd.conf b/read-systemd.conf
index 51befb5..f3870b6 100644
--- a/read-systemd.conf
+++ b/read-systemd.conf
@@ -1,3 +1,5 @@
+TypesDB "/home/luke/src/collectd-systemd/systemd.types.db"
+
LoadPlugin python
<Plugin python>
ModulePath "/home/luke/src/collectd-systemd"
diff --git a/systemd.py b/systemd.py
index 1f28195..18cdb77 100755
--- a/systemd.py
+++ b/systemd.py
@@ -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]
)
diff --git a/systemd.types.db b/systemd.types.db
new file mode 100644
index 0000000..bf45e3a
--- /dev/null
+++ b/systemd.types.db
@@ -0,0 +1,2 @@
+sd_units value:GAUGE:0:U
+sd_jobs value:GAUGE:0:U