Wednesday, April 17, 2019

monitor golden-gate processes


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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

#!/bin/bash
EMAIL_LIST="support@mydomain.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
report

 Now configure the script in crontab with 30 min interval.
1
2
3
4
  
00,30 * * * * /home/goldengate/gg_alert.sh > /home/goldengate/gg_alerts.log