Hi
There are two script i have created
1) Linux
2) solaris and other platform.
First one i just wrote with modified logic and less processing using files.
Second script is specially for other Unix OS ,due to tac command does not work there.
Please inform me on jonyjt@gmail.com , if you find problem regarding it.
1 script
There are two script i have created
1) Linux
2) solaris and other platform.
First one i just wrote with modified logic and less processing using files.
Second script is specially for other Unix OS ,due to tac command does not work there.
Please inform me on jonyjt@gmail.com , if you find problem regarding it.
1 script
#!/bin/ksh ############################### # monitor gg process ############################### export ORACLE_HOME=/u00/app/oracle/product/10.2.0/DB export GG_HOME=/ORAGG/product/11.2.1/gghome10 export PATH=$GG_HOME:$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$GG_HOME:$LD_LIBRARY_PATH export LOGFILE=/tmp/testoutput.log export DT=`date +%d/%m/%Y\ %k:%M:%S` export BOX=`hostname -s` export COLUMNS=130 #echo "############################################################" #echo `date +%d/%m/%Y\ %k:%M:%S` ################################ echo $DT rm -rf /tmp/testoutput.log ############################### #check if process has abended. ${GG_HOME}/ggsci <<!| while read;do printf '%s\n' ;egrep -i '(EXTRACT|REPLICAT)'|tr ":" " " | tr -s '[:space:]' | awk '{if ($2=="ABENDED" || $5>=05 || $7 >=05 ) {print $1" "$3" is "$2" with lag of " $4"HR:"$5"MI and checkpoint of "$7"HR:"$8"MI" "\n">> "/tmp/testoutput.log"} else {print "No lag for"$3 > "/tmp/nolag.log"} }' ; done info all exit ! ############################### if [ -f ${LOGFILE} ]; then x=$( grep -c ABENDED /tmp/testoutput.log ) y=$( grep -c RUNNING /tmp/testoutput.log ) if [ $x -gt 0 ]; then echo "please refer below logs" >> $LOGFILE echo "##################################################################" >> $LOGFILE tac ${GG_HOME}/ggserr.log | grep -m 1 -A 2 -B 2 ABEND >> $LOGFILE mailx -s "Alert GG Abended on $BOX" fistname.lastname@company.com < $LOGFILE fi if [ $y -gt 0 ]; then ##echo "process running " mailx -s "Lag Found on $BOX" fistname.lastname@company.com < $LOGFILE fi else echo "NO LAG FOUND" fi ###################################2 script It was created on Solaris platform for ksh shell. ggs_lag.ksh is main script which calls ggs.ksh , you can also merge both into one script also.
#!/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 ######################This is ggs.ksh which calls by above ggs_lag.ksh
#!/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