Debian – Nagios command not transmitting all arguments

debiannagiospostgresql

I'm using the following service to monitor our postgres db from nagios:

define service{
       use                             test-service         ; Name of servi$
       host_name                       DEMOCGN002
       service_description             Postgres State
       check_command                   check_nrpe!check_pgsql!192.168.1.135!test!test!test
       notifications_enabled           1
       }

On the remote machine I've configured the command:

command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -H $ARG1$ -d $ARG2$ -l $ARG3$ -p $ARG4$

In the syslog I can see that command is executed, but there is only one argument transmitted:

Oct 20 13:18:43 DEMOSRV01 nrpe[1033]: Running command: /usr/lib/nagios/plugins/check_pgsql -H 192.168.1.134 -d  -l  -p 
Oct 20 13:18:43 DEMOSRV01 nrpe[1033]: Command completed with return code 3 and output: check_pgsql: Database name is not valid - -l#012Usage:#012check_pgsql [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]#012 [-t <timeout>] [-d <database>] [-l <logname>] [-p <password>]
Oct 20 13:18:43 DEMOSRV01 nrpe[1033]: Return Code: 3, Output: check_pgsql: Database name is not valid - -l#012Usage:#012check_pgsql [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]#012 [-t <timeout>] [-d <database>] [-l <logname>] [-p <password>]

Why are arguments 2,3 and 4 missing?

Best Answer

You're mixing up the arguments which are defined on monitoring host with the arguments on the remote host. The $ARGx$ macro cannot be used on the NRPE host.

Be default, the check_nrpe command is defined as belows:

define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 120
}

On the remote host you must use the 'real' value, something like this:

command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -d test -l test -p test

and this command can be called from the Nagios host with:

define service{
    use                     test-service         
    host_name               DEMOCGN002
    service_description     Postgres State
    check_command           check_nrpe!check_pgsql
    notifications_enabled   1
    }

No need to pass the IP address because it get the value of host_name.