3 Replies Latest reply: Apr 16, 2013 9:50 AM by GKris RSS

    GoldenGate - Lag Monitor

    808649
      Experts,

      How to monitor the Lag time while replicating DB using Goldengate ?
      Goldengate Director seems to costly and we cant afford that, Is there anyway to achive this using scripts ?

      -- Riaz
        • 1. Re: GoldenGate - Lag Monitor
          User152973
          Hi Riaz,

          You can try and modify these scripts to monitor lag.
          I found it online and tested at my work and it worked. You may give a try.

          #!/bin/ksh
          ############################################
          # Name: ggs_lag.ksh #
          # PURPOSE: TO MONITOR LAG OF GOLDEN GATE #
          # NOTE: THIS SCRIPT CALLS ggs.ksh #
          # THIS SCRIPT NOTIFY IF LAG IS MORE THEN 30 MIN #
          # ONLY FOR FOR EXT AND PMP PROCESS GROUP #
          ###########################################
          export GGATE=/opt/oracle/u01/app/oracle/ggs
          alias gate='clear;cd $GGATE;./ggsci'
          export PATH=/opt/oracle/u01/app/oracle/ggs:$PATH
          export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/opt/oracle/u01/app/oracle/ggs
          LOGDIR=/export/home/oracle/dba_scripts/ggs/logs
          EMAILFile=$LOGDIR/ggs_email.log
          BOX=$(uname -a | awk '{print $2}')


          ##########################################################################
          # RUNNING SCRIPT TO GET GOLDEN GATE INFORMATION #
          ##########################################################################


          /export/home/oracle/dba_scripts/ggs/ggs.ksh > $LOGDIR/ggs_1.log


          #to check when script was running


          echo "script ggsksh completed from ggs_lag at `date`" >> /tmp/ggs_check.log


          ##################################################################################
          ## FORMATING INFORMATION: change cut -d":" -f 1,4 TO cut -d":" -f 1,2 ##
          ## to getinformation about lag instead of checkpoint ##
          ## this command grep only EXT_ and PMP_ if you need more pattern ##
          ## if you need more pattern to be greped please add to '(EXT_|PMP_|pattern)' ##
          ##################################################################################




          cat $LOGDIR/ggs_1.log|egrep -i '(EXT_|PMP_)'|cut -d":" -f 1,2,4| tr ":" " "|tr -s '[:space:]'|cut -d" " -f1,2,3,4,5,6 > $LOGDIR/ggs_2.log


          # uncomment below command if you want to get lag and checkpoint both information #


          #cat $LOGDIR/ggs_1.log|egrep -i '(EXT_|PMP_|DART)'|cut -d":" -f 1,2,4| tr ":" " "|tr -s '[:space:]'|cut -d" " -f1,2,3,4,5,6 > $LOGDIR/ggs_2.log


          # uncomment below command if you want to get lag information about running process #


          #cat $LOGDIR/ggs_1.log|grep RUNNING|cut -d":" -f 1,2,4| tr ":" " "|tr -s '[:space:]'|cut -d" " -f1,2,3,4,5,6 >
          $LOGDIR/ggs_2.log


          ##########################################################################
          ## CHECKING FOR LAG MORE THEN 30 MIN FOR ABENDED PROCESS ##
          ##########################################################################


          ##########################################################################
          ## CHECKING FOR LAG MORE THEN 30 MIN FOR ABENDED PROCESS ##
          ##########################################################################




          awk '{if ( $4 > 00 || $5 >=30 ) {print $1 " " $3 " HAS LAG of " $4" hour " $5 " min -- at -- " d "\n"} else {print "NO LAG FOR " $3 " " d >> "/tmp/ggs_lag_fine.log" }}' d="$(date)" $LOGDIR/ggs_2.log > $LOGDIR/ggs_email.log


          # uncomment below command if you want to get lag and checkpoint both information #


          #awk '{if ($4 >=30 || $5>=30 ) {print $1 " " $3 " has lag of "$4" min with checkpoint of "$5" min -- at -- " d "\n"} else {print "NO LAG FOR " $3 " "d > "/tmp/ggs_lag_fine.log" }}' d="$(date)" $LOGDIR/ggs_2.log > $LOGDIR/ggs_email.log


          ##########################################################
          ## SENDING EMAIL IF ERRORS ARE IN LOGFILE ###
          ##########################################################


          if [ -s $EMAILFile ]; then
          #echo "ERRORS FOUND"
          mailx -s "GG LAG FOUND ON: $BOX" your.email@gmail.com team.email@gmail.com < $EMAILFile else cat /dev/null > $EMAILFile
          #echo "ERRORS NOT FOUND"
          fi


          ################# SCRIPT END ######################










          #!/bin/ksh
          #########################################
          #Name: ggs.ksh #
          #THIS SCRIPT WILL CALLED BY ggs_lag.ksh #
          #########################################
          #alias gate='clear;cd $GGATE;./ggsci'
          echo "ggsksh started `date`" >> /tmp/ggs_check.log
          export GGATE=/opt/oracle/u01/app/oracle/ggs
          alias gate='clear;cd $GGATE;ggsci'
          export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/opt/oracle/u01/app/oracle/ggs
          export PATH=/opt/oracle/u01/app/oracle/ggs:$PATH
          #cd $GGATE
          /opt/oracle/u01/app/oracle/ggs/ggsci <<>
          info all
          exit
          EOF
          echo "ggsksh completed at `date` " >> /tmp/ggs_check.log


          Thanks.
          • 2. Re: GoldenGate - Lag Monitor
            808649
            Thanks Ravi.
            Let me too try it.
            • 3. Re: GoldenGate - Lag Monitor
              GKris
              script is working but not sending the mail.

              thanks
              GKris