pflogsumm.pl1
Produce postfix mta logfile summary copyright (c) 1998-2010 by james s. seymour, release 1.1.3.
Part of pflogsumm(1).
Usage
pflogsumm.pl -
[eq]
[{-d
<today | yesterday>}]
[--detail
<cnt>]
[--bounce_detail
<cnt>]
[--deferral_detail
<cnt>]
[-h
<cnt>]
[{-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
<cnt>]
[--smtp_detail
<cnt>]
[--smtpd_stats]
[--smtpd_warning_detail
<cnt>]
[--syslog_name=string]
[-u
<cnt>]
[--verbose_msg_detail]
[--verp_mung
[=<n>]]
[--zero_fill]
[file1
[filen]]
pflogsumm.pl -
[{help | version}]
Overview
Pflogsumm is a log analyzer/summarizer for the Postfix MTA. It isdesigned to provide an over-view of Postfix activity, with just enoughdetail to give the administrator a "heads up" for potential troublespots.Pflogsumm generates summaries and, in some cases, detailed reports ofmail server traffic volumes, rejected and bounced email, and serverwarnings, errors and panics.
Options
--bounce_detail <cnt>Limit detailed bounce reports to the top <cnt>. 0to suppress entirely.-d today generate report for just today-d yesterday generate report for just "yesterday"--deferral_detail <cnt>Limit detailed deferral reports to the top <cnt>. 0to suppress entirely.--detail <cnt>Sets all --*_detail, -h and -u to <cnt>. Isover-ridden by individual settings. --detail 0suppresses *all* detail.-e extended (extreme? excessive?) detailEmit detailed reports. At present, this includesonly a per-message report, sorted by sender domain,then user-in-domain, then by queue i.d.WARNING: the data built to generate this report canquickly consume very large amounts of memory if alot of log entries are processed!-h <cnt> top <cnt> to display in host/domain reports.0 = none.See also: "-u" and "--*_detail" options for furtherreport-limiting options.--help Emit short usage message and bail out.(By happy coincidence, "-h" alone does much the same,being as it requires a numeric argument :-). Yeah, Iknow: lame.)-i--ignore_case Handle complete email address in a case-insensitivemanner.Normally pflogsumm lower-cases only the host anddomain parts, leaving the user part alone. Thisoption causes the entire email address to be lower-cased.--iso_date_timeFor 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_mungThis is for use when you have a mix of Internet-styledomain addresses and UUCP-style bang-paths in the log.Upstream UUCP feeds sometimes mung Internet domainstyle address into bang-paths. This option cansometimes undo the "damage". For example:"somehost.dom!username@foo" (where "foo" is the nexthost upstream and "somehost.dom" was whence the emailoriginated) will get converted to"[email protected]". This also affects theextended detail report (-e), to help ensure that by-domain-by-name sorting is more accurate.--mailq Run "mailq" command at end of report.Merely a convenience feature. (Assumes that "mailq"is in $PATH. See "$mailqCmd" variable to path thisiif desired.)--no_bounce_detail--no_deferral_detail--no_reject_detailThese switches are depreciated in favour of--bounce_detail, --deferral_detail and--reject_detail, respectively.Suppresses the printing of the following detailedreports, respectively:message bounce detail (by relay)message deferral detailmessage reject detailSee also: "-u" and "-h" for further report-limitingoptions.--no_no_msg_sizeDo not emit report on "Messages with no size data".Message size is reported only by the queue manager.The message may be delivered long-enough after the(last) qmgr log entry that the information is not inthe log(s) processed by a particular run ofpflogsumm.pl. This throws off "Recipients by messagesize" and the total for "bytes delivered." These arenormally reported by pflogsumm as "Messages with nosize data."--no_smtpd_warningsThis switch is depreciated in favour ofsmtpd_warning_detailOn a busy mail server, say at an ISP, SMTPD warningscan result in a rather sizeable report. This optionturns reporting them off.--problems_firstEmit "problems" reports (bounces, defers, warnings,etc.) before "normal" stats.--rej_add_fromFor those reject reports that list IP addresses orhost/domain names: append the email from address toeach listing. (Does not apply to "Improper use ofSMTP command pipelining" report.)-q quiet - don't print headings for empty reportsnote: headings for warning, fatal, and "master"messages will always be printed.--reject_detail <cnt>Limit detailed smtpd reject, warn, hold and discardreports to the top <cnt>. 0 to suppress entirely.--smtp_detail <cnt>Limit detailed smtp delivery reports to the top <cnt>.0 to suppress entirely.--smtpd_statsGenerate smtpd connection statistics.The "per-day" report is not generated for single-dayreports. For multiple-day reports: "per-hour" numbersare daily averages (reflected in the report heading).--smtpd_warning_detail <cnt>Limit detailed smtpd warnings reports to the top <cnt>.0 to suppress entirely.--syslog_name=nameSet syslog_name to look for for Postfix log entries.By default, pflogsumm looks for entries in logfileswith a syslog name of "postfix," the default.If you've set a non-default "syslog_name" parameterin your Postfix configuration, use this option totell pflogsumm what that is.See the discussion about the use of this option under"NOTES," below.-u <cnt> top <cnt> to display in user reports. 0 == none.See also: "-h" and "--*_detail" options for furtherreport-limiting options.--verbose_msg_detailFor 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"[email protected]"to"[email protected]"In other words: replace the numeric value with "ID".By specifying the optional "=2" (second form), themunging is more "aggressive", converting the addressto something like:"[email protected]"Actually: specifying anything less than 2 does the"simple" munging and anything greater than 1 resultsin the more "aggressive" hack being applied.See "NOTES" regarding this option.--version Print program name and version and bail out.--zero_fill "Zero-fill" certain arrays so reports come out withdata in columns that that might otherwise be blank.
Return value
Pflogsumm doesn't return anything of interest to the shell.
Errors
Error messages are emitted to stderr.
Examples
Produce a report of previous day's activities:pflogsumm.pl -d yesterday /var/log/maillogA report of prior week's activities (after logs rotated):pflogsumm.pl /var/log/maillog.0What's happened so far today:pflogsumm.pl -d today /var/log/maillogCrontab entry to generate a report of the previous day's activityat 10 minutes after midnight.10 0 * * * /usr/local/sbin/pflogsumm -d yesterday /var/log/maillog2>&1 |/usr/bin/mailx -s "`uname -n` daily mail stats" postmasterCrontab entry to generate a report for the prior week's activity.(This example assumes one rotates ones mail logs weekly, some timebefore 4:10 a.m. on Sunday.)10 4 * * 0 /usr/local/sbin/pflogsumm /var/log/maillog.02>&1 |/usr/bin/mailx -s "`uname -n` weekly mail stats" postmasterThe two crontab examples, above, must actually be a single lineeach. They're broken-up into two-or-more lines due to pageformatting issues.
Notes
Pflogsumm makes no attempt to catch/parse non-Postfix logentries. Unless it has "postfix/" in the log entry, it will beignored.It's important that the logs are presented to pflogsumm inchronological order so that message sizes are available whenneeded.For display purposes: integer values are munged into "kilo" and"mega" notation as they exceed certain values. I chose theadmittedly arbitrary boundaries of 512k and 512m as the points atwhich to do this--my thinking being 512x was the largest number(of digits) that most folks can comfortably grok at-a-glance.These are "computer" "k" and "m", not 1000 and 1,000,000. Youcan easily change all of this with some constants near thebeginning of the program."Items-per-day" reports are not generated for single-dayreports. For multiple-day reports: "Items-per-hour" numbers aredaily averages (reflected in the report headings).Message rejects, reject warnings, holds and discards are allreported under the "rejects" column for the Per-Hour and Per-Daytraffic summaries.Verp munging may not always result in correct address andaddress-count reduction.Verp munging is always in a state of experimentation. The useof this option may result in inaccurate statistics with regardsto the "senders" count.UUCP-style bang-path handling needs more work. Particularly ifPostfix is not being run with "swap_bangpath = yes" and/or *is* beingrun with "append_dot_mydomain = yes", the detailed by-message reportmay not be sorted correctly by-domain-by-user. (Also depends onupstream MTA, I suspect.)The "percent rejected" and "percent discarded" figures are onlyapproximations. They are calculated as follows (example is for"percent rejected"):percent rejected =(rejected / (delivered + rejected + discarded)) * 100There are some issues with the use of --syslog_name. The problem isthat, even with $syslog_name set, Postfix will sometimes still logthings 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# after process initialization. Some initialization errors will be# logged with the default name, especially errors while parsing# the command line and errors while accessing the Postfix main.cf# configuration file.As a consequence, pflogsumm must always look for "postfix," in logs,as well as whatever is supplied for syslog_name.Where this becomes an issue is where people are running two or moreinstances of Postfix, logging to the same file. In such a case:. Neither instance may use the default "postfix" syslog nameand.... Log entries that fall victim to what's described insample-misc.cf will be reported under "postfix", so that ifyou're running pflogsumm twice, once for each syslog_name, suchlog entries will show up in each report.The Pflogsumm Home Page is at:http://jimsun.LinxNet.com/postfix_contrib.html
Requirements
For certain options (e.g.: --smtpd_stats), Pflogsumm requires theDate::Calc module, which can be obtained from CPAN athttp://www.perl.com.Pflogsumm is currently written and tested under Perl 5.8.3.As of version 19990413-02, pflogsumm worked with Perl 5.003, butfuture compatibility is not guaranteed.
History
- Debian 6.0 (Squeeze): the text shown here
- Debian 5.0 (Lenny) to Debian 3.1 (Sarge)
- Debian 3.0 (Woody)