At 08:51 AM 9/30/02 , Rob Murdock wrote:
Report on failures. I know the email reports give this, but it would be
nice to be able to list these for a date range or day/week/month.
We run this daily on each backup server. You'll have to make a few obvious
changes for your site.
----------- cut -----------------
#!/usr/local/bin/sh
# $Id: nsrlognotify,v 1.4 2002/04/01 19:09:52 root.p Exp $
mailto=${1:-"sysadm AT eldocomp DOT com"}
(
echo "From: root AT ecisun5.ecinet DOT com"
echo "To: sysadm AT eldocomp DOT com"
echo "Reply-To: sysadm AT eldocomp DOT com"
echo "Subject: NSR Log Exception Scan"
/usr/local/sbin/nsrlogscan /nsr 2>& 1
) | /usr/lib/sendmail $mailto
----------- uncut -----------------
----------- cut -----------------
#!/usr/bin/perl -w
# $Id: nsrlogscan,v 1.4 2002/03/28 02:46:38 root.p Exp $
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
=head1 NAME
nsrlogscan - Perform a scan of the NSR messages log for alerts
=head1 SYNOPSIS
nsrlogscan [-vh] nsrdirectory
=head1 DESCRIPTION
This program scans the NSR B<messages> log for alert entries.
Only entries for dates that follow the modification time
of the B<.nsrlogscan> file will be examined. The entries
found will be written to standard output.
The B<-v> option prints the program version. The B<-h> option
prints brief usage information.
This program must be executed as the superuser.
=head1 PROPERTY
This software is the property of Eldorado Computing Inc. and
may be duplicated or distributed with permission.
=head1 AUTHOR
William Bloom <wbloom AT eldocomp DOT com>
=cut
use strict;
use Getopt::Std;
use Date::Parse;
use vars qw
{
$opt_h $opt_v $version
$nsrbase $nsrlogs $nsrmessages $since $entry $seencount $alertcount
};
$version = sprintf("%d.%02d", '$Revision: 1.4 $' =~ /(\d+)\.(\d+)/);
sub usage
{
"\n",
"Usage: nsrlogscan [-vh] <nsrdirectory>\n\n",
" Scan NSR messages log for alerts.\n\n",
" <nsrdirectory> is the base install directory\n",
" for NSR.\n\n",
" Only the superuser may use this program.\n\n";
}
die usage() unless (getopts("vh")); # Report usage if invalid options passed
if ($opt_v)
{
# Report version (-v option)
print STDERR "\nThis is nsrlogscan version $version.\n\n";
exit(0);
}
if ($opt_h)
{
# Show usage
print STDERR usage();
exit(0);
}
die usage() if
(!@ARGV || ! -d "$ARGV[0]" || ! -f "$ARGV[0]/logs/messages");
$nsrbase = $ARGV[0];
$nsrlogs = "$nsrbase/logs";
$nsrmessages = "$nsrlogs/messages";
$alertcount = $seencount = 0;
$since = 0 unless ($since = (stat("$nsrlogs/.nsrlogscan"))[9]);
$| = 1;
print STDERR "\nNow commencing scan of ${nsrmessages}\nfor exceptions since
",scalar(localtime($since)),"...\n\n";
open(MSGS,$nsrmessages) || die "\nFailed to access $nsrmessages: $!\n\n";
while($entry = <MSGS>)
{
$seencount++;
next unless($entry =~
/^(\w\w\w\s+\d+\s+\d\d:\d\d:\d\d)\s.*\s\((critical|emergency|alert)\)\s/ &&
(str2time($1) >= $since));
print $entry;
$alertcount++;
}
close(MSGS);
print STDERR "\nScan complete.\n Entries seen: $seencount\n Alerts found:
$alertcount\n\n";
system("/usr/bin/touch","$nsrlogs/.nsrlogscan");
exit(0);
----------- uncut -----------------
-crl
--
Chad R. Larson (CRL22) chad AT eldocomp DOT com
Eldorado Computing, Inc. 602-604-3100
5353 North 16th Street, Suite 400
Phoenix, Arizona 85016-3228
--
Note: To sign off this list, send a "signoff" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
|