Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2k stars 574 forks source link

CheckCommand broken because plugin is not in PluginDir or PluginContribDir #10154

Open phibos opened 3 weeks ago

phibos commented 3 weeks ago

Describe the bug

By default PluginDir and PluginContribDir are set to /usr/lib/nagios/plugins. https://github.com/Icinga/icinga2/blob/8beb0b74ab9f8402abf4a05b9b768d312304e3f0/CMakeLists.txt#L54

As long as I install my plugins manually into the plugin directory everything works fine. But if I use the packaged plugins shipped with the distributions I get into trouble because Debian and Ubuntu seem to change the location of some plugins.

btrfs check command

The btrfs check command is defined as:

object CheckCommand "btrfs" {
    import "plugin-check-command"
    command = [ "sudo", PluginContribDir + "/check_btrfs" ]

Source: https://github.com/Icinga/icinga2/blob/8beb0b74ab9f8402abf4a05b9b768d312304e3f0/itl/plugins-contrib.d/storage.conf#L91

Debian

/usr/lib/nagios-btrfs/plugins/check_btrfs

rabbitmq

Currently not in the ITL

On Ubuntu the path changes.

Ubunut 20.04, 22.04, 24.04: /usr/lib/nagios/plugins-rabbitmq/ Ubuntu 24.10: /usr/bin

Source: https://packages.ubuntu.com/noble/nagios-plugins-rabbitmq

Debian 11: /usr/lib/nagios/plugins-rabbitmq Debian 12: /usr/bin/

To Reproduce

Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include configuration, logs, etc. to reproduce, if relevant.

Install icinga on the system and use the check command

Expected behavior

Find the right location of the check_command binary

Your Environment

Include as many relevant details about the environment you experienced the problem in

Additional context

The to check plugins are only examples there might be more. Do you have any advice/idea how to fix this issue? Should we introduce additional constants for every check command in the constants.conf? https://github.com/Icinga/icinga2/blob/8beb0b74ab9f8402abf4a05b9b768d312304e3f0/etc/icinga2/constants.conf.cmake like in the example below.

const PluginContribDir = "/usr/lib/nagios/plugins/"
const PluginBtrfsDir = "/usr/lib/nagios-btrfs/plugins/"

Or is this something the user has to deal with. In this case I think it would be better to not ship the predefined check commands in the ITL and create an additional repository for additional check command examples.