==============================
General
==============================
Code example.
Reading from file
sed+awk+egrep
If result is wrong, report error.
For predefined time, skip check.
cat $GG_STATUS_FILE | while read;do printf '%s\n' ;egrep -i '(EXTRACT|REPLICAT)'|tr ":" " " | tr -s '[:space:]' | awk -v lc=$LC '{if
($2!="RUNNING" || $4>=01 || $5>=lc || ( "$7" ~ /^[0-9]+$/ && $7>=01 ) || $8>=lc ) {print " Problem with the "$1" "$3" : status is
"$2" with lag of " $4"HR:"$5"MI and checkpoint of "$7"HR:"$8"MI " >> "/tmp/gg_test.out"} }' ; done
if [ -s "/tmp/gg_test.out" ]; then
GG_STATUS=1
fi
# If no GoldenGate errors found
if [ ${GG_STATUS} -eq 0 ]; then
echo "`date +"%d-%m-%Y %H:%M:%S"` GOLDENGATE STATUS OK. GoldenGate seems to be functioning properly" | tee -a ${LOG_FILE}
else
#--------------------------------------------
#Skip restart from crontab
#46 06 * * * /software/oracle/oracle/scripts/gg_restart_all_extracts.sh
#--------------------------------------------
SKIP_HOUR=6
SKIP_MIN_START=45
SKIP_MIN_END=59
RUN_HOUR=`date | sed s/:/' '/g | awk '{print $4}'`
RUN_MIN=`date | sed s/:/' '/g | awk '{print $5}'`
SKIP_CHECK=0
if [ $SKIP_HOUR -eq $RUN_HOUR ]; then
if [ $SKIP_MIN_START -lt $RUN_MIN ] && [ $RUN_MIN -lt $SKIP_MIN_END ]; then
SKIP_CHECK=1
else
SKIP_CHECK=0
fi
fi
if [ $SKIP_CHECK -eq 1 ]; then
echo "`date +"%d-%m-%Y %H:%M:%S"` GOLDENGATE Restart Time, Skip GOLDENGATE STATUS Check." | tee -a ${LOG_FILE}
else
echo "`date +"%d-%m-%Y %H:%M:%S"` GOLDENGATE STATUS MAJOR. Problem with GoldenGate Process(es)" | tee -a ${LOG_FILE}
cat /tmp/gg_test.out | tee -a ${LOG_FILE}
cat $GG_STATUS_FILE | tee -a ${LOG_FILE}
fi
#--------------------------------------------
# echo "`date +"%d-%m-%Y %H:%M:%S"` GOLDENGATE STATUS MAJOR. Problem with GoldenGate Process(es)" | tee -a ${LOG_FILE}
# cat /tmp/gg_test.out | tee -a ${LOG_FILE}
# cat $GG_STATUS_FILE | tee -a ${LOG_FILE}
#--------------------------------------------
fi
\rm -f /tmp/gg_test.out
\rm -f /tmp/check_goldengate.*
\rm -f /tmp/gg_status.*
No comments:
Post a Comment