MC/ServiceGuard
Case Study: Oracle Web Application
Server
Attachment A
#!/usr/bin/sh
#
#
cdb01:/etc/cmcluster/ows/owsmonitor.sh
#
#
*************************************************************************
#
***************** Monitor Script for
ows on cdb01 ******************
#
*************************************************************************
#
# This script will monitor the Oracle Web
Application Server (OWS) wrb
# processes, attempt up to two restarts of the
OWS, and exit to fail the
# package service if two restarts fail.
#
#
#
MONITOR_INTERVAL: The interval of time
in seconds this script should
# wait
between checks of the Oracle Web Application Server.
#
#
MONITOR_PROCESSES: Set MONITOR_PROCESSES
to contain the names of all
# processes
that must be executing to assume this
# application
is still up and running.
#
#
Examples:
#
MONITOR_INTERVAL=30
#
set -A MONITOR_PROCESSES wrbroker
MONITOR_INTERVAL=30
set
-A WRB_PROCESSES mnrpcnmsrv mnaddrsrv wrbvpm wrbcfg mnorbsrv wrblog wrbroker
wrbasrv wrbahsrv \
wrbfac
wrbdm
set
-A KILL_PROCESSES mnrpcnmsrv mnaddrsrv wrbvpm wrbcfg mnorbsrv wrblog wrbroker
wrbasrv wrbahsrv \
wrbfac
wrbdm wrbc oraweb
SVPATH=/home/oracle7/admin/ows/cdbp/httpd_cdb01/www/config
SVPID=`cat
$SVPATH/svwww.pid`
set
-A MONITOR_PROCESSES ${WRB_PROCESSES[@]} ${SVPID}
#ORACLE_HOME=/home/oracle7/product/7.3.4
#ORAWEB_HOME=$ORACLE_HOME/ows/3.0
#
START OF MONITOR FUNCTION
#
Monitor the ows processes by making sure that all required processes
#
are running.
while
true
do
for
i in ${MONITOR_PROCESSES[@]}
do
ps -ef | grep ${i} | grep -v grep >
/dev/null
if [[ $? != 0 ]]
then
print "\n *** Process ${i} has
Failed, Attempting ows Restart! ***" >> \
/etc/cmcluster/ows/owsmonitor.sh.log
kill -9 ${SVPID} 2>/dev/null
for q in ${KILL_PROCESSES[@]}
do
kill -9 `ps -ef|grep ${q}|grep -v
grep|awk '{print $2}'` 2>/dev/null
done
sleep 2
su - oracle7 -c
"/home/oracle7/product/7.3.4/ows/3.0/bin/owsctl start wrb" >
/dev/null \
2>>/etc/cmcluster/ows/owsmonitor.sh.log
wait
sleep 60
su - oracle7 -c
"/home/oracle7/product/7.3.4/ows/3.0/bin/owsctl start www" >
/dev/null \
2>>/etc/cmcluster/ows/owsmonitor.sh.log
wait
sleep 5
SVPID=`cat $SVPATH/svwww.pid`
set -A MONITOR_PROCESSES
${WRB_PROCESSES[@]} ${SVPID}
for j in ${MONITOR_PROCESSES[@]}
do
ps -ef | grep ${j} | grep -v grep
> /dev/null
if [[ $? != 0 ]]
then
print "\n *** Process ${j}
has Failed after 1st ows Restart. ***" >> \
/etc/cmcluster/ows/owsmonitor.sh.log
print "\n *** Attempting
2nd ows Restart! ***" > /etc/cmcluster/ows/owsmonitor.sh.log
kill -9 ${SVPID} 2>/dev/null
for r in ${KILL_PROCESSES[@]}
do
kill -9 `ps -ef|grep
${r}|grep -v grep|awk '{print $2}'` 2>/dev/null
done
sleep 2
su - oracle7 -c
"/home/oracle7/product/7.3.4/ows/3.0/bin/owsctl start wrb" > \
/dev/null
2>>/etc/cmcluster/ows/owsmonitor.sh.log
wait
sleep 60
su - oracle7 -c
"/home/oracle7/product/7.3.4/ows/3.0/bin/owsctl start www" > \
/dev/null
2>>/etc/cmcluster/ows/owsmonitor.sh.log
wait
sleep 5
SVPID=`cat $SVPATH/svwww.pid`
set -A MONITOR_PROCESSES
${WRB_PROCESSES[@]} ${SVPID}
for k in
${MONITOR_PROCESSES[@]}
do
ps -ef | grep ${k} | grep -v grep > /dev/null
if [[ $? != 0 ]]
then
print "\n\n"
>> /etc/cmcluster/ows/owsmonitor.sh.log
/sbin/date >>
/etc/cmcluster/ows/owsmonitor.sh.log
print "\n ***
Process ${k} has Failed, 2 ows Restarts have Failed. ABORTING \
ows
service! ***" >> /etc/cmcluster/ows/owsmonitor.sh.log
exit
fi
done
fi
done
fi
done
sleep ${MONITOR_INTERVAL}
done