OBJECTIVE:
Write a script is to monitor goldengate processes like extract and replicat, And in case extract or replicat is down, it will send alert to the respective email ids.
SOLUTION:
Below is the shell script.(gg_alert.sh)
cat gg_alert.sh
#!/bin/bash EMAIL_LIST="support@dbaclass.com" OIFS=$IFS IFS=" " NIFS=$IFS function status { OUTPUT=`$GG_HOME/ggsci << EOF info all exit EOF` } function alert { for line in $OUTPUT do if [[ $(echo "${line}"|egrep 'STOP|ABEND' >/dev/null;echo $?) = 0 ]] then GNAME=$(echo "${line}" | awk -F" " '{print $3}') GSTAT=$(echo "${line}" | awk -F" " '{print $2}') GTYPE=$(echo "${line}" | awk -F" " '{print $1}') case $GTYPE in "MANAGER") cat $GG_HOME/dirrpt/MGR.rpt | mailx -s "${HOSTNAME} - GoldenGate ${GTYPE} ${GSTAT}" $NOTIFY ;; "EXTRACT"|"REPLICAT") cat $GG_HOME/dirrpt/"${GNAME}".rpt |mailx -s "${HOSTNAME} - GoldenGate ${GTYPE} ${GNAME} ${GSTAT}" $EMAIL_LIST ;; esac fi done } export GG_HOME=/goldengate/install/software/gghome_1 export ORACLE_HOME=/oracle/app/oracle/product/12.1.0/db_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib status alert
Now configure the script in crontab with 30 min interval.
00,30 * * * * /home/goldengate/gg_alert.sh > /home/goldengate/gg_alerts.log
$GG_HOME/ggsci – this is not going on ggsci prompt
You need to set GG_HOME properly.
else go to GG_HOME path and then do ./ggsci
NOTIFY not declared
Hi Sir,
You have written a very good script but feels like few things are pending, like NOTIFY not declared ,
Can you please share me the Updated and complete script.
We will fix it Swastik
thanks you for the script, but last call also should be alert instead of report