Package: pflogsumm Version: 1.1.0-3 Severity: wishlist Hi,
Reading about every blacklisted host that's tried to send us spam recently isn't much fun, so limiting it to the top offenders is useful. The attached patch adds a new option --top_reject=<cnt> which limits the number of addresses shown in the reject detail. Cheers, Brian -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (990, 'testing'), (500, 'unstable') Architecture: i386 (i486) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.15-1-486 Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Versions of packages pflogsumm depends on: ii libdate-calc-perl 5.4-4 Perl library for accessing dates ii perl [perl5] 5.8.8-4 Larry Wall's Practical Extraction pflogsumm recommends no packages. -- no debconf information
diff -ur pflogsumm-1.1.0/pflogsumm.pl detail/pflogsumm.pl --- pflogsumm-1.1.0/pflogsumm.pl 2006-04-25 21:55:08.000000000 +0100 +++ detail/pflogsumm.pl 2006-04-25 23:07:44.000000000 +0100 @@ -16,7 +16,7 @@ [--problems_first] [--rej_add_from] [--no_bounce_detail] [--no_deferral_detail] [--no_reject_detail] [--no_no_msg_size] [--no_smtpd_warnings] [--zero_fill] [--syslog_name=string] - [file1 [filen]] + [--top_reject=<cnt>] [file1 [filen]] pflogsumm.pl -[help|version] @@ -52,8 +52,8 @@ 0 = none. - See also: "-u" and "--no_*_detail" for further - report-limiting options. + See also: "-u", "--no_*_detail" and "--top_reject" + for further report-limiting options. --help Emit short usage message and bail out. @@ -108,8 +108,8 @@ message deferral detail message reject detail - See also: "-u" and "-h" for further report-limiting - options. + See also: "-u", "-h", and "--top_reject" for further + report-limiting options. --no_no_msg_size @@ -167,10 +167,15 @@ See the discussion about the use of this option under "NOTES," below. + --top_reject=<cnt> + + top <cnt> to display in reject detail reports. + 0 == none. + -u <cnt> top <cnt> to display in user reports. 0 == none. - See also: "-h" and "--no_*_detail" for further - report-limiting options. + See also: "-h", "--no_*_detail" and "--top_reject" for + further report-limiting options. --verbose_msg_detail @@ -455,7 +460,7 @@ [--problems_first] [--rej_add_from] [--no_bounce_detail] [--no_deferral_detail] [--no_reject_detail] [--no_no_msg_size] [--no_smtpd_warnings] [--zero_fill] [--syslog_name=name] - [file1 [filen]] + [--top_reject=<cnt>] [file1 [filen]] $progName --[version|help]"; @@ -486,7 +491,8 @@ "verbose_msg_detail" => \$opts{'verbMsgDetail'}, "verp_mung:i" => \$opts{'verpMung'}, "version" => \$opts{'version'}, - "zero_fill" => \$opts{'zeroFill'} + "zero_fill" => \$opts{'zeroFill'}, + "top_reject=i" => \$opts{'topRejects'} ) || die "$usageMsg\n"; # internally: 0 == none, undefined == -1 == all @@ -887,7 +893,7 @@ print_nested_hash(\%bounced, "message bounce detail (by relay)", $opts{'q'}); } unless($opts{'noRejectDetail'}) { - print_nested_hash(\%rejects, "message reject detail", $opts{'q'}); + print_nested_hash(\%rejects, "message reject detail", $opts{'q'}, $opts{'topRejects'}); 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'}); @@ -1201,8 +1207,9 @@ # print "nested" hashes sub print_nested_hash { - my($hashRef, $title, $quiet) = @_; + my($hashRef, $title, $quiet, $top) = @_; my $dottedLine; + $top = 0 unless(defined($top)); unless(%$hashRef) { return if($quiet); $dottedLine = ": none"; @@ -1210,12 +1217,12 @@ $dottedLine = "\n" . "-" x length($title); } printf "\n$title$dottedLine\n"; - walk_nested_hash($hashRef, 0); + walk_nested_hash($hashRef, 0, $top); } # "walk" a "nested" hash sub walk_nested_hash { - my ($hashRef, $level) = @_; + my ($hashRef, $level, $top) = @_; $level += 2; my $indents = ' ' x $level; my ($keyName, $hashVal) = each(%$hashRef); @@ -1230,13 +1237,14 @@ unless(ref($hashVal2) eq 'HASH') { my $cnt = 0; $cnt += $_ foreach (values %{$hashRef->{$_}}); + print " (top $top)" if $top > 0; print " (total: $cnt)"; } print "\n"; - walk_nested_hash($hashRef->{$_}, $level); + walk_nested_hash($hashRef->{$_}, $level, $top); } } else { - really_print_hash_by_cnt_vals($hashRef, 0, $indents); + really_print_hash_by_cnt_vals($hashRef, $top, $indents); } }