7.monitor oracle database listener & instance status

tolilong發表於2016-03-27
monitor oracle database listener & instance status


[mon@oracle source]$ crontab -l
* * * * * /home/mon/source/mon_db >> /home/mon/log/mon_db.log


[mon@oracle source]$ more mon_db 
#!/bin/bash
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1
export ORACLE_SID=yangxu
datetime=`date +"%Y/%m/%d %H:%M:%S"`
hostname=`hostname`


lsnrstat=`ps -ef | grep -i tnslsnr | grep -v grep | wc -l`
if [ $lsnrstat -eq 0 ];then
   echo "$datetime starting listener"
   $ORACLE_HOME/bin/lsnrctl start
   echo "$datetime start listener completed"
   echo "$datetime $hostname started listener" | mutt -s "$datetime $hostname started listener" tolilong@163.com
else
   echo "$datetime listener is already runing"
fi


dbstat=`ps -ef | grep -e ora_smon_$ORACLE_SID -e ora_pmon_$ORACLE_SID -e ora_lgwr_$ORACLE_SID | grep -v grep | wc -l`
if [ $dbstat -eq 0 ];then
   echo "$datetime starting instance $ORACLE_SID"
   $ORACLE_HOME/bin/sqlplus / nolog << EOF
   conn / as sysdba;
   startup;
EOF
   echo "$datetime start instance complete"
   echo "$datetime $hostname started database" | mutt -s "$datetime $hostname started database" tolilong@163.com
else
   echo "$datetime $ORACLE_SID is already runing"
fi

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2064892/,如需轉載,請註明出處,否則將追究法律責任。

相關文章