systemd in Zabbix

If you use Zabbix to monitor your servers you may want to monitor systemd services with it especially if you have some custom services.

These simple checks were enough for me:

systemd.unit.is-active[<unit name>]  # 1 if unit is active, 0 if inactive
systemd.unit.is-failed[<unit name>]  # 1 if unit if in failed state, 0 if not
systemd.unit.is-enabled[<unit name>] # 1 if unit is enabled, 0 if not

It's very simple. Just place userparameter_systemd.conf to your zabbix config dir (usually /etc/zabbix_agentd.conf.d) with the following content:

# checks to determine if specified unit is active, failed or enabled
UserParameter=systemd.unit.is-active[*],systemctl is-active --quiet '$1' && echo 1 || echo 0
UserParameter=systemd.unit.is-failed[*],systemctl is-failed --quiet '$1' && echo 1 || echo 0
UserParameter=systemd.unit.is-enabled[*],systemctl is-enabled --quiet '$1' && echo 1 || echo 0

Comments

Comments powered by Disqus