Page 1 of 1

incorrect output

Posted: Fri Nov 21, 2014 8:44 am
by kdt
Hi All,

I have one shell script, using to check two process running or not.
When i run that script on client it gives correct output (process running or not) but while running plugins from nagios server its gives opposite out-put.
Below is script :

cat check_consum_process
#!/bin/sh
#set -x
COUNT2=`ps -aef | grep -v grep | egrep 'AB.py |XX.py' | wc -l`
if
[ $COUNT2 -eq 2 ]
then
echo "AB.py/XX.py OK"
exit 0
else
echo "AB.py/XX.py NOT OK"
exit 2
fi

OUTPUT on client end.
Command :: ./check_consum_process
OUTPUT :: AB.py/XX.py OK

OUTPUT from nagios server :
command :: /usr/lib/nagios/plugins/check_nrpe -H ABC_server -c check_custom_consum_process
Output :: AB.py/XX.py NOT OK

Don't know whats going wrong here..:(
Nagios Version 3.2.1
Please help.

Re: incorrect output

Posted: Fri Nov 21, 2014 10:11 am
by rhassing
Maybe you could change the script to:

Code: Select all

#!/bin/sh
#set -x
COUNT=`ps -aef | grep -v grep | egrep 'AB.py |XX.py' 
COUNT2=`ps -aef | grep -v grep | egrep 'AB.py |XX.py' | wc -l`
if
[ $COUNT2 -eq 2 ]
then
echo $COUNT
echo $COUNT2
echo "AB.py/XX.py OK"
exit 0
else
echo $COUNT
echo $COUNT2
echo "AB.py/XX.py NOT OK"
exit 2
fi
That would make it a bit easier to what goes wrong.

Re: incorrect output

Posted: Fri Nov 21, 2014 2:50 pm
by sreinhardt
That's an excellent point, as it would give you the ps output post greps and the count that your script is seeing! At least while debugging, I couldn't agree more!

Re: incorrect output

Posted: Mon Nov 24, 2014 2:32 am
by kdt
Hi ,

Have change the script as per suggestion.
Please let me know how to fix it.
Below is the output..

Client End Out put :
web 21887 1 1 Nov21 1 01:10:35 python ./AB.py --logging-level=debug --logging-file=XXXXXXX web 29040 1 6 Nov17 1 10:24:36 python ./XX.py --logging-level=debug --logging-file=YYYYYY
2
AB.py/XX.py OK


Server Output ::

web 21887 1 1 Nov21 ? 01:10:35 python ./AB.py --logg
1
AB.py/XX.py NOT OK

Re: incorrect output

Posted: Mon Nov 24, 2014 9:11 am
by rhassing
I seems that it doesn't find the proces

Code: Select all

web 29040 1 6 Nov17 1 10:24:36 python ./XX.py --logging-level=debug --logging-file=YYYYYY
when you are running the script from the server.

Is the NRPE allowed to see both processes? Could it be that you are running the script as root on the client and not when run from the server?

Re: incorrect output

Posted: Mon Nov 24, 2014 9:21 am
by kdt
Both process running under web user & command was triggered by root users on both end (client & server ).
Server is showing count as 1 instant of 2 so i think its able to read & grep.
Please correct me if wrong.

Re: incorrect output

Posted: Mon Nov 24, 2014 5:51 pm
by abrist
Are you sure? NRPE commands usually run as the nagios user . . .