incorrect output

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
kdt
Posts: 3
Joined: Fri Nov 21, 2014 8:28 am

incorrect output

Post 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.
User avatar
rhassing
Posts: 412
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: incorrect output

Post 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.
Rob Hassing
Image
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: incorrect output

Post 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!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
kdt
Posts: 3
Joined: Fri Nov 21, 2014 8:28 am

Re: incorrect output

Post 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
User avatar
rhassing
Posts: 412
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: incorrect output

Post 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?
Rob Hassing
Image
kdt
Posts: 3
Joined: Fri Nov 21, 2014 8:28 am

Re: incorrect output

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: incorrect output

Post by abrist »

Are you sure? NRPE commands usually run as the nagios user . . .
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked