Re: Dataguard Monitoring

  • From: Andrew Kerber <andrew.kerber@xxxxxxxxx>
  • To: TESTAJ3@xxxxxxxxxxxxxx
  • Date: Tue, 5 Oct 2010 08:24:21 -0500

I think it is pretty much like 10g.  Here is my 10g script:

#!/bin/bash
set -x
# First, we must set the environment . . . .
export PATH=$PATH:/usr/local/bin
export ORACLE_SID=$1
export ORAENV_ASK=NO
. oraenv
export TNS_ADMIN=$ORACLE_HOME/network/admin
#ORACLE_HOME=`cat /etc/oratab|grep $ORACLE_SID:|cut -f2 -d':'`
#export ORACLE_HOME
export REMDEST=$1"DR"
#export REMDEST
getlog() {
$ORACLE_HOME/bin/sqlplus -s $connstring << !
set echo off feed off head off time off timing off
$stmt
exit
!
}

connstring="sys/manager@$REMDEST as sysdba"

# GET LATEST SEQUENCE FOR THREAD 1 ON STANDBY #
stmt="select max(sequence#) from v\$archived_log where thread# = 1 and
applied = 'YES' and resetlogs_change#=(select max(resetlogs_change#) from
v\$archived_log);"
thread1_stby=`getlog | tail -1 | while read var; do echo $var; done`

# GET LATEST SEQUENCE FOR THREAD 2 ON STANDBY - uncomment for RAC, add 1 for
each rac node#
# stmt="select max(sequence#) from v\$archived_log where thread# = 2 and
applied = 'YES' and resetlogs_change#=(select max(resetlogs_change#) from
v\$archived_log)"
# thread2_stby=`getlog | tail -1 | while read var; do echo $var; done`

connstring="sys/manager as sysdba"

# GET LATEST SEQUENCE FOR THREAD 1 ON PROD #
stmt="select max(sequence#) from v\$archived_log where thread# = 1 and
resetlogs_change#=(select max(resetlogs_change#) from v\$archived_log);"
thread1_prod=`getlog | tail -1 | while read var; do echo $var; done`

# GET LATEST SEQUENCE FOR THREAD 2 ON PROD #i - uncomment for RAC, add 1 for
each rac node#
# stmt="select max(sequence#) from v\$archived_log where thread# = 2 and
resetlogs_change#=(select max(resetlogs_change#) from v\$archived_log);"
# thread2_prod=`getlog | tail -1 | while read var; do echo $var; done`

thread1_diff=`expr $thread1_prod - $thread1_stby`
thread2_diff=0
# uncomment next line for rac
# thread2_diff=`expr $thread2_prod - $thread2_stby`

# if [ "$thread1_diff" -gt 5 ] || [ "$thread2_diff" -gt 5 ]; then
if [ "$thread1_diff" -gt 5 ]; then
  MSG=`echo -e "$1 archive logs are out of sync by $thread1_diff logs\n"`
  echo "$MSG" | mail -s "** $1"DR" STANDBY OUT OF SYNC **" me@xxxxxxxxxxx
  echo `date` >> /u01/app/oracle/bin/dg_monitor_history.log
  echo $MSG >> /u01/app/oracle/bin/dg_monitor_history.log
else
  MSG=`echo -e "Standby for $1 archive logs are in sync\n"`
  echo "$MSG" | mail -s "** $1"DR" Standby in Sync **" me@xxxxxxxxxxx
fi

#if [ "$thread1_diff" -gt 1 ] || [ "$thread2_diff" -gt 1 ]; then
if [ "$thread1_diff" -gt 1 ]; then
  MSG=`echo -e "$1 archive logs are out of sync by $thread1_diff logs\n"`
  echo `date` >> /u01/app/oracle/bin/dg_monitor_history.log
  echo $MSG >> /u01/app/oracle/bin/dg_monitor_history.log
fi


On Tue, Oct 5, 2010 at 8:15 AM, <TESTAJ3@xxxxxxxxxxxxxx> wrote:

>
> Howard, what are you trying to accomplish, where archive logs are not being
> shipped?
>
> joe
> _______________________________________
> Joe Testa, Oracle Certified Professional
> Senior Engineering & Administration Lead
> (Work) 614-677-1668
> (Cell) 614-312-6715
>
>
>
>
>
>  From: Howard Latham <howard.latham@xxxxxxxxx> To: ORACLE-L <
> oracle-l@xxxxxxxxxxxxx> Date: 10/05/2010 09:10 AM Subject: Dataguard
> Monitoring Sent by: oracle-l-bounce@xxxxxxxxxxxxx
> ------------------------------
>
>
>
> Anyone point me in the right direction for an 11g Linux Script to
> monitor Dataguard lag?
>
> I have googled and looked on oracle Support.
>
> --
> Howard A. Latham
>
> Sent from my Nokia N97
>
>
>


-- 
Andrew W. Kerber

'If at first you dont succeed, dont take up skydiving.'

Other related posts: