views:

2306

answers:

2

When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment.

I posted some bash and Perl scripts to find and tail the alert log on my blog some time back, and I'm surprised to see that post still getting lots of hits.

The technique used is to lookup background_dump_dest from v$parameter. But I only tested this on Oracle Database 10g.

Is there a better approach than this? And does anyone know if this still works in 11g?

+5  A: 

Am sure it will work in 11g, that parameter has been around for a long time.

Seems like the correct way to find it to me.

If the background_dump_dest parameter isn't set, the alert.log will be put in $ORACLE_HOME/RDBMS/trace

cagcowboy
@cagcowboy hey, thanks for the tip about what happens if the parameter is not set ... the scripts I have don't take that into account
tardate
+3  A: 

Once you've got the log open, I would consider using File::Tail or File::Tail::App to display it as it's being written, rather than sleeping and reading. File::Tail::App is particularly clever, because it will detect the file being rotated and switch, and will remember where you were up to between invocations of your program.

I'd also consider locking your cache file before using it. The race condition may not bother you, but having multiple people try to start your program at once could result in nasty fights over who gets to write to the cache file.

However both of these are nit-picks. My brief glance over your code doesn't reveal any glaring mistakes.

pjf
@pjf thanks .. good points for tailing in Perl. For this use however, I wanted to stay within the standard Perl modules that are part of the Oracle installation. Currently doesn't include File::Tail or File::Tail::App I believe.
tardate