Oracle alert log monitoring by using ADRCI
Oracle alert log monitoring by using ADRCI
set -x
#################################################
###### ALERT LOG CHECKING VIA ADRCI #############
#################################################
export ORACLE_SID=ORADW4
export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1
export PATH=$PATH:/u01/app/oracle/product/12.1.0.2/dbhome_1/bin
export ERROR_LOG=/home/oracle/admin/common/scripts/logs/alert_log_error.txt
export EMAIL_ERROR_LOG=/home/oracle/admin/common/scripts/logs/alert_log_ORADW4_email_error.txt
export SUBJECT=”ORA – Errors in the alert log for $ORACLE_SID ”
export EMAIL=”dba@ajara.tech”
export MAILPROG=”/bin/mail”
echo $PATH > $ERROR_LOG
HOST_NAME=`hostname`
DDATE=`date`
#adrci_home=( $(adrci exec=”show homes” | grep -i $ORACLE_SID))
adrci_home=diag/rdbms/oradw/ORADW4
echo $adrci_home’ Alert Log on’ $HOST_NAME ‘at ‘ $DDATE >> $ERROR_LOG
#
#This is test for one full day
adrci exec=”set home ${adrci_home}; show alert -p \\\”message_text like ‘%ORA-%’ and originating_timestamp > systimestamp-1\\\”” -term >> $ERROR_LOG
#
#
#This is test for the last 1 hour
#
##adrci exec=”set home ${adrci_home}; show alert -p \\\”message_text like ‘%ORA-%’ and originating_timestamp > systimestamp-1/24\\\”” -term >> $ERROR_LOG
##
## Filter out any errors that you don’t want to be checked
## As an example Here ORA-0155 and ORA-03113 are filtered out
cat $ERROR_LOG | grep -v ORA-03113 > $EMAIL_ERROR_LOG
##
##
num_errors=`grep -c ‘ORA-‘ $EMAIL_ERROR_LOG`
if [ $num_errors != 0 ]
then
$MAILPROG -s “$SUBJECT” “$EMAIL” — -r $HOSTNAME < $EMAIL_ERROR_LOG
fi