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