{"id":4263,"date":"2025-06-16T23:00:54","date_gmt":"2025-06-16T23:00:54","guid":{"rendered":"https:\/\/w3buddy.com\/?post_type=cposts&#038;p=4263"},"modified":"2025-06-16T23:36:20","modified_gmt":"2025-06-16T23:36:20","slug":"goldengate-process-monitor","status":"publish","type":"cposts","link":"https:\/\/w3buddy.com\/blog\/notes\/shell-scripts\/goldengate-process-monitor\/","title":{"rendered":"GoldenGate Process Monitor"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Automated Monitoring of Oracle GoldenGate Processes Using Shell Script<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This shell script is part of a broader <strong>Shell Script Automation<\/strong> toolkit designed for Oracle DBAs. It automatically monitors key Oracle GoldenGate processes \u2014 including <strong>Manager<\/strong>, <strong>Extract<\/strong>, <strong>Replicat<\/strong>, and <strong>JAgent<\/strong> \u2014 and sends alerts if any of them stop or abend. With embedded configuration and optional fallback auto-detection, the script is highly portable across environments. It\u2019s ideal for <strong>proactive replication health monitoring via cron scheduling<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcc4 Shell Script: <code>gg_alert.sh<\/code><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code>#!\/bin\/bash\n\n################################################################################\n# Title   : Automated Monitoring of Oracle GoldenGate Processes Using Shell Script\n# Script  : gg_alert.sh\n# Purpose : Monitors GoldenGate processes (Manager, Extract, Replicat, JAgent)\n#           and sends alerts via email if any are STOPPED or ABENDED.\n#\n# Features:\n#   - Self-contained script (no external config)\n#   - Fallback auto-detection for GG_HOME and ORACLE_HOME\n#   - Sends email alerts with report file\n#   - Cron-friendly and easily portable across environments\n#\n# Author  : W3Buddy\n# Version : 1.0\n################################################################################\n\n### --- Configuration Section --- ###\nGG_HOME=\"\/goldengate\/install\/software\/gghome_1\"\nORACLE_HOME=\"\/oracle\/app\/oracle\/product\/12.1.0\/db_1\"\nEMAIL_LIST=\"info.w3buddy@gmail.com\"\n#####################################\n\n# --- Fallback auto-detection if not set ---\nGG_HOME=${GG_HOME:-$(dirname \"$(command -v ggsci 2&gt;\/dev\/null)\")}\nORACLE_HOME=${ORACLE_HOME:-\"\/oracle\/app\/oracle\/product\/12.1.0\/db_1\"}\nEMAIL_LIST=${EMAIL_LIST:-\"dba@example.com\"}\n\n# --- Environment Setup ---\nexport GG_HOME\nexport ORACLE_HOME\nexport LD_LIBRARY_PATH=$ORACLE_HOME\/lib\n\n# Save and set IFS\nOIFS=$IFS\nIFS=$'\\n'\n\n# --- Fetch GoldenGate process status ---\nfunction fetch_status {\n    OUTPUT=$(\"$GG_HOME\"\/ggsci &lt;&lt;EOF\ninfo all\nexit\nEOF\n)\n}\n\n# --- Send alerts for STOPPED or ABENDED processes ---\nfunction send_alerts {\n    for line in $OUTPUT; do\n        if echo \"$line\" | grep -E 'MANAGER|EXTRACT|REPLICAT|JAGENT' &gt;\/dev\/null; then\n            GTYPE=$(echo \"$line\" | awk '{print $1}')\n            GSTAT=$(echo \"$line\" | awk '{print $2}')\n            GNAME=$(echo \"$line\" | awk '{print $3}')\n            SUBJECT=\"\"\n            REPORT_FILE=\"\"\n\n            # Alert for MANAGER and JAGENT if not RUNNING\n            if &#91;&#91; \"$GTYPE\" == \"MANAGER\" || \"$GTYPE\" == \"JAGENT\" ]]; then\n                if &#91;&#91; \"$GSTAT\" != \"RUNNING\" ]]; then\n                    SUBJECT=\"${HOSTNAME} - GoldenGate ${GTYPE} ${GSTAT}\"\n                    REPORT_FILE=\"$GG_HOME\/dirrpt\/${GTYPE}.rpt\"\n                fi\n            fi\n\n            # Alert for EXTRACT or REPLICAT if STOPPED or ABENDED\n            if &#91;&#91; \"$GTYPE\" == \"EXTRACT\" || \"$GTYPE\" == \"REPLICAT\" ]]; then\n                if &#91;&#91; \"$GSTAT\" == \"STOP\" || \"$GSTAT\" == \"ABEND\" ]]; then\n                    SUBJECT=\"${HOSTNAME} - GoldenGate ${GTYPE} ${GNAME} ${GSTAT}\"\n                    REPORT_FILE=\"$GG_HOME\/dirrpt\/${GNAME}.rpt\"\n                fi\n            fi\n\n            # Send email if subject and report file exist\n            if &#91;&#91; -n \"$SUBJECT\" &amp;&amp; -f \"$REPORT_FILE\" ]]; then\n                mailx -s \"$SUBJECT\" \"$EMAIL_LIST\" &lt; \"$REPORT_FILE\"\n            fi\n        fi\n    done\n}\n\n# Run monitoring logic\nfetch_status\nsend_alerts\n\n# Restore IFS\nIFS=$OIFS<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f Setup Instructions<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code># ----------------------------------------------\n# 1. Create the script file on GoldenGate server\n# ----------------------------------------------\ncd \/home\/goldengate\n\n# Create the script file\nvi gg_alert.sh\n\n# (Paste the full gg_alert.sh script content inside and save)\n\n# ----------------------------------------------\n# 2. Make the script executable\n# ----------------------------------------------\nchmod +x gg_alert.sh\n\n# ----------------------------------------------\n# 3. Verify mailx is installed for email alerts\n# ----------------------------------------------\nwhich mailx\n\n# If not found, install it:\n# RHEL\/CentOS:\nsudo yum install mailx\n\n# Ubuntu\/Debian:\nsudo apt install mailutils\n\n# ----------------------------------------------\n# 4. Test the script manually\n# ----------------------------------------------\n.\/gg_alert.sh\n\n# Ensure it captures GoldenGate status and sends alerts if any process is down.\n\n# ----------------------------------------------\n# 5. Schedule via cron to run every 30 minutes\n# ----------------------------------------------\ncrontab -e\n\n# Add this entry:\n00,30 * * * * \/home\/goldengate\/gg_alert.sh >> \/home\/goldengate\/gg_alerts.log 2>&amp;1\n\n# ----------------------------------------------\n# 6. Confirm cron is scheduled\n# ----------------------------------------------\ncrontab -l<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This script provides a lightweight, fully automated solution for <strong>monitoring GoldenGate<\/strong> components without requiring manual checks. It ensures DBAs are notified proactively when something goes wrong \u2014 reducing replication downtime and improving operational reliability.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Automated Monitoring of Oracle GoldenGate Processes Using Shell Script This shell script is part of a broader Shell Script Automation toolkit designed for Oracle DBAs. It automatically monitors key Oracle GoldenGate processes \u2014 including Manager, Extract, Replicat, and JAgent \u2014 and sends alerts if any of them stop or abend. With embedded configuration and optional [&hellip;]<\/p>\n","protected":false},"template":"","meta":{"googlesitekit_rrm_CAowu461DA:productID":""},"categories":[952,990],"class_list":["post-4263","cposts","type-cposts","status-publish","hentry","category-notes","category-shell-scripts"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts\/4263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/cposts"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=4263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=4263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}