Page 2 of 2

Re: NRPE: unable to read output.

Posted: Thu Jun 07, 2018 10:17 am
by Ravikimt
As you have suggested I added echo $pid in my check_node script but same thing not getting any output.
I restarted nrpe service also after making the changes in the script

Code: Select all

#!/bin/bash

#Mentioned valid service name
service=node

#Checking for service pid value
pid=`ps -ef | grep -v grep | grep -i $service | wc -l`

case $pid in
[2]*)

echo $pid
echo "OK - $service is running" 
exit 0
;;

[0]*)

echo $pid
echo "CRITICAL -$service is not running"
exit 2
;;

[1]*)

echo $pid
echo "WARNING -$service Please check the service"
exit 1
;;

esac
I tried with this command also but doesn't help.

Code: Select all

sudo su nagios -c /usr/local/nagios/libexec/node_check

Re: NRPE: unable to read output.

Posted: Thu Jun 07, 2018 10:26 am
by Ravikimt
Sorry I have mentioned wrong variable in my code instead of var i am using pid var only so ignore that var in check_node

Re: NRPE: unable to read output.

Posted: Thu Jun 07, 2018 10:27 am
by scottwilkerson
Change it to this

Code: Select all

#!/bin/bash

#Mentioned valid service name
service=node

#Checking for service pid value
var=`ps -ef | grep -v grep | grep -i $service | wc -l`

echo $var

case $var in
[2]*)


echo "OK - $service is running"
exit 0
;;

[0]*)

echo $pid
echo "CRITICAL -$service is not running"
exit 2
;;

[1]*)

echo $pid
echo "WARNING -$service Please check the service"
exit 1
;;

esac

Re: NRPE: unable to read output.

Posted: Thu Jun 07, 2018 10:39 am
by Ravikimt
Yes, I have changed the script now I am getting the correct output

Code: Select all

bash /usr/local/nagios/libexec/check_node
4
OK -node is running
tell me the next step what I have to do.?

Re: NRPE: unable to read output.

Posted: Thu Jun 07, 2018 10:48 am
by Ravikimt
I resolved the issue thanks a lot man you are genius man .

Re: NRPE: unable to read output.

Posted: Thu Jun 07, 2018 10:53 am
by scottwilkerson
Ravikimt wrote:I resolved the issue thanks a lot man you are genius man .
Excellent!

Glad we could help. Locking thread