Nagios commandline error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Nagios commandline error

Post 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
Last edited by raamardhani7 on Mon Apr 04, 2016 6:04 pm, edited 1 time in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios commandline error

Post by lmiltchev »

How is "check_init_service1" defined in the "nrpe.cfg" (or "common.cfg") file? What are the permissions of the script?
Be sure to check out our Knowledgebase for helpful articles and solutions!
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: Nagios commandline error

Post by raamardhani7 »

check_init_service1 script's permission is 777 and owned by root:system
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios commandline error

Post by Box293 »

How is "check_init_service1" defined in the "nrpe.cfg" (or "common.cfg") file?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: Nagios commandline error

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios commandline error

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Nagios commandline error

Post 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.
Former Nagios Employee
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Re: Nagios commandline error

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios commandline error

Post by lmiltchev »

I am glad your issue has been resolved! I am closing the thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked