The attached patch extends the -d option of pflogsumm to use any date parseable with the perl Date::Parse module in addition to its normal ``today'' and ``yesterday'' options. The option now takes arguments such as ``pflogsumm -d 2006-08-15 ...''.
I wanted to be able to rerun pflogsumm against old postfix.log files to get some statistics, and found the standard options useless. Running without the -d option on a typical daily log file would throw the Per-Hour reports off since they're averages per hour which is pretty useless if the daily log file has a few lines from the previous or following day. I think this should work with pretty much any version of postfix in the OpenPKG trees as this hasn't changed in quite a while. Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 ``Rightful liberty is unobstructed action according to our will within limits drawn around us by the equal rights of others. I do not add 'within the limits of the law' because law is often but the tyrant's will, and always so when it violates the rights of the individual.'' -Thomas Jefferson
diff -uNr ../postfix-2.2.5-20060528/pflogsumm-1.1.0/pflogsumm.1 ./pflogsumm-1.1.0/pflogsumm.1 --- ../postfix-2.2.5-20060528/pflogsumm-1.1.0/pflogsumm.1 2003-12-12 06:41:55.000000000 -0800 +++ ./pflogsumm-1.1.0/pflogsumm.1 2006-08-25 17:41:57.257264392 -0700 @@ -225,6 +225,8 @@ .Vb 2 \& -d today generate report for just today \& -d yesterday generate report for just "yesterday" +\& -d YYYY-MM-DD generate report for just "YYYY-MM-DD" +\& (Really takes string Date::Parse will handle) .Ve .Vb 1 \& -e extended (extreme? excessive?) detail diff -uNr ../postfix-2.2.5-20060528/pflogsumm-1.1.0/pflogsumm.pl ./pflogsumm-1.1.0/pflogsumm.pl --- ../postfix-2.2.5-20060528/pflogsumm-1.1.0/pflogsumm.pl 2006-08-25 17:39:01.000059560 -0700 +++ ./pflogsumm-1.1.0/pflogsumm.pl 2006-08-25 17:43:45.572797928 -0700 @@ -10,7 +10,7 @@ =head1 SYNOPSIS - pflogsumm.pl -[eq] [-d <today|yesterday>] [-h <cnt>] [-u <cnt>] + pflogsumm.pl -[eq] [-d <today|yesterday|YYYY-MM-DD>] [-h <cnt>] [-u <cnt>] [--verp_mung[=<n>]] [--verbose_msg_detail] [--iso_date_time] [-m|--uucp_mung] [-i|--ignore_case] [--smtpd_stats] [--mailq] [--problems_first] [--rej_add_from] [--no_bounce_detail] @@ -37,6 +37,9 @@ -d today generate report for just today -d yesterday generate report for just "yesterday" + -d YYYY-MM-DD generate report for just "YYYY-MM-DD" + (Actually this will take any date string + parsable by the perl Date::Parse module) -e extended (extreme? excessive?) detail @@ -1372,9 +1375,10 @@ my $time = time(); if($dateOpt eq "yesterday") { - $time -= $aDay; + $time -= $aDay; } elsif($dateOpt ne "today") { - die "$usageMsg\n"; + use Date::Parse; + $time = str2time($dateOpt); } my ($t_mday, $t_mon) = (localtime($time))[3,4];