MAILLIST="test@gmail.com"
if [ "$1" ]
then DBNAME=$1
else echo "\nOracle SID has not been entered."
exit 16
fi
sqlplus -silent <<> /tmp/$$.1 &
a/a@${DBNAME}
exit;
EOF
Pid=$!
sleep 2
if [[ `ps -ef grep -w "$Pid"` != "" ]] ; then
kill -9 $Pid
fi
egrep 'ORA-121ORA-01034' /tmp/$$.1 > /dev/null
if [[ $? = 0 ]]
then
echo " ${DBNAME} is not accessible - db is down"
mailx -s " ${DBNAME} is not accessible - db is down" ${MAILLIST} < /tmp/$$.1 else grep -e 'ORA-01017' -e 'ORA-01033' /tmp/$$.1 > /dev/null
if [[ $? = 0 ]]
then
echo " ${DBNAME} is accessible - db is up and running"
exit 16
else
echo " ${DBNAME} is not accessible - db is down"
mailx -s " ${DBNAME} is not accessible - db is down" ${MAILLIST} < /tmp/$$.1 fi fi rm /tmp/$$.1 exit
Friday, May 8, 2009
Database Monitor Script
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment