Overview
The script is relatively simple consisting of:
- Get data from the GGSCI console
- Send mail using mailx(mail), if needed
Script
#!/bin/bash EMAIL_LIST="email1,email2,email3" OIFS=$IFS IFS=" " NIFS=$IFS function status { OUTPUT=`$GG_HOME/ggsci << EOF info all exit EOF` } function alert { for line in $OUTPUT do GNAME=$(echo "${line}" | awk -F" " '{print $3}') GSTAT=$(echo "${line}" | awk -F" " '{print $2}') GTYPE=$(echo "${line}" | awk -F" " '{print $1}') if [[ $(echo "${line}"|egrep 'STOP|ABEND' >/dev/null;echo $?) = 0 ]] then case $GTYPE in "MANAGER") echo "" | mailx -s "${HOSTNAME} - GoldenGate ${GTYPE} ${GSTAT}" $NOTIFY $EMAIL_LIST -- smtp="private_smprt_server_if_such_exists" -f "[email protected]" ;; "EXTRACT"|"REPLICAT") echo "" | mailx -s "${HOSTNAME} - GoldenGate ${GTYPE} ${GNAME} ${GSTAT}" $EMAIL_LIST -- smtp="private_smprt_server_if_such_exists" -f "[email protected]" ;; esac fi done } export GG_HOME=GG_HOME_PATH; export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib export ORACLE_SID=SID_NAME status alert
Crontab
We can schedule this script to run every 1 hour to see how it goes :)
0 * * * * /bin/sh /home/oracle/run_goldenGate_check.sh > /dev/null
P.S. This script will produce a message ONLY when something is STOPPED or AB