General
cancel
Showing results for 
Search instead for 
Did you mean: 

monitoring script for oracle instance

SOLVED
Go to solution
steven chang_1
Regular Advisor

monitoring script for oracle instance

#!/usr/bin/ksh
OPER="user mail box"
LSNR=`su - oracle -c "lsnrctl status " |grep successfully|awk '{print $4}'`
if [[ "$LSNR" != "successfully" ]];then
echo "Listener is not ok at `date`" |mailx -v -s "Listener Status" $OPER
else
#TO define oracle sid
ORATAB=/var/opt/oracle/oratab
cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
# Proceed only if third field is 'Y'.
if [[ "`echo $LINE | awk -F: '{print $3}' -`" == "Y" ]] ; then
ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
if [[ "$ORACLE_SID" == '*' ]] ; then
ORACLE_SID=""
fi
ORACLE_HOME=`echo $LINE |awk -F: '{print $2}' -`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin
export PATH
Stat=`echo "exit"|su oracle -c "sqlplus user/passwd@$ORACLE_SID"|grep Disconnected|awk '{print $2}'`
if [[ "$Stat" != "Disconnected" ]];then
echo "Database $ORACLE_SID not on" |mailx -v -s "Database Status" $OPER
fi
fi
;;
esac
done
fi
steven
3 REPLIES
steven chang_1
Regular Advisor

Re: monitoring script for oracle instance

attach file
steven
Joseph Loo
Honored Contributor
Solution

Re: monitoring script for oracle instance

may i know exactly what problem (any error message) you are facing?
what you do not see does not mean you should not believe
Jean-Louis Phelix
Honored Contributor

Re: monitoring script for oracle instance

Hi,

A forum is a place to exchange ideas. I can imagine that Steven is only giving us 2 scripts that he finds useful. Thanks to him. Some times ago there were posts collecting this kind of sysadmin scripts.

Regards.
It works for me (© Bill McNAMARA ...)