Log monitoring script

From: Geon Reuben (geomonap@rediffmail.com)
Date: Tue Jan 25 2005 - 10:39:12 EST


Hi guys:
I have to write a script that monitors the system logfiles for
certain words and send alerts if it finds one. I have a skeleton perl script
that does some of the logic. However, is it possible to run a perl script as a
daemon rather than running it via cron every 1 sec so that the log files can
be monitored at realtime? Also, since the messages might appear multiple
times, any ideas how I can send alerts only on the newer log messages ? Any
pointers would be helpful. Below is my Perl script.

-------------------
$LOG="/var/adm/messages";
if (-e $LOG && -s $LOG) {
   open (FILE, $LOG) ||
die "Cannot open";
   while (<FILE>) {
      if (/panic/|/warning/) {
< send alerts here >;
        }
     }
}
else {
   print "$LOG file doesn't
exist\n";
     }
close (FILE);
---------------------------------

Thanks in
advance and appologize for the slightly offtopic post. Will summarize

GR

ps:
This question was asked by Ert Werr a few weeks back. Repeated requests by me
didn't result in a summary. Hence, I had to post this again here.
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:30:03 EDT