Write a plugin, CHECK_NRPE socket timeout after 10 second

Hi, I seriously need a help here. I’ve written a shell script to monitor our email system. This email service is part of our cluster system,i.e. when one server of the cluster system is down, the email service will move to another cluster server. I am using NRPE to monitor. All existing Nagios plugins are working fine with NRPE, but my own script. Please help me to take a look at my script. Thank you very mich.

--------here is my scipt---------

#!/bin/ksh

Script to monitor the SunONE Messaging Multiplexor # # $1 - IP Address of the MMP Server in dotted decimal # # [email protected] # # Written: 23Oct03 # Updated: 29Jun05

MAX_TRIES=3 # Maximum attempts to contact MMP
RETRY=10 # Seconds to wait between retry attempts

First test: Does the interface exist?

WC=ifconfig -a | grep inet | awk '{ print $2 }' | grep $1 | wc -l if $WC -ne 1 ]];
then
exit 1
fi

Second test: Is IMAP bound to the proper interface?

netstat -an | grep “$1.143” | grep LISTEN > /dev/null if $? -ne 0 ]];
then
exit 1
fi

Third test: Is POP3 bound to the proper interface?

netstat -an | grep “$1.110” | grep LISTEN > /dev/null if $? -ne 0 ]];
then
exit 1
fi

#Fourth test: Does the IMAP server respond to a simple query?
success=0
i=0
while $i -le $MAX_TRIES ]];
do
#/usr/local/bin/sock $1 143 $RETRY
/bin/echo “a001 NOOP\na001 LOGOUT” | /usr/local/bin/nc -w $RETRY $1
143 > /dev/null
RC=$?

if $RC -eq 0 ]];
then
success=1
break
fi

sleep $RETRY
i=$(( $i + 1 ))
done

if $success -ne 1 ]];
then
exit 1
fi

#Fifth test: Does the POP3 server respond to a simple query?
success=0
i=0
while $i -le $MAX_TRIES ]];
do
/bin/echo “quit\n” | /usr/local/bin/nc -w $RETRY $1 110 > /dev/null
RC=$?

if $RC -eq 0 ]];
then
success=1
break
fi

sleep $RETRY
i=$(( $i + 1 ))
done

if $success -ne 1 ]];
then
exit 1
fi

If all the tests succeed, exit with return code 1 exit 0

What output do you get when executed on cmd line as nagios user?

NPRE 2.3 if I issue the command ./check_nrpe -n -H
if I issue the command ./check_nrpe -H the output is : CHECK_NRPE: Socket timeout after 10 seconds.

I just issue the ./check_nrpe -n & ./check_nrpe command on the remote server, this time, i am using the nagios plugin which i know is working. However, the result is the same as above. I don’t know what’s wrong. I download nrpe.c from internet and compile it for me, since nrpe v1.95 for silaris on NagiosExchange is not working for me.