# Plugins contrib systemd config is wrong

**URL:** <https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971>\
**Category:** Icinga 2\
**Tags:** icinga2\
**Created:** [August 11, 2024, 4:38pm UTC](https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971 "2024-08-11T16:38:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![isaaclw](https://community.icinga.com/user_avatar/community.icinga.com/isaaclw/32/7989_2.png) [@isaaclw](https://community.icinga.com/u/isaaclw)\
**Post date:** [August 11, 2024, 4:38pm UTC](https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971/1 "2024-08-11T16:38:08Z")

</div>

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:

```auto
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`:

```auto
/* 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`:

```auto
$ 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.

---

<div class="post-metadata">

**Author:** ![isaaclw](https://community.icinga.com/user_avatar/community.icinga.com/isaaclw/32/7989_2.png) [@isaaclw](https://community.icinga.com/u/isaaclw)\
**Post date:** [August 11, 2024, 4:39pm UTC](https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971/2 "2024-08-11T16:39:49Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![rsx](https://community.icinga.com/user_avatar/community.icinga.com/rsx/32/2094_2.png) [@rsx](https://community.icinga.com/u/rsx)\
**Post date:** [August 12, 2024, 6:22am UTC](https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971/3 "2024-08-12T06:22:24Z")

</div>

> [@isaaclw](#):
>
> After I edited the file provided by `icinga2-common` (by removing the .py) and restarting icinga2 manually on my agent, the checks were fixed.

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](https://github.com/Josef-Friedrich/check_systemd) for which the command is defined in icinga2-common.

---

<div class="post-metadata">

**Author:** ![lorenz](https://community.icinga.com/user_avatar/community.icinga.com/lorenz/32/7666_2.png) [@lorenz](https://community.icinga.com/u/lorenz)\
**Post date:** [August 12, 2024, 12:20pm UTC](https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971/4 "2024-08-12T12:20:18Z")

</div>

This is a [known problem](https://github.com/Icinga/icinga2/issues/9547). 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:

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

```

or something like that.

---

<div class="post-metadata">

**Author:** ![isaaclw](https://community.icinga.com/user_avatar/community.icinga.com/isaaclw/32/7989_2.png) [@isaaclw](https://community.icinga.com/u/isaaclw)\
**Post date:** [August 13, 2024, 1:48pm UTC](https://community.icinga.com/t/plugins-contrib-systemd-config-is-wrong/13971/5 "2024-08-13T13:48:15Z")

</div>

> [@lorenz](#):
>
> 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:

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:

> <https://github.com/Icinga/icinga2/commit/a2194367080c779f46a3585d9571a788368e80c1>
>
> The executable name for check\_systemd's dropped the \`.py\` suffix for
> version 2.0….3\[0\], released in April 2019\[1\]. However, the old name is
> still being referenced, both in documentation as well as in the ITL's
> CheckCommand's command, making it unusable.
> 
> Closes #9547.
> 
> \[0\]: https://github.com/Josef-Friedrich/check\_systemd/compare/v2.0.2...v2.0.3#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7
> \[1\]: https://github.com/Josef-Friedrich/check\_systemd/releases/tag/v2.0.3

Thanks.
