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
Nagios commandline error
-
raamardhani7
- Posts: 459
- Joined: Tue Jun 02, 2015 12:36 am
Nagios commandline error
Last edited by raamardhani7 on Mon Apr 04, 2016 6:04 pm, edited 1 time in total.
Re: Nagios commandline error
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
check_init_service1 script's permission is 777 and owned by root:system
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios commandline error
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
Check is defined in the following way:Box293 wrote:How is "check_init_service1" defined in the "nrpe.cfg" (or "common.cfg") file?
Code: Select all
command[check_init_service1]=/usr/local/nagios/libexec/check_init_service1
Re: Nagios commandline error
You need to pass the process as an argument (i.e. "mccdev"), correct? Change your command from this:
to this:
and restart nrpe (xinetd) on the client. Let us know if this helped.
Code: Select all
command[check_init_service1]=/usr/local/nagios/libexec/check_init_service1Code: Select all
command[check_init_service1]=/usr/local/nagios/libexec/check_init_service1 $ARG1$Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Nagios commandline error
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.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.
Former Nagios Employee
-
raamardhani7
- Posts: 459
- Joined: Tue Jun 02, 2015 12:36 am
Re: Nagios commandline error
Hi Team,rkennedy wrote: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.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.
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
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!