-
I am in the progress to write a shell script to check my alert log for an Oracle database 816 on Solaris. The script will be placed on cron job and check the Oracle alert log every 5 minutes. If any new ORA- error comes up, it will send me an email. Does anybody have any tips or techniques for this? Thank you!
Righ now, I am thinking something like:
cat alert_dbprod.log|grep ORA
Questions are:
How do I avoid scaning the log from the very first line everytime? The alert log is purged and "refreshed" every quarter.
What are the searching patterns that I need to use? Only "ORA-"? Are there any other patterns I need to catch and send emails for DBAs to look?
-
Here is the script I use:
C_DATE=`date +"%a %b %e "`
DBA='me@myaddress.com'
host=`hostname`
## Xtract current date records from alert file & scan it for ORA-errors.
sed -n "/^$C_DATE/,$ p" /P0/app/oracle/admin/mast/bdump/alert_mast.log > temp$$
sed -n '/^ORA-/ p' temp$$ > ora_errors
# Variable LN_CNT initialized to the no. of lines in the ora_errors file.
LN_CNT=`wc -l < ora_errors`
# If ora_errors file has lines in it, then mail is sent to the DBA.
if [[ $LN_CNT -ge 1 ]]
then
cat ora_errors | mailx -s "Please Check the ALERT_MAST.LOG on $host for Er
rors" $DBA
fi
rm temp$$
rm ora_errors
-
As part of my cron job, I save a copy of the current alert.log file to alert.log.last. I can then diff the two files to get only the changes since the last time the cron job was fired.
Jeff Hunter
-
Thank you for mhaller and Jeff!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|