Page 1 of 1

Nagios commandline error

Posted: Mon Apr 04, 2016 5:00 pm
by raamardhani7
Hi,

When I specify the process name in the script, there is no problem identifying the process status.
However, when I type process name on the command prompt instead of specify the process name in the script, script does not function properly.

Could you help resolving this matter?

Here is the command which I ran from the command prompt:
/usr/local/nagios/libexec/check_nrpe -H dalcpldd10 -t 30 -c check_init_service1 mccdev -n

Here is my simple script (check_init_service1) :
#!/bin/sh

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3

PROGNAME=$(basename $0)

#process name is mccdev
#PROCESS="mccdev"
PROCESS="$1"

TMP_OUTPUT="/tmp/process_check.txt"

PID_EXIST=`ps -ef | grep "$PROCESS" | egrep -v "grep|$PROGNAME"`
if [ -z "$PID_EXIST" ]
then
RETURN_STATUS=$STATE_CRITICAL
FINAL_STATUS="CRITICAL"
PERFORMANCE="NOT RUNNING"
FINAL_STATUS="$FINAL_STATUS|$PERFORMANCE"
else
ps -ef | grep "$PROCESS" | egrep -v "grep|$PROGNAME" > $TMP_OUTPUT
cat "$TMP_OUTPUT" | while read -r line
do
PID=`echo $line |awk '{print $2}'`
PID_STATUS=`echo $line |awk '{print $9}'`
if [[ "$PID_STATUS" == "db2sysc" ]]
then
RETURN_STATUS=$STATE_OK
FINAL_STATUS="OK"
PERFORMANCE="$PROCESS RUNNING"
FINAL_STATUS="$FINAL_STATUS|$PERFORMANCE"
fi
done

fi

if [ -f $TMP_OUTPUT ]
then
/bin/rm -f $TMP_OUTPUT
fi

echo "$FINAL_STATUS"
exit $RETURN_STATUS

Re: Nagios commandline error

Posted: Mon Apr 04, 2016 5:05 pm
by lmiltchev
How is "check_init_service1" defined in the "nrpe.cfg" (or "common.cfg") file? What are the permissions of the script?

Re: Nagios commandline error

Posted: Mon Apr 04, 2016 6:06 pm
by raamardhani7
check_init_service1 script's permission is 777 and owned by root:system

Re: Nagios commandline error

Posted: Mon Apr 04, 2016 7:15 pm
by Box293
How is "check_init_service1" defined in the "nrpe.cfg" (or "common.cfg") file?

Re: Nagios commandline error

Posted: Tue Apr 05, 2016 10:34 am
by raamardhani7
Box293 wrote:How is "check_init_service1" defined in the "nrpe.cfg" (or "common.cfg") file?
Check is defined in the following way:

Code: Select all

command[check_init_service1]=/usr/local/nagios/libexec/check_init_service1

Re: Nagios commandline error

Posted: Tue Apr 05, 2016 11:37 am
by lmiltchev
You need to pass the process as an argument (i.e. "mccdev"), correct? Change your command from this:

Code: Select all

command[check_init_service1]=/usr/local/nagios/libexec/check_init_service1
to this:

Code: Select all

command[check_init_service1]=/usr/local/nagios/libexec/check_init_service1 $ARG1$
and restart nrpe (xinetd) on the client. Let us know if this helped.

Re: Nagios commandline error

Posted: Tue Apr 05, 2016 11:38 am
by rkennedy
raamardhani7 wrote:Hi,
When I specify the process name in the script, there is no problem identifying the process status.
However, when I type process name on the command prompt instead of specify the process name in the script, script does not function properly.
Can you show us examples of both of these? I'm trying to understand where y our error is at, and it sounds like it's in the plugin you posted.

Re: Nagios commandline error

Posted: Mon Apr 11, 2016 8:36 pm
by raamardhani7
rkennedy wrote:
raamardhani7 wrote:Hi,
When I specify the process name in the script, there is no problem identifying the process status.
However, when I type process name on the command prompt instead of specify the process name in the script, script does not function properly.
Can you show us examples of both of these? I'm trying to understand where y our error is at, and it sounds like it's in the plugin you posted.
Hi Team,

You can close this thread, my fault I didn't added that $ARG1$ in the nrpe.cfg, now it is added and the script is returning the exact results. thanks for your continuous help.

Re: Nagios commandline error

Posted: Tue Apr 12, 2016 8:50 am
by lmiltchev
I am glad your issue has been resolved! I am closing the thread.