Page 1 of 2

check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 6:12 am
by wspackaging
Goal: Check the running time of a java process and alert on it.

From the Nagios Exchange I got the check_proc_age.sh script.

From the cli on the host it runs great and gives me the output I'm expecting.
# /admin/nagios_plugins/check_proc_age.sh -p java -w 21600 -c 43200
WARNING: there are 2 process java, oldest has got 6 Hours 30 minutes age


from Nagios XI when I run the command is isn't connecting out to the remote host I want monitored. it is only checking the nagios xi server.
Ok
OK: there is no process matching java


The command being run from Nagios is:
check_process_age!-p java !-w 21600 -c 43200!!!!!!

The Exchange page doesn't explain how to configure in XI. Or I'm missing it.
http://exchange.nagios.org/directory/Pl ... sh/details

I'm missing something and I'm guessing it is a pretty basic thing. If anybody could point me to the doc or forum page explaining how to set this up I would appreciate it.

thanks
-pete

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 7:59 am
by BanditBBS
You need to use check_nrpe to check the remote host and make sure the check file is copied to the remote host's NRPE plugins location.

Check_nrpe is used to execute scripts on remote hosts. If you need more details, just say so :)

Jim/Bandit

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 4:07 pm
by lmiltchev
Thanks, BanditBBS!

@wspackaging
Let us know if you have any issues with installing NRPE on the remote server or setting up your checks.

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 4:25 pm
by wspackaging
I still have something wrong.

I put the check_proc_age.sh on the remote server in /usr/local/nagios/libexec/

in the XI config manager > Services > modify > Check process age I have it configured:
Check Command = check_nrpe
active = checked
command view = $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
$ARG1$ = check_proc_age.sh
$ARG2$ = -p java w 21600 -c 43200

Then when I run the "Test Check Command" I get a usage error.
Testing check from command line...

COMMAND: /usr/local/nagios/libexec/check_nrpe -H dc1ux082 -t 30 -c check_proc_age.sh -p java w 21600 -c 43200
OUTPUT: Incorrect command line arguments supplied

NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Version: 2.12
Last Modified: 03-10-2008
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 [-n] [-u] [-p ] [-t ] [-c ] [-a ]

Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
= The address of the host running the NRPE daemon
[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.

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 4:44 pm
by wspackaging
from the Service Details > Configure > Re-configure this service

it looks like this:
check_nrpe!check_proc_age.sh!-a '-p java -w 21600 -c 43200'!!!!!!

I get this error now.
NRPE: Command 'check_proc_age.sh' not defined

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 5:00 pm
by sreinhardt
How do you have this command definied in the nrpe configuration? Normally, you can make a check that does, you would not address the script directly from the nagios command definition, but have an additional command on the nrpe side that references it. Glad you found the -a flag!

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 5:35 pm
by BanditBBS
Let me add to what Spencer said.....

Go into nrpe.cfg on the remote server and scroll to the bottom. In there you should see commands defined. Your check_pro_age isn't defined, you need to add it there. Also if your NRPE was not installed with the allow arguements enabled, the the -a and everything after it will cause an error. You would have to define the entire command in the nrpe.cfg file.

Remember, if you make a change to nrpe.cfg that nrpe needs restarted(either nrpe service or xinetd or however it is running.)

Let me know if I didn't explain that well enough.

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 7:03 pm
by wspackaging
Getting closer :D

I had nothing in the nrpe config. I added this.
command[check_proc_age.sh]=/usr/local/nagios/libexec/check_proc_age.sh -p $ARG1$ -w $ARG2$ -c $ARG3$

I then went back into config manager and I now have the command set up like:

check_nrpe!check_proc_age.sh!-a '-p java!-w 21600 -c 43200'!!!!!

Now when I run a check it comes back as null

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 7:10 pm
by BanditBBS
wspackaging wrote:Getting closer :D

I had nothing in the nrpe config. I added this.
command[check_proc_age.sh]=/usr/local/nagios/libexec/check_proc_age.sh -p $ARG1$ -w $ARG2$ -c $ARG3$

I then went back into config manager and I now have the command set up like:

check_nrpe!check_proc_age.sh!-a '-p java!-w 21600 -c 43200'!!!!!

Now when I run a check it comes back as null
Make it:
command[check_proc_age]=/usr/local/nagios/libexec/check_proc_age.sh -p $ARG1$ -w $ARG2$ -c $ARG3$

And forget testing in Nagios, just from the command line in the libexec folder of your nagios server type:

Code: Select all

./check_nrpe -H ip_address -c check_proc_age -a 'java! 21600 43200'
You might have to use double quotes because of the ! in the process name.

EDIT: That command I said to test with may be wrong, fighting my own issue at the moment and didn't spend enough time checking for you

Re: check_proc_age.sh not connecting to remote host

Posted: Thu Sep 12, 2013 7:35 pm
by BanditBBS
Ok, my issue has been resolved, so now I can continue to help you :)

Anyway, change the command definition in nrpe.cfg to

Code: Select all

command[check_java]=/usr/local/nagios/libexec/check_proc_age.sh -p java!-w 21600 -c 43200
Then from your nagios server

Code: Select all

./check_nrpe -H ip_address -c check_java
Again, make sure you restart nrpe after making the change. This eliminates any configuration issue and also won't cause an issue if your nrpe was installed with not allowing command line arguments. If this works, this at least gets you going, then you can play around with customizing with the arguments.