How to pass multiple arguments in commands.conf

Hi Team,

I am setting up Icinga2 to monitor hosts. I have couple of issues with the following checks:
1: check_uptime
2: check_disk (on couple of hosts)

check_uptime: If i execute the following command from command line it works as expected:
/usr/lib64/nagios/plugins/check_nrpe -H host_name -c check_uptime -a “warn=uptime < 10h” “crit=uptime <2h”
WARNING: uptime: 09:31h, boot: 2019-Feb-19 04:50:32 (UTC)|‘uptime’=34262s;36000;7200

Now if i put this command in command.conf to monitor all my hosts it doesn’t work

object CheckCommand “check_host_uptime” {
command = [ PluginContribDir + “/check_nrpe” ]
arguments = {
“–host” = “$hostname$”
“-a” = “warn=uptime <10h”
“–command” = “check_uptime”
}
}

I am unable to put “warn=crit <1h”. No matter how i put i always get an error. Can someone help me in passing both warn and crit arguments in commands.cfg file? Any help will be much appreciated.

2: check_disk: This check is not working on couple of hosts. I get the following error:
image
The same check is working for other partitions on the same host but fails for root partition.

Thanks,
Rahul

Hi,

why don’t you use the existing nrpe CheckCommand and pass additional arguments in there? :slight_smile:

Cheers,
Michael

1 Like

You mean to say use the command directly in services.conf file rather than calling it from commands.conf?

Try this in the service.conf:

apply Service “memory-windows” {
import “generic-service”
check_command = “nrpe”

    vars.nrpe_command = "check_memory"
    vars.nrpe_arguments = [
      "warning=used > 90",
      "critical=used > 95" ]
vars.nrpe_timeout_unknown =     true // -u
vars.nrpe_no_ssl =              true // -n

    assign where match ("*ABC*", host.name)

}

An alternative is to use a check command:

object CheckCommand “check-nrpe-disks” {
import “disk”
import “nrpe”

        vars.nrpe_command = "check_disk"
        vars.nrpe_arguments = "-w $disk_wfree$ -c $disk_cfree$ -W $disk_inode_wfree$ -K $disk_inode_cfree$ -p $disk_partitions$ -u $disk_units$"

    vars.nrpe_timeout_unknown =     true // -u
    vars.nrpe_no_ssl =              true // -n

}

1 Like

That won’t work, Icinga expects single arguments being escaped. Rather write it this way:

vars.nrpe_arguments = [ "-w", "$disk_wfree$", "-c", "$disk_cfree$" ]

and so on.

Cheers,
Michael

My config works :slight_smile:

object CheckCommand “check-nrpe-disks” {
import “disk”
import “nrpe”

        vars.nrpe_command = "check_disk"
        vars.nrpe_arguments = "-w $disk_wfree$ -c $disk_cfree$ -W $disk_inode_wfree$ -K $disk_inode_cfree$ -p $di

    vars.nrpe_timeout_unknown =     true // -u
    vars.nrpe_no_ssl =              true // -n

}

apply Service for (disk => config in host.vars.disks) {
import “generic-service”
check_command = “check-nrpe-disks”

    vars += config

    assign where host.vars.disks != ""

}

object Host “98livsaparb-dt” {
import “unix-work”
address = “100.00.00.00”
notes = “SAP Arbiter Developement & Test”
vars.gluster = true
vars.storage = false

    vars.disks["glusterfs"] = {
            nrpe_arguments = "-w 10% -c 5% -W 10% -K 5% -p /glusterfs"
    }

    vars.disks["root"] = {
    nrpe_arguments = "-w 10% -c 5% -W 10% -K 5% -p / -u GB"
}

}

check_1 check_2

I think there is a better solution for my setting…

1 Like

@dnsmichi my nrpe_arguments in the command are useless. The check uses the arguments from the host config, but its work fine

1 Like