OCI GoldenGate Service monitoring Shell Script

Facebook
Twitter
LinkedIn
Email

OCI GoldenGate Service monitoring Shell Script : Automated Monitoring & Alerts

Oracle Cloud Infrastructure (OCI) GoldenGate Service is a powerful tool for real-time data replication and management. However, to ensure that the service is running smoothly, it’s essential to have a robust monitoring mechanism in place. One such mechanism is the use of OCI GoldenGate Service Monitoring Shell Script to monitor the service’s performance. By using a shell script, you can automate the monitoring process and be alerted of any issues with the OCI GoldenGate Service.

To use this shell script for monitoring the OCI GoldenGate Service, one needs to have a basic understanding of shell scripting and the commands used to monitor the performance of the GoldenGate. The objective of the script is to monitor the status of Extract and the replicat processes status and the lag time between the source and target databases.

The ideal environment for the script is a virtual machine (VM) that has been granted access to the OCI GoldenGate Service components.

In conclusion, this shell script is a simple and effective way to monitor the performance of OCI GoldenGate Service process. By automating the process, you can ensure that the service runs smoothly and be alerted of any issues in a timely manner.

Pre-requisites

  • 1. Hardcode or Input the Extract + Replicat process Name in the script to Monitor Eg : EXT=”EXT1 EXT2″ REP=”REP1 REP2″
  • 2. Create output log directory listed in variable : OPLOG
  • 3. Make sure SMTP is configured to send out the alerts to your email from OCI VM
  • 4. Adminclient has to be installed on the VM. It can be downloaded from here…

Sample Code

				
					EXT="EXT1 EXT2"
REP="REP1 REP2"
dt=`date +\%Y-\%m-\%d-\%H-\%M-\%S`
OPLOG=/home/opc/scripts/logs
pdate=`date -I'seconds'`
mv $OPLOG/GG_EXT*.log $OPLOG/old_logs/
for p in $EXT
do

  echo
  echo ========================================================================
  echo $p
  echo ------------------------------------------------------------------------
  STATUS=0
  curl -i --insecure -X GET -u oggadmin:Password -H request-header:value https://100.100.100.1/services/v2/extracts/$p/info/status > $OPLOG/$p.out
  tail -1 $OPLOG/$p.out | jq . > $OPLOG/$p.json
  pstatus=`egrep  -o -c 'running' $OPLOG/$p.out`
  plag=`egrep -o '"lag":[0-9]+' $OPLOG/$p.out`
  plag_delay=`echo $plag | egrep -o '[0-9]+'`
  preplicat=$p
  pstatus_text=`egrep -o '"status":"[A-Za-z0-9]+"' $OPLOG/$p.out`
  echo ------------------------------------------------------------------------
  echo "$dt,$preplicat,$pstatus_text,$plag" | tee -a $OPLOG/$p.log $OPLOG/ALL_TASKS.log
  echo ------------------------------------------------------------------------
  if [ $pstatus -eq 1 ]; then
    echo "Process $p is RUNNING"
  else
    echo "Process $p is not RUNNING" | tee -a $OPLOG/GG_EXT_Status_ERR$dt.log
    ((STATUS=STATUS+1))
  fi
   if [ $STATUS -gt 0 ]
    then
       cat $OPLOG/GG_EXT_Status_ERR$dt.log | mail -s "Test GG Extract Process is down" -r "Raghav@oraclegg.com" -S replyto="Raghav@oraclegg.com" -S smtp="smtp.email.us-ashburn-1.oci.oraclecloud.com:25" -S smtp-use-starttls -S smtp-auth=plain -S smtp-auth-user='ocid1.user.oc1..aaaaaaaa5hgqdcvnkujp5slmfaqrjejztfjwaulmkyds6woy7phrabuly5ka@ocid1.tenancy.oc1..aaaaaaaaunwlbdu2zihtabcwgu2scnqezxgbkczigdi32zg5jzt26xtkpgya.iz.com' -S smtp-auth-password='yP4&I.fE_9)abcdedf)' -S ssl-verify=ignore Raghav@oraclegg.com Raghavendra@oraclegg.com
  fi
  if [ $plag_delay -gt 300 ]
   then
     cat $OPLOG/$p.json | mail -v -s "GG TEST -  Extract $rp is behind $plag_delay "  -r "Raghav@oraclegg.com" -S replyto="Raghav@oraclegg.com" -S smtp="smtp.email.us-ashburn-1.oci.oraclecloud.com:25" -S smtp-use-starttls -S smtp-auth=plain -S smtp-auth-user='ocid1.user.oc1..aaaaaaaa5hgqdcvnkujp5slmfaqrjejztfjwaulmkyds6woy7phrabuly5ka@ocid1.tenancy.oc1..aaaaaaaaunwlbdu2zihtabcwgu2scnqezxgbkczigdi32zg5jzt26xtkpgya.iz.com' -S smtp-auth-password='yP4&I.fE_9)abcdedf)' -S ssl-verify=ignore Raghav@oraclegg.com Raghavendra@oraclegg.com
  fi
  done

mv $OPLOG/GG_REP*.log $OPLOG/old_logs/
for rp in $REP
do
  echo
  echo ========================================================================
  echo $rp
  echo ------------------------------------------------------------------------
  STATUS=0
  curl -i --insecure -X GET -u oggadmin:Password -H request-header:value https://100.100.100.1/services/v2/replicats/$rp/info/status > $OPLOG/$rp.out
  tail -1 $OPLOG/$rp.out | jq . > $OPLOG/$rp.json
  pstatus=`egrep  -o -c 'running' $OPLOG/$rp.out`
  plag=`egrep -o '"lag":[0-9]+' $OPLOG/$rp.out`
  plag_delay=`echo $plag | egrep -o '[0-9]+'`
  preplicat=$rp
  pstatus_text=`egrep -o '"status":"[A-Za-z0-9]+"' $OPLOG/$rp.out`
  echo ------------------------------------------------------------------------
  echo "$dt,$preplicat,$pstatus_text,$plag" | tee -a $OPLOG/$rp.log $OPLOG/ALL_TASKS.log
  echo ------------------------------------------------------------------------

  if [ $pstatus -eq 1 ]; then
    echo "Process $rp is RUNNING"
  else
    echo "Process $rp is not RUNNING" | tee -a $OPLOG/GG_REP_Status_ERR$dt.log
    ((STATUS=STATUS+1))
  fi
  if [ $STATUS -gt 0 ]
    then
        echo " Replicat $rp is not running on Test Environment" | mail -v -s "Test GG Replicat Process is down" -r "Raghav@oraclegg.com" -S replyto="Raghav@oraclegg.com" -S smtp="smtp.email.us-ashburn-1.oci.oraclecloud.com:25" -S smtp-use-starttls -S smtp-auth=plain -S smtp-auth-user='ocid1.user.oc1..aaaaaaaa5hgqdcvnkujp5slmfaqrjejztfjwaulmkyds6woy7phrabuly5ka@ocid1.tenancy.oc1..aaaaaaaaunwlbdu2zihtabcwgu2scnqezxgbkczigdi32zg5jzt26xtkpgya.iz.com' -S smtp-auth-password='yP4&I.fE_9)F7l)H0rX)' -S ssl-verify=ignore Raghav@oraclegg.com Raghavendra@oraclegg.com
  fi
  if [ $plag_delay -gt 300 ]
   then
     cat $OPLOG/$rp.json | mail -v -s "GG TEST -  Replicat $rp is behind $plag_delay "  -r "Raghav@oraclegg.com" -S replyto="Raghav@oraclegg.com" -S smtp="smtp.email.us-ashburn-1.oci.oraclecloud.com:25" -S smtp-use-starttls -S smtp-auth=plain -S smtp-auth-user='ocid1.user.oc1..aaaaaaaa5hgqdcvnkujp5slmfaqrjejztfjwaulmkyds6woy7phrabuly5ka@ocid1.tenancy.oc1..aaaaaaaaunwlbdu2zihtabcwgu2scnqezxgbkczigdi32zg5jzt26xtkpgya.iz.com' -S smtp-auth-password='yP4&I.fE_9)F7l)H0rX)' -S ssl-verify=ignore Raghav@oraclegg.com Raghavendra@oraclegg.com
  fi
 done

				
			
NOTE : You can also monitor the OCI GoldenGate process using obeservability and management method. You can find more information here.

In conclusion, a shell script is a simple and effective way to monitor the performance of your OCI GoldenGate Service. By automating the process, you can ensure that the service runs smoothly and be alerted of any issues in a timely manner.

Hope you found this article useful.
Disclaimer: The views expressed on this document are my own and do not necessarily reflect the views of Oracle..