monitor_dg_例行巡检,显示正常或不正常

#使用crontab定时调用,查看邮件显示结果

#!/bin/bash

source ~/.bash_profile 


$ORACLE_HOME/bin/sqlplus -silent "/ as sysdba"
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


$ORACLE_HOME/bin/sqlplus -silent "/ as sysdba"
set pagesize 0 feedback off verify off heading off echo off 
select SEQUENCE#,to_char(completion_time,'yyyy-MM-dd HH24:mi:ss'),APPLIED from v\$archived_log where to_date(completion_time)=to_date(sysdate) order by SEQUENCE# desc;
exit;
XFF



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



if [ 120 -lt ${GET_M} -o ${COUNT} -gt 5 ]; 
then
cat /tmp/dg_switch_check.log | mailx -s "BAD!!! WFDG 192.168.30.174 DOWN" [email protected]    
else
cat /tmp/dg_switch_check.log | mailx -s "GOOD NEWS, WFDG 192.168.30.174 WORK" xx@yy.com
fi


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2139878/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30126024/viewspace-2139878/

你可能感兴趣的:(monitor_dg_例行巡检,显示正常或不正常)