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.
incorrect output
Re: incorrect output
Maybe you could change the script to:
That would make it a bit easier to what goes wrong.
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
Rob Hassing
-
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: incorrect output
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.
Re: incorrect output
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
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
I seems that it doesn't find the proces
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?
Code: Select all
web 29040 1 6 Nov17 1 10:24:36 python ./XX.py --logging-level=debug --logging-file=YYYYYY
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
Re: incorrect output
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.
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
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.
"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.