$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);
     }
