#!/usr/bin/perl -w # * * * * * * * * * * * * * * * * * * * * * * * * * * * # alertwatch.pl # By: Mr Paradox # # Usage: alertwatch.pl /path/to/alert.log # # Info: # alertwatch is a persistant program to monitor your oracle alert log # no need to loop this with a cron, just start it in the background and # let it run, the second an ORA- error is written to the alert.log it # will be mailed to the DBA. # # Configuration: # Make sure to change: # mail{To} / mail{From} / mail{Subject} # # Prereqs: File::Tail # Mail::Sendmail # Both can be downloaded from www.cpan.org # * * * * * * * * * * * * * * * * * * * * * * * * * * * use File::Tail; use Mail::Sendmail; my $logfile = $ARGV[0]; my $fi = File::Tail->new( name => $logfile, maxinterval => 2, interval => 1, adjustafter => 3, resetafter => 30, tail => 0, ); while (1) { $_ = $fi->read; chomp; if ( $_ =~ "ORA-" ){ print $_; $mail{To} = ''; $mail{From} = 'Email From '; $mail{Subject} = 'Alert Log Report'; $mail{Message} = $_; sendmail(%mail) or die $Mail::Sendmail::error; } }