Plugins contrib systemd config is wrong

I’ve installed icinga2 and was setting up a systemd check for an agent.

On all hosts, I have installed the following packages:

  • icinga2
  • icinga2-common
  • monitoring-plugins
  • monitoring-plugins-systemd

The configuration in /usr/share/icinga2/include/plugins-contrib.d/systemd.conf comes from icinga2-common. My version is:

apt policy icinga2-common 
icinga2-common:
  Installed: 2.13.6-2+deb12u1
  Candidate: 2.13.6-2+deb12u1
  Version table:
 *** 2.13.6-2+deb12u1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status

This file references: check_systemd.py:

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

object CheckCommand "systemd" {
        command = [ PluginContribDir + "/check_systemd.py" ]

        arguments = {
                "--unit" = {
                        value = "$systemd_unit$"
                        description = "Name of the systemd unit that is being tested."
                }
...

But the file provided by monitoring-plugins-systemd is check_systemd without .py:

$ dpkg -X monitoring-plugins-systemd_2.3.1-4_all.deb .
./
./usr/
./usr/lib/
./usr/lib/nagios/
./usr/lib/nagios/plugins/
./usr/lib/nagios/plugins/check_systemd
./usr/share/
./usr/share/doc/
./usr/share/doc/monitoring-plugins-systemd/
./usr/share/doc/monitoring-plugins-systemd/changelog.Debian.gz
./usr/share/doc/monitoring-plugins-systemd/copyright
./usr/share/lintian/
./usr/share/lintian/overrides/
./usr/share/lintian/overrides/monitoring-plugins-systemd

After I edited the file provided by icinga2-common (by removing the .py) and restarting icinga2 manually on my agent, the checks were fixed.

This is effectively a bug report. If there’s a better place to post this, please let me know. I could find no references online to this error:

execvpe(/usr/lib/nagios/plugins/check_systemd.py) failed: No such file or directory

Pretty bad idea to change files managed by the package management. In your case it’s recommended to add a new command object. Or you use the plugin for which the command is defined in icinga2-common.

1 Like

This is a known problem. The systematic problem is, that the Icinga crew tries to provide defintions for a lot of monitoring plugins, which may or may not be available via package manager on a specific distribution or version of a distribution.
Therefore problems like this are prone to happen.

Please don’t modify the files in /usr/share/icinga2/*, this is managed by your package manger and this workaround will fall on your feet at some point.

The better solution/workaround is to create something like /etc/icinga2/zones.d/global-templates/commands/check_systemd.conf with the content:

object CheckCommand "my_systemd" {
  import "systemd"
  command = [ PluginDir + "/check_systemd"]

or something like that.

1 Like

This would normally be a good idea.

In my case I feel confident because I made the same change as what is coming down the line:

Thanks.