ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [Shell] monitor oracle database listener & instance status

[Shell] monitor oracle database listener & instance status

原创 Linux操作系统 作者:tolilong 时间:2016-03-27 21:47:20 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-2064890/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208677