Operating System - HP-UX
1748003 Members
4611 Online
108757 Solutions
New Discussion юеВ

Script solution on oracle alert logfile

 
SOLVED
Go to solution
tom quach_1
Super Advisor

Script solution on oracle alert logfile

Dear,

i have a script to check for oracle alert logfile and when the logfile has any "ORA-" it will send those alert to me.
my solution so far is, if it sees the ORA- the script will copy that alert.log to alert.log.xxxx and zero out the file
Question:
is there a way to either to remove those lines with ORA- or somehow makes the script ignore the old error in the alert.log so it only grep the new ORA- only.

Please give me some advices and syntax.
Thanks in advance.
Tom
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Script solution on oracle alert logfile

You can change/rename the logfile after you process it.

Or if you use "grep -n", you can get the line number of each line and next time ignore those with lines less than a value you save from last time.
tom quach_1
Super Advisor

Re: Script solution on oracle alert logfile

Thanks Dennis,

i did use change/rename
the grep -n seems complicate because when the file grow to certain size it will be reduced to zero and start over again.
Do you have syntax for this.
Thanks,
Tom
Hein van den Heuvel
Honored Contributor
Solution

Re: Script solution on oracle alert logfile

I agree that remembering how far you have processed is tedious. Best just move aways the chucks as they are processed.

Here is how I would approach that.
1 - rename the current file to an intermediate name
2 - use 'touch' to create a fresh file log file
- Oracle will create as needed, but I'd like one to be there all the time
- Don't zero out as Oracle might just have snuck a new one in.
3 - grep / perl / process that intermediate file as you like.
4 - append the intermediate file to a long duration log.
- Instead of the append you could datestamp the chunks. But a single somewhat larger file may be more handy than many smaller ones.

5 - roll the long duration log as needed (timestamped).

Something like...

$ mv alert.log alert.current
$ touch alert.log
$ grep -n '-ORA' alert.current > alert_ora.txt
$ cat alert.current >> alert.archive

Hein.
Dennis Handly
Acclaimed Contributor

Re: Script solution on oracle alert logfile

>I did use change/rename.

If you did that, you don't have to worry about the same contents.

>the grep -n seems complicate because when the file grow to certain size it will be reduced to zero and start over again.

Then remember the size and if smaller, then reset you scan max position.
tom quach_1
Super Advisor

Re: Script solution on oracle alert logfile

Thanks Hein and Dennis,


Good idea Hein, i will use this approach.

Dennis, the reason for this was if Oracle error out to the alert.log repeatedly, then it will generate so many small alert.log file because the script will rename and zero out the file.

Thanks for you helps.
Regards,
Tom