Highly Available HP-UX Internet Services (May 2008)

HP ServiceGuard Monitor Script for Sendmail
Following is a sample monitor script for Sendmail in an HP ServiceGuard environment:
#!/sbin/sh
#
# @(#) "sendmail" service's monitor script
#
unset UNIX95
PRE_U95=true;export PRE_U95;
PATH=/sbin:/usr/sbin:/usr/bin:$PATH
export PATH
# In case delay_checks in configured, that time should be added to this default_timeout
# default_timeout = (value of delay_checks) + (intended default_timeout)
default_timeout=10
tempfile="/tmp/inputfile"
tempfile1="/tmp/outputfile"
check_pid_file() {
grep "^O PidFile=" /etc/mail/sendmail.cf > /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
pidfile_mta=`grep "^O PidFile=" /etc/mail/sendmail.cf | sed 's/.*=//'`
else
pidfile_mta="/etc/mail/sendmail.pid"
fi
grep "^O PidFile=" /etc/mail/submit.cf > /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
pidfile_msp=`grep "^O PidFile=" /etc/mail/submit.cf | sed 's/.*=//'`
else
pidfile_msp="/var/spool/clientmqueue/sm-client.pid"
fi
if [ ! -f "$pidfile_mta" -a ! -f "$pidfile_msp" ]; then
return 1
fi
if [ -f "$pidfile_mta" ]; then
test "$pidfile_mta" && exec 0< "$pidfile_mta"
read -r PID
sendserv=`ps -e | grep -E "^ [ ]*$PID .*sendmail" | wc -l`
if [ $sendserv -eq 0 ]; then
return 1
fi
fi
if [ -f "$pidfile_msp" ]; then
test "$pidfile_msp" && exec 0< "$pidfile_msp"
read -r PID
sendserv=`ps -e | grep -E "^ [ ]*$PID .*sendmail" | wc -l`
if [ $sendserv -eq 0 ]; then
return 1
fi
fi
return 0
}
sm_hang_process() {
echo "EHLO HI" > $tempfile
echo "QUIT" >> $tempfile
telnet localhost 25 < $tempfile 2>/dev/null | grep "pleased to meet you" > tempfile1 2>&1 &
}
while true
do
check_pid_file
22