From: Sven Hoexter Date: Wed, 1 Feb 2012 19:42:22 +0000 (+0100) Subject: Imported Upstream version 1.1.4 X-Git-Tag: upstream/1.1.4 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=ba8c674111b8f534b4d76b5ead886ce81e36a18f;p=sven%2Fpflogsumm.git Imported Upstream version 1.1.4 --- diff --git a/ChangeLog b/ChangeLog index df3558d..74d8d67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,34 @@ ChangeLog for pflogsumm.pl http://jimsun.LinxNet.com/postfix_contrib.html.] +rel-1.1.4 20120201 + + Modified for compatibility with -o syslog_name=blurfl/submission + and -o syslog_name=blurfl/smtps set in master.cf. (These are the + defaults in Postfix 2.9 and beyond.) + + N.B.: This doesn't mean you'll get submission and + smtps broken-out separately from plain old smtp, + it simply means the presence of the new sub-strings + won't break Pflogsumm. + + Changed "_"s (underscores) in option switches to "-"s (dashes). + (Underscores are still accepted.) Thanks and a tip o' the hat + to David Landgren (david-at-landgren-dot-net) for the suggestion. + + Removed switches deprecated in 1.1.3 from the docs. + + Improved ISO timestamp parsing to account for optional fractional + seconds part. (This is thrown-away by Pflogsumm.) + + Minor updates to the FAQ. + + Replaced "depreciated" with "deprecated" throughout. Thanks and + a tip o' the hat to Rob Arista for the heads-up. + + Fixed bug in host normalization function that was broken for + IPv4 addresses. + rel-1.1.3 20100320 Added long-awaited switches to optionally reduce detail reporting: @@ -14,7 +42,7 @@ rel-1.1.3 20100320 any of them to 0 suppresses that detail entirely. --detail=N sets the default for all of them, as well as for -u=N and -h=N. - With the above enhancements, the following switches are depreciated, + With the above enhancements, the following switches are deprecated, and will eventually be removed: --no_bounce_detail, --no_deferral_detail, --no_reject_detail and --no_smtpd_warnings. They are replaced by setting the desired --*_detail=0. They still @@ -552,13 +580,13 @@ rel-1.0.1 20010518 of VMailer prior to 19981023. NOTICE: As of this version of pflogsumm.pl, the "-c" switch is - DEPRECIATED. This version is transitional and retains it. + DEPRECATED. This version is transitional and retains it. The next version will not have it. Subsequent versions may re-use it for another purpose. Use the "-h" and "-u" switches instead. Added "-h" and "-u" switches to provide finer-grained control over - report output. Depreciated "-c". + report output. Deprecated "-c". Added "deferred" and "bounced" to "Grand Totals", "by-day" and "by- hour" reports. diff --git a/ToDo b/ToDo index 9ac8154..36eb13d 100644 --- a/ToDo +++ b/ToDo @@ -1,6 +1,12 @@ To Be Done (Maybe) + Fix parsing for "451 4.3.5 Server configuration error;" + + Rename pflogsumm.pl -> pflogsumm. See + + http://docs.freebsd.org/info/cvs/cvs.info.Moving_files.html + date ranges, "lastweek", etc.? (options for?) break-down by local vs. non-local?, further diff --git a/pflogsumm-faq.txt b/pflogsumm-faq.txt index b96085a..0e3e4a9 100644 --- a/pflogsumm-faq.txt +++ b/pflogsumm-faq.txt @@ -100,7 +100,7 @@ Index of pflogsumm.pl Frequently Asked Questions (in no particular order) . # ---End: SMTPD_STATS_SUPPORT--- - However, if you do this you will lose support for --smtpd_stats. + However, if you do this you will lose support for --smtpd-stats. Later versions of the Pflogsumm distribution include a script to semi-automate removing smtpd stats support, if you so-desire. @@ -293,7 +293,7 @@ Index of pflogsumm.pl Frequently Asked Questions (in no particular order) away with manual inspection entirely. For those that really want all that extra detail in the log summary - reports, specify the "--verbose_msg_detail" switch. + reports, specify the "--verbose-msg-detail" switch. See Also: 25. Sending Logfile Samples @@ -473,7 +473,7 @@ Index of pflogsumm.pl Frequently Asked Questions (in no particular order) twice. And yes, I tried. I really, really tried. If I recall correctly, I - spent come two days mucking-about with this problem. Actually thought + spent some two days mucking-about with this problem. Actually thought I had it once or twice. But the results inevitably failed regression testing. At the end of this, and with some more careful thought, I realized it just wasn't possible. If you think you can prove me @@ -483,6 +483,12 @@ Index of pflogsumm.pl Frequently Asked Questions (in no particular order) johnfawcett at tiscali-dot-it believes he's done it. You may find prefiltering your log with his "prepflog" does it for you. You can find it at . + + Note: Because of the way John's pre-processing script works, + which, given my own experiments, is probably the way it *has* + to work to work correctly, integrating his code into Pflogsumm + would be difficult, at best, if it's even possible within + Pflogsumm's current structure. 15. Pflogsumm's numbers don't add up @@ -642,7 +648,7 @@ Index of pflogsumm.pl Frequently Asked Questions (in no particular order) Reject reason strings found in the mail log will be truncated at the first comma (","), colon (":") or semi-colon (";"). If you want a "clause" in your reject message to appear in Pflogsumm's output, - without having to specify --verbose_msg_detail, use a punctuation mark + without having to specify --verbose-msg-detail, use a punctuation mark other than one of those three, such as a dash ("-"). @@ -751,4 +757,4 @@ Index of pflogsumm.pl Frequently Asked Questions (in no particular order) http://jimsun.LinxNet.com/postfix_contrib.html -Created: 15 Feb., 1999 / Last updated: 10 April, 2004 +Created: 15 Feb., 1999 / Last updated: 22 March, 2010 diff --git a/pflogsumm.1 b/pflogsumm.1 index 33dac0e..8f97564 100644 --- a/pflogsumm.1 +++ b/pflogsumm.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "PFLOGSUMM 1" -.TH PFLOGSUMM 1 "2010-03-20" "1.1.3" "User Contributed Perl Documentation" +.TH PFLOGSUMM 1 "2012-02-01" "1.1.4" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -132,20 +132,18 @@ .SH "NAME" pflogsumm.pl \- Produce Postfix MTA logfile summary .PP -Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. +Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.4 .SH "SYNOPSIS" .IX Header "SYNOPSIS" -.Vb 10 +.Vb 8 \& pflogsumm.pl \-[eq] [\-d ] [\-\-detail ] -\& [\-\-bounce_detail ] [\-\-deferral_detail ] -\& [\-h ] [\-i|\-\-ignore_case] [\-\-iso_date_time] [\-\-mailq] -\& [\-m|\-\-uucp_mung] [\-\-no_bounce_detail] [\-\-no_deferral_detail] -\& [\-\-no_no_msg_size] [\-\-no_reject_detail] [\-\-no_smtpd_warnings] -\& [\-\-problems_first] [\-\-rej_add_from] [\-\-reject_detail ] -\& [\-\-smtp_detail ] [\-\-smtpd_stats] -\& [\-\-smtpd_warning_detail ] [\-\-syslog_name=string] -\& [\-u ] [\-\-verbose_msg_detail] [\-\-verp_mung[=]] -\& [\-\-zero_fill] [file1 [filen]] +\& [\-\-bounce\-detail ] [\-\-deferral\-detail ] +\& [\-h ] [\-i|\-\-ignore\-case] [\-\-iso\-date\-time] [\-\-mailq] +\& [\-m|\-\-uucp\-mung] [\-\-no\-no\-msg\-size] [\-\-problems\-first] +\& [\-\-rej\-add\-from] [\-\-reject\-detail ] [\-\-smtp\-detail ] +\& [\-\-smtpd\-stats] [\-\-smtpd\-warning\-detail ] +\& [\-\-syslog\-name=string] [\-u ] [\-\-verbose\-msg\-detail] +\& [\-\-verp\-mung[=]] [\-\-zero\-fill] [file1 [filen]] \& \& pflogsumm.pl \-[help|version] \& @@ -166,7 +164,7 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. .SH "OPTIONS" .IX Header "OPTIONS" .Vb 1 -\& \-\-bounce_detail +\& \-\-bounce\-detail \& \& Limit detailed bounce reports to the top . 0 \& to suppress entirely. @@ -174,14 +172,14 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& \-d today generate report for just today \& \-d yesterday generate report for just "yesterday" \& -\& \-\-deferral_detail +\& \-\-deferral\-detail \& \& Limit detailed deferral reports to the top . 0 \& to suppress entirely. \& \& \-\-detail \& -\& Sets all \-\-*_detail, \-h and \-u to . Is +\& Sets all \-\-*\-detail, \-h and \-u to . Is \& over\-ridden by individual settings. \-\-detail 0 \& suppresses *all* detail. \& @@ -199,7 +197,7 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& \& 0 = none. \& -\& See also: "\-u" and "\-\-*_detail" options for further +\& See also: "\-u" and "\-\-*\-detail" options for further \& report\-limiting options. \& \& \-\-help Emit short usage message and bail out. @@ -209,7 +207,7 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& know: lame.) \& \& \-i -\& \-\-ignore_case Handle complete email address in a case\-insensitive +\& \-\-ignore\-case Handle complete email address in a case\-insensitive \& manner. \& \& Normally pflogsumm lower\-cases only the host and @@ -217,14 +215,14 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& option causes the entire email address to be lower\- \& cased. \& -\& \-\-iso_date_time +\& \-\-iso\-date\-time \& \& For summaries that contain date or time information, \& use ISO 8601 standard formats (CCYY\-MM\-DD and HH:MM), \& rather than "Mon DD CCYY" and "HHMM". \& \& \-m modify (mung?) UUCP\-style bang\-paths -\& \-\-uucp_mung +\& \-\-uucp\-mung \& \& This is for use when you have a mix of Internet\-style \& domain addresses and UUCP\-style bang\-paths in the log. @@ -248,9 +246,9 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& \-\-no_deferral_detail \& \-\-no_reject_detail \& -\& These switches are depreciated in favour of -\& \-\-bounce_detail, \-\-deferral_detail and -\& \-\-reject_detail, respectively. +\& These switches are deprecated in favour of +\& \-\-bounce\-detail, \-\-deferral\-detail and +\& \-\-reject\-detail, respectively. \& \& Suppresses the printing of the following detailed \& reports, respectively: @@ -262,7 +260,7 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& See also: "\-u" and "\-h" for further report\-limiting \& options. \& -\& \-\-no_no_msg_size +\& \-\-no\-no\-msg\-size \& \& Do not emit report on "Messages with no size data". \& @@ -275,21 +273,21 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& normally reported by pflogsumm as "Messages with no \& size data." \& -\& \-\-no_smtpd_warnings +\& \-\-no\-smtpd\-warnings \& -\& This switch is depreciated in favour of -\& smtpd_warning_detail +\& This switch is deprecated in favour of +\& smtpd\-warning\-detail \& \& On a busy mail server, say at an ISP, SMTPD warnings \& can result in a rather sizeable report. This option \& turns reporting them off. \& -\& \-\-problems_first +\& \-\-problems\-first \& \& Emit "problems" reports (bounces, defers, warnings, \& etc.) before "normal" stats. \& -\& \-\-rej_add_from +\& \-\-rej\-add\-from \& For those reject reports that list IP addresses or \& host/domain names: append the email from address to \& each listing. (Does not apply to "Improper use of @@ -300,17 +298,17 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& note: headings for warning, fatal, and "master" \& messages will always be printed. \& -\& \-\-reject_detail +\& \-\-reject\-detail \& \& Limit detailed smtpd reject, warn, hold and discard \& reports to the top . 0 to suppress entirely. \& -\& \-\-smtp_detail +\& \-\-smtp\-detail \& \& Limit detailed smtp delivery reports to the top . \& 0 to suppress entirely. \& -\& \-\-smtpd_stats +\& \-\-smtpd\-stats \& \& Generate smtpd connection statistics. \& @@ -318,14 +316,14 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& reports. For multiple\-day reports: "per\-hour" numbers \& are daily averages (reflected in the report heading). \& -\& \-\-smtpd_warning_detail +\& \-\-smtpd\-warning\-detail \& \& Limit detailed smtpd warnings reports to the top . \& 0 to suppress entirely. \& -\& \-\-syslog_name=name +\& \-\-syslog\-name=name \& -\& Set syslog_name to look for for Postfix log entries. +\& Set syslog\-name to look for for Postfix log entries. \& \& By default, pflogsumm looks for entries in logfiles \& with a syslog name of "postfix," the default. @@ -338,18 +336,18 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& \& \-u top to display in user reports. 0 == none. \& -\& See also: "\-h" and "\-\-*_detail" options for further +\& See also: "\-h" and "\-\-*\-detail" options for further \& report\-limiting options. \& -\& \-\-verbose_msg_detail +\& \-\-verbose\-msg\-detail \& \& For the message deferral, bounce and reject summaries: \& display the full "reason", rather than a truncated one. \& \& Note: this can result in quite long lines in the report. \& -\& \-\-verp_mung do "VERP" generated address (?) munging. Convert -\& \-\-verp_mung=2 sender addresses of the form +\& \-\-verp\-mung do "VERP" generated address (?) munging. Convert +\& \-\-verp\-mung=2 sender addresses of the form \& "list\-return\-NN\-someuser=some.dom@host.sender.dom" \& to \& "list\-return\-ID\-someuser=some.dom@host.sender.dom" @@ -370,7 +368,7 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& \& \-\-version Print program name and version and bail out. \& -\& \-\-zero_fill "Zero\-fill" certain arrays so reports come out with +\& \-\-zero\-fill "Zero\-fill" certain arrays so reports come out with \& data in columns that that might otherwise be blank. .Ve .SH "RETURN VALUE" @@ -469,9 +467,9 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. \& \& (rejected / (delivered + rejected + discarded)) * 100 \& -\& There are some issues with the use of \-\-syslog_name. The problem is -\& that, even with $syslog_name set, Postfix will sometimes still log -\& things with "postfix" as the syslog_name. This is noted in +\& There are some issues with the use of \-\-syslog\-name. The problem is +\& that, even with Postfix\*(Aq $syslog_name set, it will sometimes still +\& log things with "postfix" as the syslog_name. This is noted in \& /etc/postfix/sample\-misc.cf: \& \& # Beware: a non\-default syslog_name setting takes effect only @@ -501,7 +499,7 @@ Copyright (C) 1998\-2010 by James S. Seymour, Release 1.1.3. .SH "REQUIREMENTS" .IX Header "REQUIREMENTS" .Vb 3 -\& For certain options (e.g.: \-\-smtpd_stats), Pflogsumm requires the +\& For certain options (e.g.: \-\-smtpd\-stats), Pflogsumm requires the \& Date::Calc module, which can be obtained from CPAN at \& http://www.perl.com. \& diff --git a/pflogsumm.pl b/pflogsumm.pl index 12b703d..a5f93ef 100755 --- a/pflogsumm.pl +++ b/pflogsumm.pl @@ -6,20 +6,18 @@ eval 'exec perl -S $0 "$@"' pflogsumm.pl - Produce Postfix MTA logfile summary -Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. +Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.4 =head1 SYNOPSIS pflogsumm.pl -[eq] [-d ] [--detail ] - [--bounce_detail ] [--deferral_detail ] - [-h ] [-i|--ignore_case] [--iso_date_time] [--mailq] - [-m|--uucp_mung] [--no_bounce_detail] [--no_deferral_detail] - [--no_no_msg_size] [--no_reject_detail] [--no_smtpd_warnings] - [--problems_first] [--rej_add_from] [--reject_detail ] - [--smtp_detail ] [--smtpd_stats] - [--smtpd_warning_detail ] [--syslog_name=string] - [-u ] [--verbose_msg_detail] [--verp_mung[=]] - [--zero_fill] [file1 [filen]] + [--bounce-detail ] [--deferral-detail ] + [-h ] [-i|--ignore-case] [--iso-date-time] [--mailq] + [-m|--uucp-mung] [--no-no-msg-size] [--problems-first] + [--rej-add-from] [--reject-detail ] [--smtp-detail ] + [--smtpd-stats] [--smtpd-warning-detail ] + [--syslog-name=string] [-u ] [--verbose-msg-detail] + [--verp-mung[=]] [--zero-fill] [file1 [filen]] pflogsumm.pl -[help|version] @@ -38,7 +36,7 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. =head1 OPTIONS - --bounce_detail + --bounce-detail Limit detailed bounce reports to the top . 0 to suppress entirely. @@ -46,14 +44,14 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. -d today generate report for just today -d yesterday generate report for just "yesterday" - --deferral_detail + --deferral-detail Limit detailed deferral reports to the top . 0 to suppress entirely. --detail - Sets all --*_detail, -h and -u to . Is + Sets all --*-detail, -h and -u to . Is over-ridden by individual settings. --detail 0 suppresses *all* detail. @@ -71,7 +69,7 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. 0 = none. - See also: "-u" and "--*_detail" options for further + See also: "-u" and "--*-detail" options for further report-limiting options. --help Emit short usage message and bail out. @@ -81,7 +79,7 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. know: lame.) -i - --ignore_case Handle complete email address in a case-insensitive + --ignore-case Handle complete email address in a case-insensitive manner. Normally pflogsumm lower-cases only the host and @@ -89,14 +87,14 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. option causes the entire email address to be lower- cased. - --iso_date_time + --iso-date-time For summaries that contain date or time information, use ISO 8601 standard formats (CCYY-MM-DD and HH:MM), rather than "Mon DD CCYY" and "HHMM". -m modify (mung?) UUCP-style bang-paths - --uucp_mung + --uucp-mung This is for use when you have a mix of Internet-style domain addresses and UUCP-style bang-paths in the log. @@ -120,9 +118,9 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. --no_deferral_detail --no_reject_detail - These switches are depreciated in favour of - --bounce_detail, --deferral_detail and - --reject_detail, respectively. + These switches are deprecated in favour of + --bounce-detail, --deferral-detail and + --reject-detail, respectively. Suppresses the printing of the following detailed reports, respectively: @@ -134,7 +132,7 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. See also: "-u" and "-h" for further report-limiting options. - --no_no_msg_size + --no-no-msg-size Do not emit report on "Messages with no size data". @@ -147,21 +145,21 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. normally reported by pflogsumm as "Messages with no size data." - --no_smtpd_warnings + --no-smtpd-warnings - This switch is depreciated in favour of - smtpd_warning_detail + This switch is deprecated in favour of + smtpd-warning-detail On a busy mail server, say at an ISP, SMTPD warnings can result in a rather sizeable report. This option turns reporting them off. - --problems_first + --problems-first Emit "problems" reports (bounces, defers, warnings, etc.) before "normal" stats. - --rej_add_from + --rej-add-from For those reject reports that list IP addresses or host/domain names: append the email from address to each listing. (Does not apply to "Improper use of @@ -172,17 +170,17 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. note: headings for warning, fatal, and "master" messages will always be printed. - --reject_detail + --reject-detail Limit detailed smtpd reject, warn, hold and discard reports to the top . 0 to suppress entirely. - --smtp_detail + --smtp-detail Limit detailed smtp delivery reports to the top . 0 to suppress entirely. - --smtpd_stats + --smtpd-stats Generate smtpd connection statistics. @@ -190,14 +188,14 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. reports. For multiple-day reports: "per-hour" numbers are daily averages (reflected in the report heading). - --smtpd_warning_detail + --smtpd-warning-detail Limit detailed smtpd warnings reports to the top . 0 to suppress entirely. - --syslog_name=name + --syslog-name=name - Set syslog_name to look for for Postfix log entries. + Set syslog-name to look for for Postfix log entries. By default, pflogsumm looks for entries in logfiles with a syslog name of "postfix," the default. @@ -210,18 +208,18 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. -u top to display in user reports. 0 == none. - See also: "-h" and "--*_detail" options for further + See also: "-h" and "--*-detail" options for further report-limiting options. - --verbose_msg_detail + --verbose-msg-detail For the message deferral, bounce and reject summaries: display the full "reason", rather than a truncated one. Note: this can result in quite long lines in the report. - --verp_mung do "VERP" generated address (?) munging. Convert - --verp_mung=2 sender addresses of the form + --verp-mung do "VERP" generated address (?) munging. Convert + --verp-mung=2 sender addresses of the form "list-return-NN-someuser=some.dom@host.sender.dom" to "list-return-ID-someuser=some.dom@host.sender.dom" @@ -242,7 +240,7 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. --version Print program name and version and bail out. - --zero_fill "Zero-fill" certain arrays so reports come out with + --zero-fill "Zero-fill" certain arrays so reports come out with data in columns that that might otherwise be blank. =head1 RETURN VALUE @@ -336,9 +334,9 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. (rejected / (delivered + rejected + discarded)) * 100 - There are some issues with the use of --syslog_name. The problem is - that, even with $syslog_name set, Postfix will sometimes still log - things with "postfix" as the syslog_name. This is noted in + There are some issues with the use of --syslog-name. The problem is + that, even with Postfix' $syslog_name set, it will sometimes still + log things with "postfix" as the syslog_name. This is noted in /etc/postfix/sample-misc.cf: # Beware: a non-default syslog_name setting takes effect only @@ -367,7 +365,7 @@ Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3. =head1 REQUIREMENTS - For certain options (e.g.: --smtpd_stats), Pflogsumm requires the + For certain options (e.g.: --smtpd-stats), Pflogsumm requires the Date::Calc module, which can be obtained from CPAN at http://www.perl.com. @@ -404,7 +402,7 @@ eval { require Date::Calc }; my $hasDateCalc = $@ ? 0 : 1; my $mailqCmd = "mailq"; -my $release = "1.1.3"; +my $release = "1.1.4"; # Variables and constants used throughout pflogsumm use vars qw( @@ -488,55 +486,60 @@ for (0 .. 23) { $smtpdPerHr[$_] = [0,0,0]; } -$progName = "pflogsumm.pl"; +($progName = $0) =~ s/^.*\///; + $usageMsg = "usage: $progName -[eq] [-d ] [--detail ] - [--bounce_detail ] [--deferral_detail ] - [-h ] [-i|--ignore_case] [--iso_date_time] [--mailq] - [-m|--uucp_mung] [--no_bounce_detail] [--no_deferral_detail] - [--no_no_msg_size] [--no_reject_detail] [--no_smtpd_warnings] - [--problems_first] [--rej_add_from] [--reject_detail ] - [--smtp_detail ] [--smtpd_stats] - [--smtpd_warning_detail ] [--syslog_name=string] - [-u ] [--verbose_msg_detail] [--verp_mung[=]] - [--zero_fill] [file1 [filen]] + [--bounce-detail ] [--deferral-detail ] + [-h ] [-i|--ignore-case] [--iso-date-time] [--mailq] + [-m|--uucp-mung] [--no-no-msg-size] [--problems-first] + [--rej-add-from] [--reject-detail ] [--smtp-detail ] + [--smtpd-stats] [--smtpd-warning-detail ] + [--syslog-name=string] [-u ] [--verbose-msg-detail] + [--verp-mung[=]] [--zero-fill] [file1 [filen]] $progName --[version|help]"; +# Accept either "_"s or "-"s in --switches +foreach (@ARGV) { + last if($_ eq "--"); + tr/_/-/ if(/^--\w/); +} + # Some pre-inits for convenience $isoDateTime = 0; # Don't use ISO date/time formats GetOptions( - "bounce_detail=i" => \$opts{'bounceDetail'}, + "bounce-detail=i" => \$opts{'bounceDetail'}, "d=s" => \$opts{'d'}, - "deferral_detail=i" => \$opts{'deferralDetail'}, + "deferral-detail=i" => \$opts{'deferralDetail'}, "detail=i" => \$opts{'detail'}, "e" => \$opts{'e'}, "help" => \$opts{'help'}, "h=i" => \$opts{'h'}, - "ignore_case" => \$opts{'i'}, + "ignore-case" => \$opts{'i'}, "i" => \$opts{'i'}, - "iso_date_time" => \$isoDateTime, + "iso-date-time" => \$isoDateTime, "mailq" => \$opts{'mailq'}, "m" => \$opts{'m'}, - "no_bounce_detail" => \$opts{'noBounceDetail'}, - "no_deferral_detail" => \$opts{'noDeferralDetail'}, - "no_no_msg_size" => \$opts{'noNoMsgSize'}, - "no_reject_detail" => \$opts{'noRejectDetail'}, - "no_smtpd_warnings" => \$opts{'noSMTPDWarnings'}, - "problems_first" => \$opts{'pf'}, + "no-bounce-detail" => \$opts{'noBounceDetail'}, + "no-deferral-detail" => \$opts{'noDeferralDetail'}, + "no-no-msg-size" => \$opts{'noNoMsgSize'}, + "no-reject-detail" => \$opts{'noRejectDetail'}, + "no-smtpd-warnings" => \$opts{'noSMTPDWarnings'}, + "problems-first" => \$opts{'pf'}, "q" => \$opts{'q'}, - "rej_add_from" => \$opts{'rejAddFrom'}, - "reject_detail=i" => \$opts{'rejectDetail'}, - "smtp_detail=i" => \$opts{'smtpDetail'}, - "smtpd_stats" => \$opts{'smtpdStats'}, - "smtpd_warning_detail=i" => \$opts{'smtpdWarnDetail'}, - "syslog_name=s" => \$opts{'syslogName'}, + "rej-add-from" => \$opts{'rejAddFrom'}, + "reject-detail=i" => \$opts{'rejectDetail'}, + "smtp-detail=i" => \$opts{'smtpDetail'}, + "smtpd-stats" => \$opts{'smtpdStats'}, + "smtpd-warning-detail=i" => \$opts{'smtpdWarnDetail'}, + "syslog-name=s" => \$opts{'syslogName'}, "u=i" => \$opts{'u'}, - "uucp_mung" => \$opts{'m'}, - "verbose_msg_detail" => \$opts{'verbMsgDetail'}, - "verp_mung:i" => \$opts{'verpMung'}, + "uucp-mung" => \$opts{'m'}, + "verbose-msg-detail" => \$opts{'verbMsgDetail'}, + "verp-mung:i" => \$opts{'verpMung'}, "version" => \$opts{'version'}, - "zero_fill" => \$opts{'zeroFill'} + "zero-fill" => \$opts{'zeroFill'} ) || die "$usageMsg\n"; # internally: 0 == none, undefined == -1 == all @@ -551,19 +554,19 @@ $opts{'rejectDetail'} = -1 unless(defined($opts{'rejectDetail'})); # These go away eventually if(defined($opts{'noBounceDetail'})) { $opts{'bounceDetail'} = 0; - warn "$progName: \"no_bounce_detail\" is depreciated, use \"bounce_detail=0\" instead\n" + warn "$progName: \"no_bounce_detail\" is deprecated, use \"bounce-detail=0\" instead\n" } if(defined($opts{'noDeferralDetail'})) { $opts{'deferralDetail'} = 0; - warn "$progName: \"no_deferral_detail\" is depreciated, use \"deferral_detail=0\" instead\n" + warn "$progName: \"no_deferral_detail\" is deprecated, use \"deferral-detail=0\" instead\n" } if(defined($opts{'noRejectDetail'})) { $opts{'rejectDetail'} = 0; - warn "$progName: \"no_reject_detail\" is depreciated, use \"reject_detail=0\" instead\n" + warn "$progName: \"no_reject_detail\" is deprecated, use \"reject-detail=0\" instead\n" } if(defined($opts{'noSMTPDWarnings'})) { $opts{'smtpdWarnDetail'} = 0; - warn "$progName: \"no_smtpd_warnings\" is depreciated, use \"smtpd_warning_detail=0\" instead\n" + warn "$progName: \"no_smtpd_warnings\" is deprecated, use \"smtpd-warning-detail=0\" instead\n" } # If --detail was specified, set anything that's not enumerated to it @@ -595,11 +598,11 @@ if($hasDateCalc) { *Delta_DHMS = *Date::Calc::Delta_DHMS; } elsif(defined($opts{'smtpdStats'})) { - # If user specified --smtpd_stats but doesn't have Date::Calc + # If user specified --smtpd-stats but doesn't have Date::Calc # installed, die with friendly help message. die <) { } else { # RFC 3339 timestamp format? next unless((($msgYr, $msgMon, $msgDay, $msgHr, $msgMin, $msgSec, $logRmdr) = - /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[\+\-](?:\d{2}):(?:\d{2})|Z) \S+ (.+)$/o) == 10); + /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[\+\-](?:\d{2}):(?:\d{2})|Z) \S+ (.+)$/o) == 10); # RFC 3339 months start at "1", we index from 0 --$msgMon; } - unless((($cmd, $qid) = $logRmdr =~ m#^(?:postfix|$syslogName)/([^\[:]*).*?: ([^:\s]+)#o) == 2 || + unless((($cmd, $qid) = $logRmdr =~ m#^(?:postfix|$syslogName)(?:/(?:smtps|submission))?/([^\[:]*).*?: ([^:\s]+)#o) == 2 || (($cmd, $qid) = $logRmdr =~ m#^((?:postfix)(?:-script)?)(?:\[\d+\])?: ([^:\s]+)#o) == 2) { #print UNPROCD "$_"; @@ -719,6 +722,8 @@ while(<>) { ++${$msgsPerDay{$revMsgDateStr}}[0]; ++$msgsRcvd; $rcvdMsg{$qid} = gimme_domain($1); # Whence it came + # DEBUG DEBUG DEBUG + #print STDERR "Received: $qid\n"; } elsif(my($rejSubTyp) = $logRmdr =~ /\[\d+\]: \w+: (reject(?:_warning)?|hold|discard): /o) { if($rejSubTyp eq 'reject') { proc_smtpd_reject($logRmdr, \%rejects, \$msgsRjctd, @@ -845,6 +850,8 @@ while(<>) { ++$dlvPerHr[$msgHr]; ++${$msgsPerDay{$revMsgDateStr}}[1]; ++$msgsDlvrd; + # DEBUG DEBUG DEBUG + #print STDERR "Delivered: $qid\n"; if($msgSizes{$qid}) { ${$recipDom{$domAddr}}[$msgSizeI] += $msgSizes{$qid}; ${$recipUser{$addr}}[$msgSizeI] += $msgSizes{$qid}; @@ -1421,7 +1428,7 @@ sub normalize_host { if((my @octets = ($norm1 =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/o)) == 4) { # Dotted-quad IP address - return(pack('C4', @octets)); + return(pack('U4', @octets)); } else { # Possibly hostname or user@dom.ain return(join( '', map { lc $_ } reverse split /[.@]/, $norm1 ));