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