1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/usr/bin/perl -w
##########################################################################
# $Id: applydate,v 1.6 2002/10/14 16:21:57 kirk Exp $
##########################################################################
########################################################
# This was written and is maintained by:
# Luuk de Boer <luuk@pi.net>
#
# Please send all comments, suggestions, bug reports,
# etc, to kirk@kaybee.org.
########################################################
use POSIX qw(strftime);
# I plan to add a *lot* more date flexibility at a later time...
my $time = time;
if ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'yesterday') {
$SearchDate = strftime("%m/%d/%y", localtime($time-86400));
$SearchDate2 = strftime("%Y/%m/%d", localtime($time-86400));
}
elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'today') {
$SearchDate = strftime("%m/%d/%y", localtime($time));
$SearchDate2 = strftime("%Y/%m/%d", localtime($time));
}
elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'all') {
$SearchDate = "../../..";
$SearchDate2 = "..../../..";
}
if ( $ENV{'LOGWATCH_DEBUG'} > 5 ) {
print STDERR "DEBUG: Inside ApplyDate (samba)...\n";
print STDERR "DEBUG: Range: " . $ENV{'LOGWATCH_DATE_RANGE'} . "\n";
print STDERR "DEBUG: Looking For: $SearchDate or $SearchDate2\n";
}
$ThisLine = <STDIN>;
mainloop: while ($ThisLine) {
if ($ThisLine =~ m/^$SearchDate ..:..:.. /o) {
print $ThisLine;
}
elsif ($ThisLine =~ m/^\[$SearchDate2 ..:..:../o) {
chomp($ThisLine);
print $ThisLine;
while ($ThisLine = <STDIN>) {
if ($ThisLine =~ m/^\[....\/..\/.. ..:..:../) {
# Found next entry
print "\n";
next mainloop;
} else {
chomp($ThisLine);
print $ThisLine;
}
}
print "\n";
} else {
$ThisLine = <STDIN>;
}
}
|