add DSN support; from Christian Rueger

This commit is contained in:
jakob 2005-06-30 13:22:23 +00:00
parent 72486e8250
commit ba295f830a
3 changed files with 341 additions and 4 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.4 2004/01/28 10:27:20 jakob Exp $ # $OpenBSD: Makefile,v 1.5 2005/06/30 13:22:23 jakob Exp $
COMMENT= "Postfix log entry summarizer" COMMENT= "Postfix log entry summarizer"
VERSION= 1.1.0 DISTNAME= pflogsumm-1.1.0
DISTNAME= pflogsumm-${VERSION} PKGNAME= ${DISTNAME}p0
CATEGORIES= mail CATEGORIES= mail
MASTER_SITES+= http://jimsun.linxnet.com/downloads/ MASTER_SITES+= http://jimsun.linxnet.com/downloads/

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-pflogsumm_pl,v 1.3 2004/01/28 10:27:20 jakob Exp $ $OpenBSD: patch-pflogsumm_pl,v 1.4 2005/06/30 13:22:23 jakob Exp $
--- pflogsumm.pl.orig 2004-01-28 13:38:53.000000000 +1000 --- pflogsumm.pl.orig 2004-01-28 13:38:53.000000000 +1000
+++ pflogsumm.pl 2004-01-28 13:39:29.000000000 +1000 +++ pflogsumm.pl 2004-01-28 13:39:29.000000000 +1000
@@ -4,13 +4,13 @@ eval 'exec perl -S $0 "$@"' @@ -4,13 +4,13 @@ eval 'exec perl -S $0 "$@"'
@ -63,3 +63,12 @@ $OpenBSD: patch-pflogsumm_pl,v 1.3 2004/01/28 10:27:20 jakob Exp $
$usageMsg = $usageMsg =
"usage: $progName -[eq] [-d <today|yesterday>] [-h <cnt>] [-u <cnt>] "usage: $progName -[eq] [-d <today|yesterday>] [-h <cnt>] [-u <cnt>]
[--verp_mung[=<n>]] [--verbose_msg_detail] [--iso_date_time] [--verp_mung[=<n>]] [--verbose_msg_detail] [--iso_date_time]
@@ -696,7 +696,7 @@ while(<>) {
}
}
elsif((($addr, $relay, $delay, $status, $toRmdr) = $logRmdr =~
- /to=<([^>]*)>, (?:orig_to=<[^>]*>, )?relay=([^,]+), delay=([^,]+), status=(\S+)(.*)$/o) >= 4)
+ /to=<([^>]*)>, (?:orig_to=<[^>]*>, )?relay=([^,]+), delay=([^,]+), (?:dsn=\d+\.\d+\.\d+, )?status=(\S+)(.*)$/o) >= 4)
{
if($opts{'m'} && $addr =~ /^(.*!)*([^!]+)!([^!@]+)@([^\.]+)$/o) {

View File

@ -0,0 +1,328 @@
$OpenBSD: patch_rus-pflogsumm_pl,v 1.1 2005/06/30 13:22:23 jakob Exp $
--- pflogsumm.pl.orig 2004-01-28 14:13:06.000000000 +1000
+++ pflogsumm.pl 2004-01-28 14:39:09.000000000 +1000
@@ -4,13 +4,13 @@ eval 'exec perl -S $0 "$@"'
=head1 NAME
-pflogsumm.pl - Produce Postfix MTA logfile summary
+pflogsumm - Produce Postfix MTA logfile summary
Copyright (C) 1998-2003 by James S. Seymour, Release 1.1.0.
=head1 SYNOPSIS
- pflogsumm.pl -[eq] [-d <today|yesterday>] [-h <cnt>] [-u <cnt>]
+ pflogsumm -[eq] [-d <today|yesterday>] [-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]
@@ -18,7 +18,7 @@ Copyright (C) 1998-2003 by James S. Seym
[--no_smtpd_warnings] [--zero_fill] [--syslog_name=string]
[file1 [filen]]
- pflogsumm.pl -[help|version]
+ pflogsumm -[help|version]
If no file(s) specified, reads from stdin. Output is to stdout.
@@ -119,7 +119,7 @@ Copyright (C) 1998-2003 by James S. Seym
The message may be delivered long-enough after the
(last) qmgr log entry that the information is not in
the log(s) processed by a particular run of
- pflogsumm.pl. This throws off "Recipients by message
+ pflogsumm. This throws off "Recipients by message
size" and the total for "bytes delivered." These are
normally reported by pflogsumm as "Messages with no
size data."
@@ -216,15 +216,15 @@ Copyright (C) 1998-2003 by James S. Seym
Produce a report of previous day's activities:
- pflogsumm.pl -d yesterday /var/log/maillog
+ pflogsumm -d yesterday /var/log/maillog
A report of prior week's activities (after logs rotated):
- pflogsumm.pl /var/log/maillog.0
+ pflogsumm /var/log/maillog.0
What's happened so far today:
- pflogsumm.pl -d today /var/log/maillog
+ pflogsumm -d today /var/log/maillog
Crontab entry to generate a report of the previous day's activity
at 10 minutes after midnight.
@@ -447,7 +447,7 @@ for (0 .. 23) {
$smtpdPerHr[$_] = [0,0,0];
}
-$progName = "pflogsumm.pl";
+$progName = "pflogsumm";
$usageMsg =
"usage: $progName -[eq] [-d <today|yesterday>] [-h <cnt>] [-u <cnt>]
[--verp_mung[=<n>]] [--verbose_msg_detail] [--iso_date_time]
@@ -809,40 +809,40 @@ if(my $msgsTotal = $msgsDlvrd + $msgsRjc
}
if(defined($dateStr)) {
- print "Postfix log summaries for $dateStr\n";
+ print "óÔÁÔÉÓÔÉËÁ ÒÁÂÏÔÙ Postfix ÎÁ $dateStr\n";
}
print "\nGrand Totals\n------------\n";
-print "messages\n\n";
-printf " %6d%s received\n", adj_int_units($msgsRcvd);
-printf " %6d%s delivered\n", adj_int_units($msgsDlvrd);
-printf " %6d%s forwarded\n", adj_int_units($msgsFwdd);
-printf " %6d%s deferred", adj_int_units($msgsDfrd);
-printf " (%d%s deferrals)", adj_int_units($msgsDfrdCnt) if($msgsDfrdCnt);
+print "óÏÏÂÝÅÎÉÊ\n\n";
+printf " %6d%s ÐÒÉÎÑÔÏ\n", adj_int_units($msgsRcvd);
+printf " %6d%s ÄÏÓÔÁ×ÌÅÎÏ\n", adj_int_units($msgsDlvrd);
+printf " %6d%s ÐÅÒÅÎÁÐÒÁ×ÌÅÎÏ\n", adj_int_units($msgsFwdd);
+printf " %6d%s ÏÔÌÏÖÅÎÏ", adj_int_units($msgsDfrd);
+printf " (%d%s ÐÏÐÙÔÏË ÏÔÐÒÁ×ÉÔØ)", adj_int_units($msgsDfrdCnt) if($msgsDfrdCnt);
print "\n";
-printf " %6d%s bounced\n", adj_int_units($msgsBncd);
-printf " %6d%s rejected (%d%%)\n", adj_int_units($msgsRjctd), $msgsRjctdPct;
-printf " %6d%s reject warnings\n", adj_int_units($msgsWrnd);
-printf " %6d%s held\n", adj_int_units($msgsHld);
-printf " %6d%s discarded (%d%%)\n", adj_int_units($msgsDscrdd), $msgsDscrddPct;
+printf " %6d%s ×ÏÚ×ÒÁÝÅÎÏ ÏÔÐÒÁ×ÉÔÅÌÀ\n", adj_int_units($msgsBncd);
+printf " %6d%s ÏÔÂÒÏÛÅÎÏ (%d%%)\n", adj_int_units($msgsRjctd), $msgsRjctdPct;
+printf " %6d%s ÐÒÅÄÕÐÒÅÖÄÅÎÉÊ ÐÏ ÏÔÂÒÏÓÕ\n", adj_int_units($msgsWrnd);
+printf " %6d%s ÕÄÅÒÖÁÎÏ\n", adj_int_units($msgsHld);
+printf " %6d%s ÏÔ×ÅÒÇÎÕÔÏ (%d%%)\n", adj_int_units($msgsDscrdd), $msgsDscrddPct;
print "\n";
-printf " %6d%s bytes received\n", adj_int_units($sizeRcvd);
-printf " %6d%s bytes delivered\n", adj_int_units($sizeDlvrd);
-printf " %6d%s senders\n", adj_int_units($sendgUserCnt);
-printf " %6d%s sending hosts/domains\n", adj_int_units($sendgDomCnt);
-printf " %6d%s recipients\n", adj_int_units($recipUserCnt);
-printf " %6d%s recipient hosts/domains\n", adj_int_units($recipDomCnt);
+printf " %6d%s ÂÁÊÔ ÐÏÌÕÞÅÎÏ\n", adj_int_units($sizeRcvd);
+printf " %6d%s ÂÁÊÔ ÄÏÓÔÁ×ÌÅÎÏ\n", adj_int_units($sizeDlvrd);
+printf " %6d%s ÏÔÐÒÁ×ÉÔÅÌÅÊ\n", adj_int_units($sendgUserCnt);
+printf " %6d%s ÏÔÐÒÁ×ÉÔÅÌÉ ÈÏÓÔÙ/ÄÏÍÅÎÙ\n", adj_int_units($sendgDomCnt);
+printf " %6d%s ÐÏÌÕÞÁÔÅÌÅÊ\n", adj_int_units($recipUserCnt);
+printf " %6d%s ÐÏÌÕÞÁÔÅÌÉ ÈÏÓÔÙ/ÄÏÍÅÎÙ\n", adj_int_units($recipDomCnt);
# ---Begin: SMTPD_STATS_SUPPORT---
if(defined($opts{'smtpdStats'})) {
- print "\nsmtpd\n\n";
- printf " %6d%s connections\n", adj_int_units($smtpdConnCnt);
- printf " %6d%s hosts/domains\n", adj_int_units(int(keys %smtpdPerDom));
- printf " %6d avg. connect time (seconds)\n",
+ print "\n\nóÔÁÔÉÓÔÉËÁ ÄÅÍÏÎÁ smtp\n";
+ printf " %6d%s ÓÏÅÄÉÎÅÎÉÊ\n", adj_int_units($smtpdConnCnt);
+ printf " %6d%s ÈÏÓÔÙ/ÄÏÍÅÎÙ\n", adj_int_units(int(keys %smtpdPerDom));
+ printf " %6d ÓÒÅÄÎÅÅ ×ÒÅÍÑ ÓÏÅÄÉÎÅÎÉÑ (ÓÅËÕÎÄÙ)\n",
$smtpdConnCnt > 0? ($smtpdTotTime / $smtpdConnCnt) + .5 : 0;
{
my ($sec, $min, $hr) = get_smh($smtpdTotTime);
- printf " %2d:%02d:%02d total connect time\n",
+ printf " %2d:%02d:%02d ÏÂÝÅÅ ×ÒÅÍÑ ÓÏÅÄÉÎÅÎÉÊ\n",
$hr, $min, $sec;
}
}
@@ -867,42 +867,42 @@ if(defined($opts{'smtpdStats'})) {
}
# ---End: SMTPD_STATS_SUPPORT---
-print_user_data(\%sendgUser, "Senders by message count", $msgCntI, $opts{'u'}, $opts{'q'});
-print_user_data(\%recipUser, "Recipients by message count", $msgCntI, $opts{'u'}, $opts{'q'});
-print_user_data(\%sendgUser, "Senders by message size", $msgSizeI, $opts{'u'}, $opts{'q'});
-print_user_data(\%recipUser, "Recipients by message size", $msgSizeI, $opts{'u'}, $opts{'q'});
+print_user_data(\%sendgUser, "ïÔÐÒÁ×ÉÔÅÌÉ ÐÏ ËÏÌÉÞÅÓÔ×Õ ÓÏÏÂÝÅÎÉÊ", $msgCntI, $opts{'u'}, $opts{'q'});
+print_user_data(\%recipUser, "ðÏÌÕÞÁÔÅÌÉ ÐÏ ËÏÌÉÞÅÓÔ×Õ ÓÏÏÂÝÅÎÉÊ", $msgCntI, $opts{'u'}, $opts{'q'});
+print_user_data(\%sendgUser, "ïÔÐÒÁ×ÉÔÅÌÉ ÐÏ ÒÁÚÍÅÒÕ ÓÏÏÂÝÅÎÉÊ", $msgSizeI, $opts{'u'}, $opts{'q'});
+print_user_data(\%recipUser, "ðÏÌÕÞÁÔÅÌÉ ÐÏ ÒÁÚÍÅÒÕ ÓÏÏÂÝÅÎÉÊ", $msgSizeI, $opts{'u'}, $opts{'q'});
-print_hash_by_key(\%noMsgSize, "Messages with no size data", 0, 1);
+print_hash_by_key(\%noMsgSize, "óÏÏÂÝÅÎÉÊ ÂÅÚ ÄÁÎÎÙÈ Ï ÒÁÚÍÅÒÅ", 0, 1);
print_problems_reports() unless(defined($opts{'pf'}));
-print_detailed_msg_data(\%msgDetail, "Message detail", $opts{'q'}) if($opts{'e'});
+print_detailed_msg_data(\%msgDetail, "óÏÂÝÅÎÉÑ (ÄÅÔÁÌØÎÏ)", $opts{'q'}) if($opts{'e'});
# Print "problems" reports
sub print_problems_reports {
unless($opts{'noDeferralDetail'}) {
- print_nested_hash(\%deferred, "message deferral detail", $opts{'q'});
+ print_nested_hash(\%deferred, "ïÔÌÏÖÅÎÎÙÅ ÓÏÏÂÝÅÎÉÑ (ÄÅÔÁÌØÎÏ)", $opts{'q'});
}
unless($opts{'noBounceDetail'}) {
- print_nested_hash(\%bounced, "message bounce detail (by relay)", $opts{'q'});
+ print_nested_hash(\%bounced, "÷ÏÚ×ÒÁÝÅÎÏ ÏÔÐÒÁ×ÉÔÅÌÀ (relay)", $opts{'q'});
}
unless($opts{'noRejectDetail'}) {
- print_nested_hash(\%rejects, "message reject detail", $opts{'q'});
- print_nested_hash(\%warns, "message reject warning detail", $opts{'q'});
- print_nested_hash(\%holds, "message hold detail", $opts{'q'});
- print_nested_hash(\%discards, "message discard detail", $opts{'q'});
- }
- print_nested_hash(\%smtpMsgs, "smtp delivery failures", $opts{'q'});
- print_nested_hash(\%warnings, "Warnings", $opts{'q'});
- print_nested_hash(\%fatals, "Fatal Errors", 0, $opts{'q'});
- print_nested_hash(\%panics, "Panics", 0, $opts{'q'});
- print_hash_by_cnt_vals(\%masterMsgs,"Master daemon messages", 0, $opts{'q'});
+ print_nested_hash(\%rejects, "ïÔÂÒÏÛÅÎÎÙÅ ÓÏÏÂÝÅÎÉÑ (ÄÅÔÁÌØÎÏ)", $opts{'q'});
+ print_nested_hash(\%warns, "ðÒÅÄÕÐÒÅÖÄÅÎÉÑ ÐÏ ÏÔÂÒÏÛÅÎÎÙÍ ÓÏÏÂÝÅÎÉÑÍ (ÄÅÔÁÌØÎÏ)", $opts{'q'});
+ print_nested_hash(\%holds, "õÄÅÒÖÁÎÎÙÅ ÓÏÏÂÝÅÎÉÑ (ÄÅÔÁÌØÎÏ)", $opts{'q'});
+ print_nested_hash(\%discards, "ïÔ×ÅÒÇÎÕÔÙÅ ÓÏÏÂÝÅÎÉÑ (ÄÅÔÁÌØÎÏ)", $opts{'q'});
+ }
+ print_nested_hash(\%smtpMsgs, "ïÛÉÂËÉ ÄÏÓÔÁ×ËÉ ÐÏ smtp", $opts{'q'});
+ print_nested_hash(\%warnings, "ðÒÅÄÕÐÒÅÖÄÅÎÉÑ", $opts{'q'});
+ print_nested_hash(\%fatals, "æÁÔÁÌØÎÙÅ ÏÛÉÂËÉ", 0, $opts{'q'});
+ print_nested_hash(\%panics, "ðÁÎÉËÁ", 0, $opts{'q'});
+ print_hash_by_cnt_vals(\%masterMsgs,"óÏÏÂÝÅÎÉÑ ÇÌÁ×ÎÏÇÏ ÄÅÍÏÎÁ", 0, $opts{'q'});
}
if($opts{'mailq'}) {
# flush stdout first cuz of asynchronousity
$| = 1;
- print "\nCurrent Mail Queue\n------------------\n";
+ print "\nóÏÓÔÏÑÎÉÅ ÐÏÞÔÏ×ÏÊ ÏÞÅÒÅÄÉ\n------------------\n";
system($mailqCmd);
}
@@ -913,9 +913,9 @@ sub print_per_day_summary {
my $value;
print <<End_Of_Per_Day_Heading;
-Per-Day Traffic Summary
- date received delivered deferred bounced rejected
- --------------------------------------------------------------------
+óÕÍÍÁÒÎÙÊ ÔÒÁÆÆÉË ÐÏ ÄÎÑÍ
+ äÁÔÁ ÐÏÌÕÞÅÎÏ ÄÏÓÔÁ×ÌÅÎÏ ÏÔÌÏÖÅÎÏ ×ÏÚ×ÒÁÝÅÎÏ ÏÔÂÒÏÛÅÎÏ
+ ------------------------------------------------------------------------
End_Of_Per_Day_Heading
foreach (sort { $a <=> $b } keys(%$msgsPerDay)) {
@@ -938,20 +938,20 @@ End_Of_Per_Day_Heading
# (done in a subroutine only to keep main-line code clean)
sub print_per_hour_summary {
my ($rcvPerHr, $dlvPerHr, $dfrPerHr, $bncPerHr, $rejPerHr, $dayCnt) = @_;
- my $reportType = $dayCnt > 1? 'Daily Average' : 'Summary';
+ my $reportType = $dayCnt > 1? 'óÒÅÄÎÉÊ ÚÁ ÄÅÎØ' : 'óÕÍÍÁÒÎÙÊ';
my ($hour, $value);
print <<End_Of_Per_Hour_Heading;
-Per-Hour Traffic $reportType
- time received delivered deferred bounced rejected
- --------------------------------------------------------------------
+$reportType ÐÏÞÁÓÏ×ÏÊ ÔÒÁÆÉË
+ ÷ÒÅÍÑ ÐÏÌÕÞÅÎÏ ÄÏÓÔÁ×ÌÅÎÏ ÏÔÌÏÖÅÎÏ ×ÏÚ×ÒÁÝÅÎÏ ÏÔÂÒÏÛÅÎÏ
+ -------------------------------------------------------------------------
End_Of_Per_Hour_Heading
for($hour = 0; $hour < 24; ++$hour) {
if($isoDateTime) {
- printf " %02d:00-%02d:00", $hour, $hour + 1;
+ printf "%02d:00-%02d:00", $hour, $hour + 1;
} else {
- printf " %02d00-%02d00 ", $hour, $hour + 1;
+ printf "%02d00-%02d00 ", $hour, $hour + 1;
}
foreach $value (@$rcvPerHr[$hour], @$dlvPerHr[$hour],
@$dfrPerHr[$hour], @$bncPerHr[$hour],
@@ -972,13 +972,15 @@ sub print_recip_domain_summary {
local($hashRef) = $_[0];
my($cnt) = $_[1];
return if($cnt == 0);
- my $topCnt = $cnt > 0? "(top $cnt)" : "";
+ my $topCnt = $cnt > 0? "(ÎÅ ÏÔÏÂÒÁÖÁÔØ ÂÏÌÅÅ $cnt ÚÁÐÉÓÅÊ)" : "";
my $avgDly;
print <<End_Of_Recip_Domain_Heading;
-Host/Domain Summary: Message Delivery $topCnt
- sent cnt bytes defers avg dly max dly host/domain
- -------- ------- ------- ------- ------- -----------
+äÏÓÔÁ×ËÁ ÓÏÏÂÝÅÎÉÊ èÏÓÔ/äÏÍÅÎ $topCnt
+ ÏÔÐÒÁ×ÌÅÎÏ ÂÁÊÔ ÏÔÌÏÖÅÎÏ ÓÒ. ×ÒÅÍÑ ÍÁËÓ. ×ÒÅÍÑ ÈÏÓÔ/ÄÏÍÅÎ
+ ÓÏÏÂÝÅÎÉÊ ÓÏÏÂÝÅÎÉÊ
+ ---------- ---- --------- --------- ----------- ----------
+
End_Of_Recip_Domain_Heading
foreach (reverse sort by_count_then_size keys(%$hashRef)) {
@@ -989,7 +991,7 @@ End_Of_Recip_Domain_Heading
} else {
$avgDly = 0;
}
- printf " %6d%s %6d%s %6d%s %5.1f %s %5.1f %s %s\n",
+ printf " %6d%s %6d%s %6d%s %5.1f %s %5.1f %s %s\n",
adj_int_units(${$hashRef->{$_}}[$msgCntI]),
adj_int_units(${$hashRef->{$_}}[$msgSizeI]),
adj_int_units(${$hashRef->{$_}}[$msgDfrsI]),
@@ -1010,13 +1012,14 @@ sub print_sending_domain_summary {
my $topCnt = $cnt > 0? "(top $cnt)" : "";
print <<End_Of_Sender_Domain_Heading;
-Host/Domain Summary: Messages Received $topCnt
- msg cnt bytes host/domain
- -------- ------- -----------
+ðÏÌÕÞÁÔÅÌÉ ÓÏÏÂÝÅÎÉÊ èÏÓÔ/äÏÍÅÎ $topCnt
+ ÐÏÌÕÞÅÎÏ ÂÁÊÔ ÈÏÓÔ/ÄÏÍÅÎ
+ ÓÏÏÂÝÅÎÉÊ
+ -------- ------- -------
End_Of_Sender_Domain_Heading
foreach (reverse sort by_count_then_size keys(%$hashRef)) {
- printf " %6d%s %6d%s %s\n",
+ printf " %6d%s %6d%s %s\n",
adj_int_units(${$hashRef->{$_}}[$msgCntI]),
adj_int_units(${$hashRef->{$_}}[$msgSizeI]),
$_;
@@ -1030,10 +1033,10 @@ sub print_user_data {
my($hashRef, $title, $index, $cnt, $quiet) = @_;
my $dottedLine;
return if($cnt == 0);
- $title = sprintf "%s%s", $cnt > 0? "top $cnt " : "", $title;
+ $title = sprintf "%s (%s)", $title, $cnt > 0? "ÎÅ ÏÔÏÂÒÁÖÁÔØ ÂÏÌÅÅ $cnt ÚÁÐÉÓÅÊ " : "";
unless(%$hashRef) {
return if($quiet);
- $dottedLine = ": none";
+ $dottedLine = ": ÎÅÔ";
} else {
$dottedLine = "\n" . "-" x length($title);
}
@@ -1172,7 +1175,7 @@ sub print_hash_by_cnt_vals {
$title = sprintf "%s%s", $cnt? "top $cnt " : "", $title;
unless(%$hashRef) {
return if($quiet);
- $dottedLine = ": none";
+ $dottedLine = ": ÎÅÔ";
} else {
$dottedLine = "\n" . "-" x length($title);
}
@@ -1187,7 +1190,7 @@ sub print_hash_by_key {
$title = sprintf "%s%s", $cnt? "first $cnt " : "", $title;
unless(%$hashRef) {
return if($quiet);
- $dottedLine = ": none";
+ $dottedLine = ": ÎÅÔ";
} else {
$dottedLine = "\n" . "-" x length($title);
}
@@ -1205,7 +1208,7 @@ sub print_nested_hash {
my $dottedLine;
unless(%$hashRef) {
return if($quiet);
- $dottedLine = ": none";
+ $dottedLine = ": ÎÅÔ";
} else {
$dottedLine = "\n" . "-" x length($title);
}
@@ -1249,7 +1252,7 @@ sub print_detailed_msg_data {
my $dottedLine;
unless(%$hashRef) {
return if($quiet);
- $dottedLine = ": none";
+ $dottedLine = ": ÎÅÔ";
} else {
$dottedLine = "\n" . "-" x length($title);
}