Listing 6 /etc/ha.d/mon/mon.d/db_inst.monitor
/etc/ha.d/mon/mon.d/db2_inst.monitor
#!/bin/ksh -x
. /etc/ha.d/shellfuncs
DB2HADRDBNAME=psftcrp
#temp_log_file=/tmp/heartbeat/scriptTemp.out
temp_log_file=/source/crp_scripttemp.out
touch $temp_log_file > /dev/null 2> /dev/null
chmod a+w $temp_log_file > /dev/null 2> /dev/null
echo "`date` :: db2_inst.monitor running" >> /var/log/hb.debug
#
tempHost=$(echo $HOSTNAME)
case $tempHost in
db01.example.com)
DB2INST=db2inst1;;
db02.example.com)
DB2INST=db2inst1;;
esac
echo "XXXXXXXXXXXXXXXXXXXXXXX $DB2INST on $tempHost XXXXXXXXXXXXXXXXXXXXXX"
INSTUP=$(su - $DB2INST -c "db2pd -inst" |grep -i "Database Partition" \
|grep -c "Active")
if [ $INSTUP -eq 0 ]
then
echo "`date` :: db2_inst.monitor DB2 is down" >> /var/log/hb.debug
logger -i -p info -t $0 "ERROR: DB2 INSTANCE $DB2INST IS DOWN"
exit 1
else
echo "`date` :: db2_inst.monitor DB2 is up" >> /var/log/hb.debug
logger -i -p error -t $0 "INFO: DB2 INSTANCE $DB2INST IS UP "
exit 0
fi
|