below script can be used to find archivelog gap between primary and standby.
if shipping gap or apply gap is greater than or equal to 5 you will get mail(you can change the number if you want in if condition).
#!/bin/bash
export ORACLE_SID=ORCL
export ORACLE_HOME=`egrep -i ":Y|:N" /etc/oratab |grep $ORACLE_SID| cut -d":" -f2 | grep -v "\#" | grep -v "\*"`
export PATH=$ORACLE_HOME/bin:$PATH
DG_GAP_CHECK=`sqlplus -s "/ as sysdba" <<EOF
set pagesize 200
set linesize 121
set heading off feedback off verify off
select(select name from v\\$database) name,
(select max(sequence#) from v\\$archived_log where dest_id=1
) current_primary_seq,
(select max(sequence#)
from v\\$archived_log
where trunc(next_time)> sysdate-1
and dest_id=2
) max_stby,
(select nvl(
(select max(sequence#)-min(sequence#)
from v\\$archived_log
where trunc(next_time)> sysdate-1
and dest_id=2
and applied='NO'
),0)
from dual
) "To be Applied",
((select max(sequence#) from v\\$archived_log where dest_id=1)-
(select max(sequence#) from v\\$archived_log where dest_id=2)) "To be shipped"
from dual;
exit;
EOF`
TO_BE_SHIPPED="`echo $DG_GAP_CHECK|awk '{ print $5}'`"
TO_BE_APPLIED="`echo $DG_GAP_CHECK|awk '{ print $4}'`"
if [ $TO_BE_SHIPPED -ge 5 ] || [ $TO_BE_APPLIED -ge 5 ]
then
echo $DG_GAP_CHECK | mail -r "sender@company.com" -s "`hostname`:Dataguard is out of sync" "receiver@company.com receiver@company.com"
fi
if shipping gap or apply gap is greater than or equal to 5 you will get mail(you can change the number if you want in if condition).
#!/bin/bash
export ORACLE_SID=ORCL
export ORACLE_HOME=`egrep -i ":Y|:N" /etc/oratab |grep $ORACLE_SID| cut -d":" -f2 | grep -v "\#" | grep -v "\*"`
export PATH=$ORACLE_HOME/bin:$PATH
DG_GAP_CHECK=`sqlplus -s "/ as sysdba" <<EOF
set pagesize 200
set linesize 121
set heading off feedback off verify off
select(select name from v\\$database) name,
(select max(sequence#) from v\\$archived_log where dest_id=1
) current_primary_seq,
(select max(sequence#)
from v\\$archived_log
where trunc(next_time)> sysdate-1
and dest_id=2
) max_stby,
(select nvl(
(select max(sequence#)-min(sequence#)
from v\\$archived_log
where trunc(next_time)> sysdate-1
and dest_id=2
and applied='NO'
),0)
from dual
) "To be Applied",
((select max(sequence#) from v\\$archived_log where dest_id=1)-
(select max(sequence#) from v\\$archived_log where dest_id=2)) "To be shipped"
from dual;
exit;
EOF`
TO_BE_SHIPPED="`echo $DG_GAP_CHECK|awk '{ print $5}'`"
TO_BE_APPLIED="`echo $DG_GAP_CHECK|awk '{ print $4}'`"
if [ $TO_BE_SHIPPED -ge 5 ] || [ $TO_BE_APPLIED -ge 5 ]
then
echo $DG_GAP_CHECK | mail -r "sender@company.com" -s "`hostname`:Dataguard is out of sync" "receiver@company.com receiver@company.com"
fi
No comments:
Post a Comment