59 * * * * /software/oracle/oracle/scripts/gg_stats_monitor/get_gg_stats.sh
get_gg_stats.sh
#!/bin/bash
. /etc/sh/orash/oracle_login.sh igt
GG_HOME=/software/ogg/191
ORACLE_SID=igt
ORACLE_HOME=/software/oracle/122
HOME_DIR=/software/oracle/oracle/scripts/gg_stats_monitor
DAY_LOG_FILE="${HOME_DIR}/logs/gg_stats_daily.log"
HOUR_LOG_FILE="${HOME_DIR}/logs/gg_stats_hourly.log"
TEMP_HR_LOG=/tmp/gg_stats_hr.log
TEMP_DAY_LOG=/tmp/gg_stats_day.log
SCHEMA_NAME=XXX_YYYYY_ZZZZZ
RUN_HOUR=$(date +"%H")
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`
rm -f $TEMP_HR_LOG 2>/dev/null
rm -f $TEMP_DAY_LOG 2>/dev/null
$GG_HOME/ggsci > $TEMP_HR_LOG << EOD
STATS EXTRACT EXT_I_01, HOURLY
STATS EXTRACT EXT_P_01, HOURLY
STATS EXTRACT EXT_S_01, HOURLY
STATS REPLICAT REP_I_01, HOURLY
STATS REPLICAT REP_P_01, HOURLY
STATS REPLICAT REP_S_01, HOURLY
exit
EOD
if [[ $RUN_HOUR == "09" ]]; then
$GG_HOME/ggsci > $TEMP_DAY_LOG << EOD
STATS EXTRACT EXT_I_01, DAILY
STATS EXTRACT EXT_P_01, DAILY
STATS EXTRACT EXT_S_01, DAILY
STATS REPLICAT REP_I_01, DAILY
STATS REPLICAT REP_P_01, DAILY
STATS REPLICAT REP_S_01, DAILY
exit
EOD
fi
echo "=======================" >> $HOUR_LOG_FILE
echo $RUN_DATE >> $HOUR_LOG_FILE
echo "=======================" >> $HOUR_LOG_FILE
less ${TEMP_HR_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 >> $HOUR_LOG_FILE
if [[ -f $TEMP_DAY_LOG ]]; then
echo "=======================" >> $DAY_LOG_FILE
echo $RUN_DATE >> $DAY_LOG_FILE
echo "=======================" >> $DAY_LOG_FILE
less ${TEMP_DAY_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 >> $DAY_LOG_FILE
fi
#=======================
# Keeps Logs for 1 Week
#=======================
if [[ $RUN_HOUR == "01" ]]; then
mv ${HOUR_LOG_FILE}_06 ${HOUR_LOG_FILE}_07 2>/dev/null
mv ${HOUR_LOG_FILE}_05 ${HOUR_LOG_FILE}_06 2>/dev/null
mv ${HOUR_LOG_FILE}_04 ${HOUR_LOG_FILE}_05 2>/dev/null
mv ${HOUR_LOG_FILE}_03 ${HOUR_LOG_FILE}_04 2>/dev/null
mv ${HOUR_LOG_FILE}_02 ${HOUR_LOG_FILE}_03 2>/dev/null
mv ${HOUR_LOG_FILE}_01 ${HOUR_LOG_FILE}_02 2>/dev/null
mv ${HOUR_LOG_FILE} ${HOUR_LOG_FILE}_01 2>/dev/null
mv ${DAY_LOG_FILE}_06 ${DAY_LOG_FILE}_07 2>/dev/null
mv ${DAY_LOG_FILE}_05 ${DAY_LOG_FILE}_06 2>/dev/null
mv ${DAY_LOG_FILE}_04 ${DAY_LOG_FILE}_05 2>/dev/null
mv ${DAY_LOG_FILE}_03 ${DAY_LOG_FILE}_04 2>/dev/null
mv ${DAY_LOG_FILE}_02 ${DAY_LOG_FILE}_03 2>/dev/null
mv ${DAY_LOG_FILE}_01 ${DAY_LOG_FILE}_02 2>/dev/null
mv ${DAY_LOG_FILE} ${DAY_LOG_FILE}_01 2>/dev/null
fi
No comments:
Post a Comment