monitor_dg_當機或日誌沒正常應用就報警

lusklusklusk發表於2016-12-31
#!/bin/bash
source ~/.bash_profile 
#check time(M)
 


$ORACLE_HOME/bin/sqlplus -silent "/ as sysdba" </tmp/dg_switch_check139.log
set pagesize 0 feedback off verify off heading off echo off
select THREAD#,SEQUENCE#,APPLIED from v\$archived_log where to_date(completion_time)=to_date(sysdate);
exit;
XFF


$ORACLE_HOME/bin/sqlplus -silent "/ as sysdba" </tmp/check_dg139.log
set pagesize 0 feedback off verify off heading off echo off 
select ceil((sysdate-next_time)*24*60) "M" 
from v\$archived_log  
where applied='YES' AND SEQUENCE#=(SELECT MAX(SEQUENCE#)  FROM V\$ARCHIVED_LOG WHERE applied='YES');
exit;
XFF


GET_M=`cat /tmp/check_dg139.log`
COUNT=`cat /tmp/dg_switch_check139.log |grep "NO" |wc -l`




cat /tmp/dg_switch_check139.log |grep "ORACLE not available">/tmp/dg_error.log
if [ $? -eq 0 ];
then
echo '10.98.0.29 ORACLE not available' | /usr/local/bin/mailx -s "10.98.0.29 ORACLE not available" XX@YY.com
fi


#if not standby after 120min and more than 5 archivelog not standby
if [ 120 -lt ${GET_M} -a ${COUNT} -gt 5 ]; 
then    
echo 'error dg 10.98.0.29' | /usr/local/bin/mailx -s "PROD SDB $ORACLE_SID 10.98.0.29 ERROR" XX9@YY.com
fi




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

相關文章