Search Blog Post

Monday, May 20, 2013

Shell script for checking instance availability

db_sid=""
ora_home=''"
envr="Prod"
mailto="tyagi.ankur07@gmail.com"
db_st=`ps -ef | grep smon | grep $db_sid | awk '{print $8}'`
db_sid_pro="ora_smon_$db_sid"

case "$db_st" in
"$db_sid_pro")
tag="true"
msg="$db_sid diatabase instance is running"
echo "$db_sid_pro database process is running"
;;
*)
if [ -e $ora_home/dbs/spfile$db_sid.ora ];then
msg="database is down"
echo "database is down"
tag="false"
else
tag="false"
msg="Incorrect database SID - $db_sid. Please provide the correct database SID"
echo "Incorrect database SID - $db_sid. Please provide the correct database SID"
fi
;;
esac


if [ $tag = "false" ]; then
echo "$msg " | mail -s "$envr database status - $db_sid " $mailto
fi

No comments:

Post a Comment