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?

link|improve this question

80% accept rate
Is check-pgsql receiving them? Try writing a little script that catches them ans writes them to a file. Then, change the command[check_pgsql] to the temporary script. – Bart De Vos Oct 20 '11 at 12:58
I changed it to command[check_pgsql]=echo A $ARG1$ B $ARG2$ C $ARG3$ D $ARG4$ >> /tmp/nagiostest.log. In the log I see "A 192.168.1.134 B C D". Seems that the arguments 2,3 and 4 are not passed. – markus Oct 20 '11 at 13:19
feedback

1 Answer

up vote 5 down vote accepted

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.