Fellow Monks,
I have a reoccuring problem with my Checkpoint FW-1 logfiles keep getting corrupt. Right now, I have this command
fw log -n |more (-n says don't to resolve dns) in my .bash_profile so everytime I login it will tell me if the log files are corrupt or not. Well sometimes I don't login for a few days, so I lose 2 days worth of logfiles if they are corrupt. If everything is fine, then the command will just scroll through all of the log files (which are huge). Here is the error message that is returned when the log files do become corrupt
lvfile_open: failed to open logfile /etc/fw/log/fw.log log ptrs proble
+m
Failed to open logfile
Below is the script that I wrote that I thought would work, but it doesn't seem to be. Also, when the
fw log -n is run is there a way to stop the process so that it doesn't stay open scrolling through the whole log file (by default this command will stay open showing all new log entries). I want to run this command every 30 minutes from cron and I don't want a bunch of these processes running in the background. Will this work:
fw log |exit 1
#!/usr/bin/perl -w
use strict;
############################################################
#
# Script to check to see if the log files become corrupt
#
############################################################
my $result;
my $cmd1="fw log -n" ;
my $from_addr="Root<root\@mysite.com>";
my $to_addr="Dru<dru\@mysite.com>";
#Run fw log command
#$result=`$cmd1`;
#If it fails, then send email
if ($cmd1 =~ m/failed/){
open(SENDMAIL, "|/usr/lib/sendmail -oi -t")
or die "Can't fork for sendmail: $!\n";
print SENDMAIL <<EOM;
From: $from_addr
To: $to_addr
Subject: There is a problem with the firewall logs!
EOM
close(SENDMAIL) or warn "sendmail didn't close nicely";
exit 1
}
TIA
-Dru
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.