Oracle - Reading alert log file.
Hi All,
My requirement is that I wanted a shell script which should read the alert.log(oracle) and should send the alert to my email if any error encountered on daily basis. Note: I have a script which does the same job but at the same time it creates a new alert.log whenever any error occur. But I don't want the new alert log I wanted to read the same alert log daily and if any new error come should alert as email. |
Oracle Enterprise Manager has that capability built-in.
A Google search turned up lots of alternatives, including these: http://www.dba-oracle.com/t_alert_lo...ing_errors.htm And worst case, you can simply write a quick'n'dirty script that does a "grep | diff" of your alert log. |
#!/bin/sh
#GLOBS ALERT="ORA"; LOGFILE=/opt/app/oracle/admin/TECHDATA/bdump/alert_TECHDATA.log MYFILE=/opt/app/oracle/admin/TECHDATA/bdump/ora_error.log ## #get the errors out of the logfile. grep -hw "$ALERT" $LOGFILE >> $MYFILE #count number of lines in myfile, and print. VAR=`wc -l $MYFILE | awk -F" " '{print $1}'` echo $VAR # if the amount of lines is greater than 0, then cat the file and send it to me. if not then echo all clear. #size variable is the number of errors the last time the script ran cd /opt/app/oracle/admin/TECHDATA/bdump/ size=`wc -l ora_error.last | awk -F" " '{print $1}'` echo $size # if the amount of lines is greater than 0, then cat the file and send it to me. if not then echo all clear if [[ $VAR -gt $size ]]; then cat $MYFILE | mail -s "Oracle Error - Following Error Occured" "XXX.com" ; else cd /opt/app/oracle/admin/TECHDATA/bdump/ echo `date` >> alert_check_dump.log echo "All is Well" >> alert_check_dump.log fi; cd /opt/app/oracle/admin/TECHDATA/bdump/ rm ora_error.last mv ora_error.log ora_error.last touch ora_error.log Note: I am interested to see only the new error each time I run the script. But this does not does the entire error . |
All times are GMT -5. The time now is 07:33 AM. |