LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-02-2011, 11:21 PM   #1
myounusn
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
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.
 
Old 03-03-2011, 12:36 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 03-03-2011, 04:11 AM   #3
myounusn
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Original Poster
Rep: Reputation: 0
#!/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 .

Last edited by myounusn; 03-03-2011 at 04:18 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
oracle alert log script dxangel Programming 17 12-28-2014 06:27 AM
[SOLVED] Need some help reading part of a log file agangsto Linux - General 5 07-09-2010 02:14 AM
Reading a CSV text file and storing the values in Oracle Database table shafi2all Linux - Newbie 3 04-17-2008 12:19 PM
Log file reading Garak Linux - General 5 07-08-2003 06:55 PM


All times are GMT -5. The time now is 12:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration