Script for alert.log errors in 24 hrs

The alert.log is the first thing a dba would look for an issue with respect to an instance and how better can it be when you can receive last 24 hrs erorrs to your mail box. The below script looks only for ORA-0403, ORA-00600 and ORA-04775. You may add more.

/home/oracle/scripts/crons/chk_alert.sh <db_name> <instance_sid>

#!/bin/ksh
#
#   collect ora error from alert in past 24 hours
#
DBUNAME=$1
ORACLE_SID=$2
ORACLE_HOME=`/usr/local/bin/dbhome $ORACLE_SID`
export ORACLE_HOME ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME/bin

MAIL_RECIPIENT="boy@gmail.com"
HOST_NAME=`hostname -a`
LOG_DIR=/home/oracle/scripts/crons/logs

rm -rf ${LOG_DIR}/alerterr_$ORACLE_SID.log
adrci exec="set home diag/rdbms/$DBUNAME/$ORACLE_SID; show alert -term -p \\\"message_text like '%ORA-0403%' or message_text like '%ORA-00600%' or message_text like '%ORA-04775%' and originating_timestamp >= systimestamp-1\\\"" > ${LOG_DIR}/alerterr_$ORACLE_SID.log
if [ `grep -i error ${LOG_DIR}/alerterr_$ORACLE_SID.log|wc -l` -ne 0 ]; then
    cat ${LOG_DIR}/alerterr_$ORACLE_SID.log|mail -s "$ORACLE_SID Alert Log Errors on `hostname -a` in Past 24 Hours" $MAIL_RECIPIENT
fi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s