8 thoughts on “Linux Shell Script To Monitor and Report GoldenGate Lag”

  1. I have two Goldengate installations on same server. Does it work for both Goldengate installations i.e, two different Goldengate HOME

  2. Looks I missed out your reply, Apologize for that.
    Actually, I don't have a test environment with the same scenario you have, but as an easy approach, I recommend to schedule two versions of the script in the crontab, each script will point to a different GoldenGate Home installation.

  3. Hi Mohammoud , Am not good in scripting . I tried your script it is working in linux but the problem is am 3 mails in the same time and exclude parameter is not working . By default it is sending details of all the process . I wanted remove some process names and lag should be greater than 30 mints . Can check what iam missing in this script . Sugesstion : If you can add header for the process and status would be good to understand
    =======

    Script i modified using ur script :
    ===================================
    [oracle] taxqn1pporadb08:cat gglag.sh
    #!/bin/bash
    set -x
    MAIL_LIST="svedachalamsundaram@corelogic.com"
    SERVER_NAME=`uname -n`
    export SERVER_NAME

    # ###########################################
    # Mandatory Parameters To Be Set By The User:
    # ###########################################
    ORACLE_HOME=/apps/oracle/product/11.2.0.4/db_1 # ORACLE_HOME path of the database where GoldenGate is running against.
    GG_HOME=/ora_backup/ggate/12.2 # GoldenGate Installation Home path. e.g. GG_HOME=/goldengate/gghome

    # ################
    # Script Settings:
    # ################
    # LAG THRESHOLD in minutes: [If reached an e-mail alert will be sent. Default 10 minutes]
    LAG_IN_MINUTES=2

    # Excluded Specific PROCESSES NAME:
    # e.g. If you want to exclude two replicate processes with names REP_11 and REP_12 from being reported then add them to below parameter as shown:
    # EXL_PROC_NAME="DONOTREMOVE|REP_11|REP_12"
    EXL_PROC_NAME="DONOTREMOVE|EPASAUD|RPASAUD1|RPASAUD2|RPASAUD3|RPASAUD4|RPASAUD5|RPASAUD6|RPASAUD7|RPASAUD8|RPASAUD9"
    #EXL_PROC_NAME="DONOTREMOVE|RCLGL|RLASP1|RLASP2"

    # ###############
    # VARIABLES:
    # ###############
    LOG_DIRECTORY=/export/home/oracle/dbascripts/dba # Log Location

    LAG=$LAG_IN_MINUTES
    #LAG=$((LAG_IN_MINUTES * 100))
    export LAG
    export EXL_PROC_NAME=$EXL_PROC_NAME
    export LD_LIBRARY_PATH=${ORACLE_HOME}/lib
    echo LD_LIBRARY_PATH is: $LD_LIBRARY_PATH

    # ################################################
    # Checking the LAG status from Goldengate Console:
    # ################################################
    for GREP_SERVICE in EXTRACT REPLICAT
    do
    export GREP_SERVICE

    export LOG_DIR=${LOG_DIRECTORY}
    export LOG_FILE=${LOG_DIR}/${GREP_SERVICE}_lag_mon.log

    # Identify lagging operation name:
    case ${GREP_SERVICE} in
    "REPLICAT") LAST_COL_OPNAME="RECEIVING"
    export LAST_COL_OPNAME
    BFR_LAST_COL_OPNAME="APPLYING"
    export BFR_LAST_COL_OPNAME
    ;;
    "EXTRACT") LAST_COL_OPNAME="SENDING"

    export LAST_COL_OPNAME
    BFR_LAST_COL_OPNAME="EXTRACTING"
    export BFR_LAST_COL_OPNAME
    ;;
    esac

    $GG_HOME/ggsci << EOF |grep "${GREP_SERVICE}" > ${LOG_FILE}
    info all
    exit
    EOF

    # ################################
    # Email Notification if LAG Found:
    # ################################

    for i in `cat ${LOG_FILE}|egrep -v ${EXL_PROC_NAME}|awk '{print $NF}'|sed -e 's/://g'`
    do
    if [ $i -ge ${LAG} ]
    then
    mail -s "Goldengate LAG detected in ${LAST_COL_OPNAME} TRAIL FILES on Server [${SERVER_NAME}]" ${MAIL_LIST} < ${LOG_FILE}
    #echo "Goldengate LAG detected in ${LAST_COL_OPNAME} TRAIL FILES on Server [${SERVER_NAME}]"
    fi
    done

    done

    # #############
    # END OF SCRIPT
    ###############

  4. For a lag greater than 30 min set this parameter:

    LAG_IN_MINUTES=31

    for excluding processes from being reported I can see you are doing it right, but remember they will not trigger the alarm if the are lagged of OFF, but they will be still seen in the Email body:

    EXL_PROC_NAME="DONOTREMOVE|EPASAUD|RPASAUD1|RPASAUD2|RPASAUD3|RPASAUD4|RPASAUD5|RPASAUD6|RPASAUD7|RPASAUD8|RPASAUD9"

Leave a Reply

Your email address will not be published. Required fields are marked *