Page 1 of 4

check_procs not working with nrpe

Posted: Fri Aug 08, 2014 1:52 pm
by klee
Hi,

As you can see, the check_procs plugin works, as does NRPE. However, when I try to run check_proc via NRPE, it give me this error and then doles out the usage instructions (as seen below).
Please note: Although I am showing this from localhost, I have the same problems from remote host (our Nagios server).
--enable-ssl and --enable-command-args were compiled into NRPE. The 'dont_blame_nrpe' directive in the NRPE config file have been set to 1.

I'm not sure what I'm doing wrong at this point. Can you guys please advise?

Thanks,

-klee

-------------------------------------------------------------------------------------------------------------

[root@TestServer]# ./check_procs -C workserver
PROCS OK: 1 process with command name 'workserver' | procs=1;;;0;

[root@TestServer]# ./check_nrpe -H 127.0.0.1
NRPE v2.15

[root@TestServer]# ./check_nrpe -H 127.0.0.1 -c check_procs -C workserver
./check_nrpe: invalid option -- 'C'

NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.15
Last Modified: 09-06-2013
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required

Usage: check_nrpe -H <host> [ -b <bindaddr> ] [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]

Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
<bindaddr> = bind to local address
-4 = user ipv4 only
-6 = user ipv6 only
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.

Note:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.

Re: check_procs not working with nrpe

Posted: Fri Aug 08, 2014 2:05 pm
by abrist
Can you post the check_procs command definition from the remote host's nrpe.cfg?

Re: check_procs not working with nrpe

Posted: Fri Aug 08, 2014 2:36 pm
by klee
Hi Abrist,

On the remote host, check_procs is defined as follows in /usr/local/nagios/etc/nrpe.cfg

command[check_procs]=/usr/local/nagios/libexec/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$

Thanks,

-klee

Re: check_procs not working with nrpe

Posted: Fri Aug 08, 2014 2:44 pm
by abrist
The nrpe.cfg command expects 3 arguments:

Code: Select all

command[check_procs]=/usr/local/nagios/libexec/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
they are:

Code: Select all

warning (-w $ARG1$)
critical (-c $ARG2$)
state (-s $ARG3)
You are trying to run the check with 1 $ARGn$ that is not configured in the command. Essentially, your current command looks like the following when it gets run by nrpe:

Code: Select all

/usr/local/nagios/libexec/check_procs -w -C -c workserver -s
Which is all sorts of wrong.
You may want to add a new command that looks like:

Code: Select all

command[check_procs_command]=/usr/local/nagios/libexec/check_procs -C $ARG1$
And then check it with:

Code: Select all

./check_nrpe -H 127.0.0.1 -c check_procs workserver
Or abstract the $ARGn$s completely like the following command:

Code: Select all

command[check_procs_command]=/usr/local/nagios/libexec/check_procs $ARG1$
And check it with:

Code: Select all

./check_nrpe -H 127.0.0.1 -c check_procs -a '-C workserver'
The latter way would allow you to run other combinations of switches and $ARGn$s with the same command. For example:

Code: Select all

./check_nrpe -H 127.0.0.1 -c check_procs -a '-w 150 -c 250'

Re: check_procs not working with nrpe

Posted: Fri Aug 08, 2014 3:01 pm
by klee
Thanks so much, Abrist. This worked perfectly.

I really appreciate your detailed explanation.

I'm going to work on configuring the service (over the weekend) in NagiosXI... I'll keep you posted.

Best Regards,

-klee

check_procs not working with nrpe (continued)

Posted: Tue Aug 12, 2014 10:35 am
by klee
Hi,

We want to monitor "bioserver, workserver, server cmr, server msg, server timer” with check_procs.
As you can see from the output of check_procs, it seems to have a problem handling processes containing multiple words.
I've tried using single and double quotes with no success. Can you please advise?

root 2547 1 0 Jul30 ? 02:17:14 /exc/bioserver
root 2881 1 0 Jul30 ? 00:00:05 server timer
root 2882 1 0 Jul30 ? 00:07:27 server msg
root 2883 1 0 Jul30 ? 00:00:00 server cmr
root 2886 1 0 Jul30 ? 00:00:00 workserver

Code: Select all

[root@bcsnsnagios1 libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C bioserver'
PROCS OK: 1 process with command name 'bioserver' | procs=1;;;0;

[root@bcsnsnagios1 libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C workserver'
PROCS OK: 1 process with command name 'workserver' | procs=1;;;0;

[root@bcsnsnagios1 libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C server cmr'
PROCS WARNING: 3 processes with command name 'server' | procs=3;cmr;;0;

[root@bcsnsnagios1 libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C server mgr'
PROCS WARNING: 3 processes with command name 'server' | procs=3;mgr;;0;

[root@bcsnsnagios1 libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C server timer'
PROCS WARNING: 3 processes with command name 'server' | procs=3;timer;;0;
Also, I just wanted to confirm if it's OK to use check_procs in this manner (to check for the existence of specific processes) without using the RANGE or other options?

Thanks,

-klee

Re: check_procs not working with nrpe (continued)

Posted: Tue Aug 12, 2014 10:40 am
by tmcdonald
You probably need to quote the proc name too:

Code: Select all

[...] -c check_procs -a '-C "server cmr"'

Re: check_procs not working with nrpe (continued)

Posted: Tue Aug 12, 2014 11:20 am
by klee
Unfortunately, that does not work. Below are check_procs outputs (using quotes) performed locally and remotely.

Code: Select all

[root@TestServer]# /usr/local/nagios/libexec/check_procs -C "server timer"
PROCS OK: 0 processes with command name 'server timer' | procs=0;;;0;

[root@Nagios]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C "server timer"'
CHECK_NRPE: Received 0 bytes from daemon.  Check the remote server logs for error messages.

Re: check_procs not working with nrpe

Posted: Tue Aug 12, 2014 4:21 pm
by abrist
Double quotes are illegal characters in when used in an arg (-a) through NRPE.

Re: check_procs not working with nrpe

Posted: Tue Aug 12, 2014 4:42 pm
by klee
Hi Abrist,

I figured as much, but tmcdonald asked me to try, so I posted the output.

Thanks,

-klee