G
George Monappallil
Hi guys, Below i have a created a simple perl script that checks an
application log file for words like "ERROR" or "Warning" . I want the script
to send me an alert on my cell whenever it finds those words. I have checked
the net but wasn't successful in finding a way to do it. How would I do
that.
I am a complete newbie but I have already started liking Perl
-------------------------
#!/bin/perl
$LOG="/var/tretsov/tretsov.log";
if (-e $LOG && -s $LOG) {
open (FILE, $LOG) || die "Cannot open";
while (<FILE>) {
if (/ERROR/|/WARNING/i) {
print $_;
}
}
}
else {
print "$LOG file doesn't exist\n";
}
close (FILE);
------------------------
As you can see right now it just prints the lines out to stdout. I would
also like to get your insights on your experiences on running such programs.
I would like to have this program run as a daemon...is it possible ? I also
want this script to just send one message per alert even if it checks the
logs multiple times. Any ideas how I can do it ?
Thanks in advance.
George
application log file for words like "ERROR" or "Warning" . I want the script
to send me an alert on my cell whenever it finds those words. I have checked
the net but wasn't successful in finding a way to do it. How would I do
that.
I am a complete newbie but I have already started liking Perl
-------------------------
#!/bin/perl
$LOG="/var/tretsov/tretsov.log";
if (-e $LOG && -s $LOG) {
open (FILE, $LOG) || die "Cannot open";
while (<FILE>) {
if (/ERROR/|/WARNING/i) {
print $_;
}
}
}
else {
print "$LOG file doesn't exist\n";
}
close (FILE);
------------------------
As you can see right now it just prints the lines out to stdout. I would
also like to get your insights on your experiences on running such programs.
I would like to have this program run as a daemon...is it possible ? I also
want this script to just send one message per alert even if it checks the
logs multiple times. Any ideas how I can do it ?
Thanks in advance.
George