Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: Script to be notified by email if db is down
> We dont run Enterprise Manager (Intelligent Agents) at our site, so we
> want to have a script that runs periodically to check if the database
> is up and if not, then it should e-mail me.
>
Attached. You *may* need to alter it a bit.Checks for all DBs whose oratab
entry ends w/ "Y" & loooks for Net8 listener up also...
#!/bin/sh # # check_ora_up.sh: check to see if oracle DBs & Net8 listener are up... #
exit 1
fi
# Look for DB names in oratab
#
cat ${ORATAB} | while read line
do
OSID=`echo ${line} | grep '^[^ #]' | awk -F: '{ print $1 }'`
YN=`echo ${line} | grep '[YN]$' | awk -F: '{ print $3 }'`
if [ -n "${OSID}" -a "${YN}" = "Y" ]; then
DB_UP=`ps -ef | grep smon_${OSID} | grep -v grep`
if [ $? -ne 0 ]
then
echo "${OSID} NOT up!" >>${MSGS}
fi
fi
done
#
# Check Net8 listener too...
NET8_UP=`ps -ef | grep LISTENER | grep -v grep`
if [ $? -ne 0 ]
then
echo "Net8 NOT up!" >>${MSGS}
fi
#
if [ -s "${MSGS}" ]; then
MSG_FILE="${MSGS}"
export MSG_FILE
subj="##ERROR## on `hostname`"
mailx -s "${subj}" dba_at_foo.com < "${MSG_FILE}"
rm ${MSGS}
fi
exit 0
This message was cancelled from within Mozilla...not Received on Fri Dec 28 2001 - 10:04:07 CST