No such file or directory

Hi,

Setup is just one master and two clients to try some stuff out.
Cluster check is okay and endpoints are connected using icinga2 agent and several (default) checks do their work.
I created a check_test.sh script with a exit to see if I could execute a script on the clients.
This works just fine.

But…then I wanted to try check_mem.pl
cd /usr/lib/nagios/plugins/
wget https://raw.githubusercontent.com/ckujau/nagios-plugins/master/check_mem.pl
chmod +x check_mem.pl

Executing locally works fine:
root@vm6:~# sudo -u nagios /usr/lib/nagios/plugins/check_mem.pl -u -w 70 -c 90 -C
OK - 10.3% (415012 kB) used.|TOTAL=4041612KB;;;; USED=415012KB;2829128;3637450;; FREE=3626600KB;;;; CACHES=347288KB;;;;

Services.conf created:

apply Service “check_mem” {
import “slowcheck-service”
display_name = “Check memory”
check_command = “check_mem”
vars.warning = 70
vars.critical = 90
assign where host.vars.client_endpoint
}

In global-templates zone defined the command as following:

object CheckCommand "check_mem"{
    import "plugin-check-command"
    command =  [PluginDir + "/check_mem.pl"]

    arguments += {
            "-u" = {}
            "-w" = {
             required = true
             value = "$warning$"
            }
            "-c" = {
             required = true
             value = "$critical$"
            }
            "-C" = {}
    }
 }

icinga2 daemon -C gives no errors. Restarting service after changes. The changes are also visible on the clients (/var/lib/icinga2/api/zones/global-templates/_etc)
Above settings give me UNKNOWN “execvpe(/usr/lib/nagios/plugins/check_mem.pl) failed: No such file or directory” .

What is it that I’m doing wrong? Any tips/suggestions?

This works:

cat /usr/lib/nagios/plugins/plugin_test

#!/usr/bin/bash
echo 2
exit 2;

Service:

apply Service "check_test_ok" {
import "generic-service"
check_command = "check_test"
command_endpoint = host.vars.client_endpoint
assign where host.vars.client_endpoint

}

command:

object CheckCommand “check_test” {
import “plugin-check-command”
command = [PluginDir + “/plugin_test”]
}

While typing this, I found my own solution. :slight_smile: Didnt want to delete my post , maybe others find their solution here to.

//specify where the check is executed, add:
command_endpoint = host.vars.client_endpoint

Just as a hint, the check_mem check command is already provided by ITL.

Thx @m4k5ym but I got some different results when using that. Some differences between different vps servers. Think it has to do with the swap being used or not.
Using the check_mem.pl with the -S parameter solved this or I missed something using the check_mem from ITL

*EDIT think you’re right, using -S solves this also for the check_mem provided by ITL

Where do you use -S exactly? Because I can’t find it in the script it self actual.

C

Sorry again )-: Mean to say -C not -S