Wed, 21 Sep 2011 14:10:37 +0200
Import package vendor original specs for necessary manipulations.
michael@146 | 1 | This patch makes Pflogsumm working with the particular format |
michael@146 | 2 | of the OSSP fsl based Postfix logfile and additionally allows |
michael@146 | 3 | one to specify a more flexible data format. |
michael@146 | 4 | |
michael@146 | 5 | Index: pflogsumm.1 |
michael@146 | 6 | --- pflogsumm.1.orig 2007-04-06 16:11:28 +0200 |
michael@146 | 7 | +++ pflogsumm.1 2007-04-06 17:35:12 +0200 |
michael@146 | 8 | @@ -172,6 +172,8 @@ |
michael@146 | 9 | .Vb 2 |
michael@146 | 10 | \& -d today generate report for just today |
michael@146 | 11 | \& -d yesterday generate report for just "yesterday" |
michael@146 | 12 | +\& -d YYYY-MM-DD generate report for just "YYYY-MM-DD" |
michael@146 | 13 | +\& (Really takes string Date::Parse will handle) |
michael@146 | 14 | .Ve |
michael@146 | 15 | .PP |
michael@146 | 16 | .Vb 1 |
michael@146 | 17 | Index: pflogsumm.pl |
michael@146 | 18 | --- pflogsumm.pl.orig 2008-06-29 15:46:01 +0200 |
michael@146 | 19 | +++ pflogsumm.pl 2008-06-29 19:39:07 +0200 |
michael@146 | 20 | @@ -10,7 +10,7 @@ |
michael@146 | 21 | |
michael@146 | 22 | =head1 SYNOPSIS |
michael@146 | 23 | |
michael@146 | 24 | - pflogsumm.pl -[eq] [-d <today|yesterday>] [-h <cnt>] [-u <cnt>] |
michael@146 | 25 | + pflogsumm.pl -[eq] [-d <today|yesterday|YYYY-MM-DD>] [-h <cnt>] [-u <cnt>] |
michael@146 | 26 | [--verp_mung[=<n>]] [--verbose_msg_detail] [--iso_date_time] |
michael@146 | 27 | [-m|--uucp_mung] [-i|--ignore_case] [--smtpd_stats] [--mailq] |
michael@146 | 28 | [--problems_first] [--rej_add_from] [--no_bounce_detail] |
michael@146 | 29 | @@ -37,6 +37,9 @@ |
michael@146 | 30 | |
michael@146 | 31 | -d today generate report for just today |
michael@146 | 32 | -d yesterday generate report for just "yesterday" |
michael@146 | 33 | + -d YYYY-MM-DD generate report for just "YYYY-MM-DD" |
michael@146 | 34 | + (Actually this will take any date string |
michael@146 | 35 | + parsable by the perl Date::Parse module) |
michael@146 | 36 | |
michael@146 | 37 | -e extended (extreme? excessive?) detail |
michael@146 | 38 | |
michael@146 | 39 | @@ -359,6 +362,7 @@ |
michael@146 | 40 | use strict; |
michael@146 | 41 | use locale; |
michael@146 | 42 | use Getopt::Long; |
michael@146 | 43 | +use Date::Parse; |
michael@146 | 44 | eval { require Date::Calc }; |
michael@146 | 45 | my $hasDateCalc = $@ ? 0 : 1; |
michael@146 | 46 | |
michael@146 | 47 | @@ -542,8 +546,8 @@ |
michael@146 | 48 | my $logRmdr; |
michael@146 | 49 | next unless((($msgMonStr, $msgDay, $msgHr, $msgMin, $msgSec, $logRmdr) = |
michael@146 | 50 | /^(...) +(\d+) (..):(..):(..) \S+ (.+)$/o) == 6); |
michael@146 | 51 | - unless((($cmd, $qid) = $logRmdr =~ m#^(?:postfix|$syslogName)/([^\[:]*).*?: ([^:\s]+)#o) == 2 || |
michael@146 | 52 | - (($cmd, $qid) = $logRmdr =~ m#^((?:postfix)(?:-script)?)(?:\[\d+\])?: ([^:\s]+)#o) == 2) |
michael@146 | 53 | + unless((($cmd, $qid) = $logRmdr =~ m#^<[a-z]+>\s+(?:postfix|$syslogName)/([^\[:]*).*?: ([^:\s]+)#o) == 2 || |
michael@146 | 54 | + (($cmd, $qid) = $logRmdr =~ m#^<[a-z]+>\s+((?:postfix)(?:-script)?)(?:\[\d+\])?: ([^:\s]+)#o) == 2) |
michael@146 | 55 | { |
michael@146 | 56 | #print UNPROCD "$_"; |
michael@146 | 57 | next; |
michael@146 | 58 | @@ -1406,11 +1410,11 @@ |
michael@146 | 59 | # Back up to yesterday |
michael@146 | 60 | $time -= ((localtime($time))[2] + 2) * 3600; |
michael@146 | 61 | } elsif($dateOpt ne "today") { |
michael@146 | 62 | - die "$usageMsg\n"; |
michael@146 | 63 | + $time = str2time($dateOpt); |
michael@146 | 64 | } |
michael@146 | 65 | my ($t_mday, $t_mon) = (localtime($time))[3,4]; |
michael@146 | 66 | |
michael@146 | 67 | - return sprintf("%s %2d", $monthNames[$t_mon], $t_mday); |
michael@146 | 68 | + return sprintf("%s %02d", $monthNames[$t_mon], $t_mday); |
michael@146 | 69 | } |
michael@146 | 70 | |
michael@146 | 71 | # if there's a real domain: uses that. Otherwise uses the IP addr. |