Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!!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 -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?

share|improve this question
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 B C D". Seems that the arguments 2,3 and 4 are not passed. – markus Oct 20 '11 at 13:19
up vote 10 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.

share|improve this answer

I had the same trouble and respectfully disagree a little with the accepted answer, so I thought I would post the solution in case someone else comes across it.

You CAN execute a remote script using nrpe whilst passing it command line arguments from the monitoring host, otherwise you would have to give the remote script hard values on every single remote machine which isn't feasible for large set-ups.

Here is how it works on mine, this works for passing 3 arguments remotely, but you can increase the number in your commands.cfg or equivalent file:

# Check NRPE command
define command {
    command_name check_nrpe
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ $ARG3$ $ARG4$

Notice that $ARG1$ in the above line is reserved for the command itself, so its actually $ARG2$, $ARG3$ and $ARG4$ that get sent to the remote script, but when they arrive at the remote script they will be listed as $ARG1$ $ARG2$ and $ARG3$ (this is what markus was saying about mixing up arguments) and therefore must be defined as such in the remote machine's nrpe.cfg

The remote machine(s) nrpe.cfg:

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

And finally define the service:

define service{
    use                             test-service;
    host_name                       DEMOCGN002;
    service_description             Postgres State;
    check_command                   check_nrpe!check_pgsql!test!test!test;
    notifications_enabled           1;
share|improve this answer
Works for me.Not being able to pass multiple arguments to commands via NRPE seems unreasonable. – Adrian Aug 28 '13 at 10:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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