Script For Monitoring Alert Log

Requirement:
A shell script to monitor alert log for all the databases on a server once in every 15 min.And in the case of any ORA- error mail to the respective  TEAM.

Below script is prepared using the ADRCI utility of oracle 11g and above. 


Script: alert_log_ora_errorchecking.sh
#!/bin/sh
##################################################################################
###### ALERT LOG CHECKING VIA ADRCI #######################################################
######  Author - XXXXXX#######################################################
###################################################################################
export ORACLE_BASE=/u01/app
export ORACLE_HOME=/u01/app/oracle/product/11.2.3/dbhome_1
export ORACLE_SID=Demo
export LOG=/home/oracle/DBA_SCRIPTS/alert_demo_err.log
export adrci_home=diag/rdbms/demo/demo
export HOST_NAME=demoserv
echo '######################################################################' > $LOG
echo '####ALERT LOG OUTPUT FOR LAST 15 MINUTES #######################' >> $LOG
echo '###################################################################' >> $LOG

                #adrci_homes=( $(adrci exec="show homes" | grep -e rdbms -e asm))####If ASM
                echo '####################################################' >> $LOG
                echo '#### find below error details for the Database:' $ORACLE_SID '#########' >> $LOG
                echo '############Host Name :' $HOST_NAME '###################' >> $LOG
                echo '####################################################' >> $LOG
                echo ''  >> $LOG
                echo ''  >> $LOG
                echo ''  >> $LOG
                for adrci_home in ${adrci_home[@]}
                do
                echo $adrci_home' Alert Log' >> $LOG
               adrci exec="set home ${adrci_home}; show alert -p \\\"message_text like '%ORA-%' and originating_timestamp > systimestamp-1/96\\\"" -term >> $LOG
                done
[[ `grep -c "ORA-" ${LOG}` -gt 0 ]] && mail -s "ORA- error found in alert Log of the server" xyz@thedbaportfolio.com <$LOG


Permission:
chmod 755  alert_log_ora_errorchecking.sh

Crontab entry:

0,15,30,45 * * * * /home/oracle/DBA_SCRIPTS/alert_log_ora_errorchecking.sh > /dev/null

No comments:

Post a Comment

thedbaportfolio@gmail.com