Pages

Thursday, December 14, 2023

Golden Gate - Crontab to log INFO ALL

crontab
*/10 * * * * /software/oracle/oracle/scripts/gg_stats_monitor/get_gg_info.sh

get_gg_info.sh
#!/bin/bash
. /etc/sh/orash/oracle_login.sh igt
GG_HOME=/software/ogg/191
ORACLE_SID=igt
ORACLE_HOME=/software/oracle/122

SCHEMA_NAME=XXX_YYYYY_ZZZZZ

HOME_DIR=/software/oracle/oracle/scripts/gg_stats_monitor
INFO_LOG_FILE="${HOME_DIR}/logs/gg_info.log"
TEMP_INFO_LOG=/tmp/gg_info_all.log

RUN_HOUR=$(date +"%H")
RUN_MIN=$(date +"%M")
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`

#main()
rm -f $TEMP_INFO_LOG 2>/dev/null

$GG_HOME/ggsci > $TEMP_INFO_LOG << EOD
INFO ALL
exit
EOD

echo "=======================" >> $INFO_LOG_FILE
echo $RUN_DATE >> $INFO_LOG_FILE
echo "=======================" >> $INFO_LOG_FILE
less ${TEMP_INFO_LOG} | grep -v "Command Interpreter for Oracle" | grep -v OGGCORE | grep -v "Operating system" | grep -v Copyright | grep -v "character set" | grep -v "Linux, x64" | grep -v GGSCI | grep -v "SYSLOG"  | grep -v ^$ >> $INFO_LOG_FILE


#=======================
# Keeps Logs for 1 Week
#=======================
if [[ $RUN_HOUR == "01" && $RUN_MIN == "00" ]]; then
 mv ${TEMP_INFO_LOG}_06 ${TEMP_INFO_LOG}_07 2>/dev/null
 mv ${TEMP_INFO_LOG}_05 ${TEMP_INFO_LOG}_06 2>/dev/null
 mv ${TEMP_INFO_LOG}_04 ${TEMP_INFO_LOG}_05 2>/dev/null
 mv ${TEMP_INFO_LOG}_03 ${TEMP_INFO_LOG}_04 2>/dev/null
 mv ${TEMP_INFO_LOG}_02 ${TEMP_INFO_LOG}_03 2>/dev/null
 mv ${TEMP_INFO_LOG}_01 ${TEMP_INFO_LOG}_02 2>/dev/null
 mv ${TEMP_INFO_LOG} ${TEMP_INFO_LOG}_01 2>/dev/null
fi

Generated File
=======================
20231214_082001
=======================
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     DPM_I_01    00:00:00      00:00:01
EXTRACT     RUNNING     DPM_P_01    00:00:00      00:00:08
EXTRACT     RUNNING     DPM_S_01    00:00:03      00:00:05
EXTRACT     RUNNING     EXT_I_01    00:00:02      00:00:05
EXTRACT     RUNNING     EXT_P_01    00:00:02      00:00:02
EXTRACT     RUNNING     EXT_S_01    00:00:02      00:00:02
REPLICAT    RUNNING     REP_I_01    00:00:00      00:00:04
REPLICAT    RUNNING     REP_P_01    00:00:00      00:00:08
REPLICAT    RUNNING     REP_S_01    00:00:03      00:00:00

No comments:

Post a Comment