Monitor systemd units with Nagios/Icinga

Recently I stumbled upon an interesting blog post about monitoring systemd units with Nagios or Icinga.

But in my opinion the post's screenshot is misleading. I looks like the linked Python scripts automatically discovers and configures systemd units within Nagios/Icinga - which is not the case. The script named pynagsystemd utilizes the systemctl command to check the state of all active systemd units. Enabled but failed entries (e.g. crashed services) are reported:

pynagsystemd

The script requires the Python module python-nagiosplugin - which can be installed using the Python package manager pip or using a RPM package.

While testing in my homelab, I discovered that some unneeded, but enabled systemd units are reported:

1$ /usr/lib64/nagios/plugins/pynagsystemd.py
2SYSTEMD CRITICAL - failed units:  rngd.service kdump.service

Simply disabling these units won't fix the output:

1# systemctl disable rngd.service
2# systemctl disable kdump.service
3# /usr/lib64/nagios/plugins/pynagsystemd.py
4SYSTEMD CRITICAL - failed units:  rngd.service kdump.service

After disabling the units, error counters need to be reset:

1# systemctl reset-failed

The next result was:

1$ /usr/lib64/nagios/plugins/pynagsystemd.py
2SYSTEMD OK

🙂

Translations: