X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Feximstats.src;h=4edb7e54b24fc6ebb004917f7f0edd2812c11015;hp=88eb69fe83b3d849b59d3c965cd5139704340f28;hb=b322aac87b2d3e5a1cc4f3ebdee2fd81651bdd7c;hpb=f3f065bbe8b7d7fdc4d46dbfa063ae4dfb05bfd7;ds=sidebyside diff --git a/src/src/eximstats.src b/src/src/eximstats.src index 88eb69fe8..4edb7e54b 100644 --- a/src/src/eximstats.src +++ b/src/src/eximstats.src @@ -1,5 +1,4 @@ #!PERL_COMMAND -w -# $Cambridge: exim/src/src/eximstats.src,v 1.13 2007/01/31 16:52:12 ph10 Exp $ # Copyright (c) 2001 University of Cambridge. # See the file NOTICE for conditions of use and distribution. @@ -263,6 +262,28 @@ # 2007-01-31 V1.53 Philip Hazel # Allow for [pid] after date in log lines # +# 2007-02-14 V1.54 Daniel Tiefnig +# Improved the '($parent) =' pattern match. +# +# 2007-03-19 V1.55 Steve Campbell +# Differentiate between permanent and temporary rejects. +# +# 2007-03-29 V1.56 Jez Hancock +# Fixed some broken HTML links and added missing column headers. +# +# 2007-03-30 V1.57 Steve Campbell +# Fixed Grand Total Summary Domains, Edomains, and Email columns +# for Rejects, Temp Rejects, Ham, and Spam rows. +# +# 2007-04-11 V1.58 Steve Campbell +# Fix to get <> and blackhole to show in edomain tables. +# +# 2007-09-20 V1.59 Steve Campbell +# Added the -bylocaldomain option +# +# 2007-09-20 V1.60 Heiko Schlittermann +# Fix for misinterpreted log lines +# # # # For documentation on the logfile format, see @@ -367,7 +388,7 @@ Useful for finding out which of your mailing lists are receiving mail. Show the delivery times (B
)for all the messages. -Exim must have been configured to use the +delivery_time logging option +Exim must have been configured to use the +deliver_time logging option for this option to work. I is an optional list of times. Eg -show_dt1,2,4,8 will show @@ -518,7 +539,7 @@ mailing list exim-users@exim.org. This program does not perfectly handle messages whose received and delivered log lines are in different files, which can happen when you have multiple mail servers and a message cannot be -immeadiately delivered. Fixing this could be tricky... +immediately delivered. Fixing this could be tricky... Merging of xls files is not (yet) possible. Be free to implement :) @@ -561,7 +582,7 @@ use vars qw($WEEK $DAY $HOUR $MINUTE); @days_per_month = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334); $gig = 1024 * 1024 * 1024; -$VERSION = '1.53'; +$VERSION = '1.60'; # How much space do we allow for the Hosts/Domains/Emails/Edomains column headers? $COLUMN_WIDTHS = 8; @@ -589,6 +610,7 @@ use vars qw($spam_score $spam_score_gigs); use vars qw($ham_score $ham_score_gigs); use vars qw(%ham_count_by_ip %spam_count_by_ip); use vars qw(%rejected_count_by_ip %rejected_count_by_reason); +use vars qw(%temporarily_rejected_count_by_ip %temporarily_rejected_count_by_reason); #For use in Speadsheed::WriteExcel use vars qw($workbook $ws_global $ws_relayed $ws_errors); @@ -604,7 +626,7 @@ $ntopchart = 5; # The following are parameters whose values are # set by command line switches: use vars qw($show_errors $show_relay $show_transport $transport_pattern); -use vars qw($topcount $local_league_table $include_remote_users); +use vars qw($topcount $local_league_table $include_remote_users $do_local_domain); use vars qw($hist_opt $hist_interval $hist_number $volume_rounding $emptyOK); use vars qw($relay_pattern @queue_times @user_patterns @user_descriptions); use vars qw(@rcpt_times @delivery_times); @@ -623,6 +645,7 @@ use vars qw(%received_count %received_data %received_data_gigs); use vars qw(%delivered_messages %delivered_data %delivered_data_gigs %delivered_addresses); use vars qw(%received_count_user %received_data_user %received_data_gigs_user); use vars qw(%delivered_messages_user %delivered_addresses_user %delivered_data_user %delivered_data_gigs_user); +use vars qw(%delivered_messages_local_domain %delivered_addresses_local_domain %delivered_data_local_domain %delivered_data_gigs_local_domain); use vars qw(%transported_count %transported_data %transported_data_gigs); use vars qw(%relayed %errors_count $message_errors); use vars qw(@qt_all_bin @qt_remote_bin); @@ -1346,7 +1369,8 @@ sub print_league_table { # Generate the printf formats and table headers. ################################################ my(@headers) = ('Messages'); - push(@headers,'Addresses') if defined $a_count; + #push(@headers,'Addresses') if defined $a_count; + push(@headers,'Addresses') if defined $a_count && %$a_count; push(@headers,'Bytes','Average') if defined $m_data; my $txt_format = "%10s " x @headers . " %s\n"; @@ -1368,7 +1392,7 @@ sub print_league_table { EoText - print $htm_col_headers; + print $htm_fh $htm_col_headers } if ($xls_fh) { @@ -1467,7 +1491,7 @@ EoText
EoText - print $htm_col_headers; + print $htm_fh $htm_col_headers; } if ($xls_fh) { $spreadsheet->write(${$row_sref}++, 0, $title, $f_header2); @@ -1768,6 +1792,7 @@ Valid options are: -bydomain show results by sending domain. -byemail show results by sender's email address -byedomain show results by sender's email domain +-bylocaldomain show results by local domain -pattern "Description" /pattern/ Count lines matching specified patterns and show them in @@ -1813,7 +1838,7 @@ sub generate_parser { my $parser = ' my($ip,$host,$email,$edomain,$domain,$thissize,$size,$old,$new); my($tod,$m_hour,$m_min,$id,$flag,$extra,$length); - my($seconds,$queued,$rcpt_time); + my($seconds,$queued,$rcpt_time,$local_domain); my $rej_id = 0; while (<$fh>) { @@ -1899,13 +1924,22 @@ sub generate_parser { # "H=Host (UnverifiedHost) [IpAddr]" or "H=(UnverifiedHost) [IpAddr]". # We do 2 separate matches to keep the matches simple and fast. # Host is local unless otherwise specified. - $ip = (/\\bH=.*?(\\[[^]]+\\])/) ? $1 : "local"; + $ip = (/\\bH=.*?(\\[[^]]+\\])/) ? $1 + # 2008-03-31 06:25:22 Connection from [213.246.33.217]:39456 refused: too many connections from that IP address // .hs + : (/Connection from (\[\S+\])/) ? $1 + # 2008-03-31 06:52:40 SMTP call from mail.cacoshrf.com (ccsd02.ccsd.local) [69.24.118.229]:4511 dropped: too many nonmail commands (last was "RSET") // .hs + : (/SMTP call from .*?(\[\S+\])/) ? $1 + : "local"; $host = (/\\bH=(\\S+)/) ? $1 : "local"; $domain = "localdomain"; #Domain is localdomain unless otherwise specified. #IFDEF ($do_sender{Domain}) - if ($host !~ /^\\[/ && $host =~ /^(\\(?)[^\\.]+\\.([^\\.]+\\..*)/) { + if ($host =~ /^\\[/ || $host =~ /^[\\d\\.]+$/) { + # Host is just an IP address. + $domain = $host; + } + elsif ($host =~ /^(\\(?)[^\\.]+\\.([^\\.]+\\..*)/) { # Remove the host portion from the DNS name. We ensure that we end up # with at least xxx.yyy. $host can be "(x.y.z)" or "x.y.z". $domain = lc("$1.$2"); @@ -1927,16 +1961,25 @@ sub generate_parser { #ENDIF ($do_sender{Email}) #IFDEF ($do_sender{Edomain}) + if (/^(<>|blackhole)/) { + $edomain = $1; + } #IFDEF ($include_original_destination) - #$edomain = (/^(\S+) (<\S*?\\@(\S+)>)?/) ? $3 || $1 : ""; - $edomain = (/^(\S+ (<\S*?\\@(\S+?)>)?)/) ? $1 : ""; - chomp($edomain); - lc($edomain); + elsif (/^(\S+ (<\S*?\\@(\S+?)>)?)/) { + $edomain = $1; + chomp($edomain); + $edomain =~ s/@(\S+?)>/"@" . lc($1) . ">"/e; + } #ENDIF ($include_original_destination) - #IFNDEF ($include_original_destination) - $edomain = (/^\S*?\\@(\S+)/) ? lc($1) : ""; + elsif (/^\S*?\\@(\S+)/) { + $edomain = lc($1); + } #ENDIF ($include_original_destination) + else { + $edomain = ""; + } + #ENDIF ($do_sender{Edomain}) if ($tod lt $begin) { @@ -2076,8 +2119,19 @@ sub generate_parser { #IFNDEF ($include_original_destination) if ($user =~ /^[\\/|]/) { #ENDIF ($include_original_destination) - my($parent) = $_ =~ /(<[^@]+@?[^>]*>)/; - $user = "$user $parent" if defined $parent; + #my($parent) = $_ =~ /(<[^@]+@?[^>]*>)/; + my($parent) = $_ =~ / (<.+?>) /; #DT 1.54 + if (defined $parent) { + $user = "$user $parent"; + #IFDEF ($do_local_domain) + if ($parent =~ /\\@(.+)>/) { + $local_domain = lc($1); + ++$delivered_messages_local_domain{$local_domain}; + ++$delivered_addresses_local_domain{$local_domain}; + add_volume(\\$delivered_data_local_domain{$local_domain},\\$delivered_data_gigs_local_domain{$local_domain},$size); + } + #ENDIF ($do_local_domain) + } } ++$delivered_messages_user{$user}; ++$delivered_addresses_user{$user}; @@ -2164,7 +2218,8 @@ sub generate_parser { #IFNDEF ($include_original_destination) if ($user =~ /^[\\/|]/) { #ENDIF ($include_original_destination) - my($parent) = $_ =~ /(<[^@]+@?[^>]*>)/; + #my($parent) = $_ =~ /(<[^@]+@?[^>]*>)/; + my($parent) = $_ =~ / (<.+?>) /; #DT 1.54 $user = "$user $parent" if defined $parent; } ++$delivered_addresses_user{$user}; @@ -2285,9 +2340,21 @@ sub generate_parser { # rejected EHLO from my.test.net [10.0.0.5]: syntactically invalid argument(s): # rejected EHLO from [10.0.0.6]: syntactically invalid argument(s): $ip = $1 if ($ip eq "local" && /^rejected [HE][HE]LO from .*?(\[.+?\]):/); - ++$rejected_count_by_ip{$ip}; if (/SpamAssassin/) { ++$rejected_count_by_reason{"Rejected by SpamAssassin"}; + ++$rejected_count_by_ip{$ip}; + } + elsif ( + /(temporarily rejected [A-Z]*) .*?(: .*?)(:|\s*$)/ + ) { + ++$temporarily_rejected_count_by_reason{"\u$1$2"}; + ++$temporarily_rejected_count_by_ip{$ip}; + } + elsif ( + /(temporarily refused connection)/ + ) { + ++$temporarily_rejected_count_by_reason{"\u$1"}; + ++$temporarily_rejected_count_by_ip{$ip}; } elsif ( /(listed at [^ ]+)/ || @@ -2299,6 +2366,7 @@ sub generate_parser { # 2005-09-23 15:07:49 1EInHJ-0007Ex-Au H=(a.b.c) [10.0.0.1] F=<> rejected after DATA: This message contains a virus: (Eicar-Test-Signature) please scan your system. # 2005-10-06 10:50:07 1ENRS3-0000Nr-Kt => blackhole (DATA ACL discarded recipients): This message contains a virus: (Worm.SomeFool.P) please scan your system. / rejected after DATA: (.*)/ || + / (rejected DATA: .*)/ || /.DATA ACL discarded recipients.: (.*)/ || /rejected after DATA: (unqualified address not permitted)/ || /(VRFY rejected)/ || @@ -2314,18 +2382,20 @@ sub generate_parser { # local_scan() function crashed with signal %d - message temporarily rejected # local_scan() function timed out - message temporarily rejected /(local_scan.. function .* - message temporarily rejected)/ || - /(temporarily refused connection)/ || # SMTP protocol synchronization error (input sent without waiting for greeting): rejected connection from %s /(SMTP protocol .*?(error|violation))/ || /(message too big)/ ) { ++$rejected_count_by_reason{"\u$1"}; + ++$rejected_count_by_ip{$ip}; } elsif (/rejected [HE][HE]LO from [^:]*: syntactically invalid argument/) { ++$rejected_count_by_reason{"Rejected HELO/EHLO: syntactically invalid argument"}; + ++$rejected_count_by_ip{$ip}; } elsif (/response to "RCPT TO.*? was: (.*)/) { ++$rejected_count_by_reason{"Response to RCPT TO was: $1"}; + ++$rejected_count_by_ip{$ip}; } elsif ( /(lookup of host )\S+ (failed)/ || @@ -2353,9 +2423,19 @@ sub generate_parser { /: (Connection refused)()/ ) { ++$rejected_count_by_reason{"\u$1$2"}; + ++$rejected_count_by_ip{$ip}; + } + elsif ( + # 2008-03-31 06:25:22 H=mail.densitron.com [216.70.140.224]:45386 temporarily rejected connection in "connect" ACL: too fast reconnects // .hs + # 2008-03-31 06:25:22 H=mail.densitron.com [216.70.140.224]:45386 temporarily rejected connection in "connect" ACL // .hs + /(temporarily rejected connection in .*?ACL:?.*)/ + ) { + ++$temporarily_rejected_count_by_ip{$ip}; + ++$temporarily_rejected_count_by_reason{"\u$1"}; } else { ++$rejected_count_by_reason{Unknown}; + ++$rejected_count_by_ip{$ip}; print STDERR "Unknown rejection: $_" if $debug; } } @@ -2432,9 +2512,9 @@ sub print_header { if ($htm_fh) { print $htm_fh html_header($title); print $htm_fh ""; - $sender_txt_format .= " " x ($COLUMN_WIDTHS - 5) . "%6d"; + $sender_html_format .= ""; + $sender_txt_format .= " " x ($COLUMN_WIDTHS - 5) . "%6s"; push(@col_headers,"${_}s"); } @@ -2538,7 +2623,7 @@ sub print_grandtotals { print $txt_fh " TOTAL Volume Messages Addresses $sender_txt_header Delayed Failed\n"; } if ($htm_fh) { - print $htm_fh "\n"; + print $htm_fh "\n"; print $htm_fh "

Grand total summary

\n"; print $htm_fh "
%d%s
\n"; print $htm_fh "\n"; @@ -2612,12 +2697,17 @@ sub print_grandtotals { } if ($merge_reports) { - foreach ('Rejects', 'Ham', 'Spam') { + foreach ('Rejects', 'Temp Rejects', 'Ham', 'Spam') { my $messages = get_report_total($report_totals{$_},'Messages'); my $addresses = get_report_total($report_totals{$_},'Addresses'); if ($messages) { @content = ($_, '', $messages, ''); push(@content,get_report_total($report_totals{$_},'Hosts')) if $do_sender{Host}; + #These rows do not have entries for the following columns (if specified) + foreach ('Domain','Email','Edomain') { + push(@content,'') if $do_sender{$_}; + } + printf $txt_fh ("$txt_format1\n", @content) if $txt_fh; printf $htm_fh ("$htm_format1\n", @content) if $htm_fh; $ws_global->write(++$row, 0, \@content) if $xls_fh; @@ -2626,15 +2716,24 @@ sub print_grandtotals { } else { foreach my $total_aref (['Rejects',\%rejected_count_by_ip], + ['Temp Rejects',\%temporarily_rejected_count_by_ip], ['Ham',\%ham_count_by_ip], ['Spam',\%spam_count_by_ip]) { + #Count the number of messages of this type. my $messages = 0; map {$messages += $_} values %{$total_aref->[1]}; if ($messages > 0) { @content = ($total_aref->[0], '', $messages, ''); + + #Count the number of distict IPs for the Hosts column. push(@content,scalar(keys %{$total_aref->[1]})) if $do_sender{Host}; + #These rows do not have entries for the following columns (if specified) + foreach ('Domain','Email','Edomain') { + push(@content,'') if $do_sender{$_}; + } + printf $txt_fh ("$txt_format1\n", @content) if $txt_fh; printf $htm_fh ("$htm_format1\n", @content) if $htm_fh; $ws_global->write(++$row, 0, \@content) if $xls_fh; @@ -2665,7 +2764,7 @@ sub print_user_patterns { print $txt_fh "\n Total\n"; } if ($htm_fh) { - print $htm_fh "

User Specified Patterns

\n"; + print $htm_fh "

User Specified Patterns

\n"; print $htm_fh "
" . join('',@col_headers) . "At least one addr
Delayed
At least one addr
Failed
\n"; print $htm_fh "
\n"; print $htm_fh "\n"; @@ -2812,7 +2911,7 @@ sub print_transport { print $txt_fh "\n Volume Messages\n"; } if ($htm_fh) { - print $htm_fh "

Deliveries by Transport

\n"; + print $htm_fh "

Deliveries by Transport

\n"; print $htm_fh "
\n"; print $htm_fh "\n"; } @@ -3138,7 +3237,7 @@ sub parse_old_eximstat_reports { add_to_totals($report_totals{Delivered},['Addresses'],$tmp{Messages}); } } - elsif (/(Rejects|Ham|Spam)\s+(.*?)\s*$/) { + elsif (/(Temp Rejects|Rejects|Ham|Spam)\s+(.*?)\s*$/) { print STDERR "Parsing $_" if $debug; add_to_totals($report_totals{$1},['Messages','Hosts'],$2); } @@ -3350,6 +3449,12 @@ sub parse_old_eximstat_reports { $data_href = \%delivered_data_user; $data_gigs_href = \%delivered_data_gigs_user; } + elsif ($category =~ /local domain destination/) { + $messages_href = \%delivered_messages_local_domain; + $addresses_href = \%delivered_addresses_local_domain; + $data_href = \%delivered_data_local_domain; + $data_gigs_href = \%delivered_data_gigs_local_domain; + } elsif ($category =~ /(\S+) destination/) { #Top 50 (host|domain|email|edomain) destinations #Top (host|domain|email|edomain) destination @@ -3358,12 +3463,18 @@ sub parse_old_eximstat_reports { $data_href = \%{$delivered_data{"\u$1"}}; $data_gigs_href = \%{$delivered_data_gigs{"\u$1"}}; } + elsif ($category =~ /temporarily rejected ips/) { + $messages_href = \%temporarily_rejected_count_by_ip; + } elsif ($category =~ /rejected ips/) { $messages_href = \%rejected_count_by_ip; } elsif ($category =~ /non-rejected spamming ips/) { $messages_href = \%spam_count_by_ip; } + elsif ($category =~ /mail temporary rejection reasons/) { + $messages_href = \%temporarily_rejected_count_by_reason; + } elsif ($category =~ /mail rejection reasons/) { $messages_href = \%rejected_count_by_reason; } @@ -3809,6 +3920,7 @@ while (@ARGV > 0 && substr($ARGV[0], 0, 1) eq '-') { elsif ($ARGV[0] =~ /^-byemail$/) { $do_sender{Email} = 1 } elsif ($ARGV[0] =~ /^-byemaildomain$/) { $do_sender{Edomain} = 1 } elsif ($ARGV[0] =~ /^-byedomain$/) { $do_sender{Edomain} = 1 } + elsif ($ARGV[0] =~ /^-bylocaldomain$/) { $do_local_domain = 1 } elsif ($ARGV[0] =~ /^-emptyok$/) { $emptyOK = 1 } elsif ($ARGV[0] =~ /^-nvr$/) { $volume_rounding = 0 } elsif ($ARGV[0] =~ /^-show_rt([,\d\+\-\*\/]+)?$/) { @rcpt_times = parse_time_list($1) } @@ -3959,7 +4071,7 @@ $message_errors = 0; $begin = "9999-99-99 99:99:99"; $end = "0000-00-00 00:00:00"; my($section,$type); -foreach $section ('Received','Delivered','Rejects','Ham','Spam') { +foreach $section ('Received','Delivered','Temp Rejects', 'Rejects','Ham','Spam') { foreach $type ('Volume','Messages','Delayed','Failed','Hosts','Domains','Emails','Edomains') { $report_totals{$section}{$type} = 0; } @@ -4051,14 +4163,16 @@ print_relay() if $show_relay; # Print the league tables, if topcount isn't zero. if ($topcount > 0) { - my($ws_rej, $ws_top50, $ws_rej_row, $ws_top50_row); - $ws_rej_row = $ws_top50_row = 0; + my($ws_rej, $ws_top50, $ws_rej_row, $ws_top50_row, $ws_temp_rej, $ws_temp_rej_row); + $ws_rej_row = $ws_temp_rej_row = $ws_top50_row = 0; if ($xls_fh) { $ws_top50 = $workbook->addworksheet('Deliveries'); $ws_rej = $workbook->addworksheet('Rejections') if (%rejected_count_by_reason || %rejected_count_by_ip || %spam_count_by_ip); + $ws_temp_rej = $workbook->addworksheet('Temporary Rejections') if (%temporarily_rejected_count_by_reason || %temporarily_rejected_count_by_ip); } print_league_table("mail rejection reason", \%rejected_count_by_reason, undef, undef, undef, $ws_rej, \$ws_rej_row) if %rejected_count_by_reason; + print_league_table("mail temporary rejection reason", \%temporarily_rejected_count_by_reason, undef, undef, undef, $ws_temp_rej, \$ws_temp_rej_row) if %temporarily_rejected_count_by_reason; foreach ('Host','Domain','Email','Edomain') { next unless $do_sender{$_}; @@ -4072,8 +4186,10 @@ if ($topcount > 0) { print_league_table("\l$_ destination", $delivered_messages{$_}, $delivered_addresses{$_}, $delivered_data{$_},$delivered_data_gigs{$_}, $ws_top50, \$ws_top50_row); } print_league_table("local destination", \%delivered_messages_user, \%delivered_addresses_user, \%delivered_data_user,\%delivered_data_gigs_user, $ws_top50, \$ws_top50_row) if (($local_league_table || $include_remote_users) && %delivered_messages_user); + print_league_table("local domain destination", \%delivered_messages_local_domain, \%delivered_addresses_local_domain, \%delivered_data_local_domain,\%delivered_data_gigs_local_domain, $ws_top50, \$ws_top50_row) if (($local_league_table || $include_remote_users) && %delivered_messages_local_domain); print_league_table("rejected ip", \%rejected_count_by_ip, undef, undef, undef, $ws_rej, \$ws_rej_row) if %rejected_count_by_ip; + print_league_table("temporarily rejected ip", \%temporarily_rejected_count_by_ip, undef, undef, undef, $ws_rej, \$ws_rej_row) if %temporarily_rejected_count_by_ip; print_league_table("non-rejected spamming ip", \%spam_count_by_ip, undef, undef, undef, $ws_rej, \$ws_rej_row) if %spam_count_by_ip; }
 VolumeMessages