diff options
author | Steve Campbell <steve@computurn.com> | 2005-02-16 15:49:36 +0000 |
---|---|---|
committer | Steve Campbell <steve@computurn.com> | 2005-02-16 15:49:36 +0000 |
commit | 50adf73a391c3c0c6485d531c315257288168696 (patch) | |
tree | 430b0cae6bc01138d373ebe584ebae3087c4b41e /src | |
parent | bb6e88ff38009f30d0483414fcabc97f00042f17 (diff) |
Added Gregor Herrmann's code to show the average sizes in the HTML top tables.
Diffstat (limited to 'src')
-rw-r--r-- | src/src/eximstats.src | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/src/eximstats.src b/src/src/eximstats.src index ed042e451..e013b9713 100644 --- a/src/src/eximstats.src +++ b/src/src/eximstats.src @@ -1,5 +1,5 @@ #!PERL_COMMAND -w -# $Cambridge: exim/src/src/eximstats.src,v 1.4 2004/12/21 11:33:55 steve Exp $ +# $Cambridge: exim/src/src/eximstats.src,v 1.5 2005/02/16 15:49:36 steve Exp $ # Copyright (c) 2001 University of Cambridge. # See the file NOTICE for conditions of use and distribution. @@ -193,6 +193,9 @@ # # 2004-12-20 V1.35 Wouter Verhelst # Pie charts by volume were actually generated by count. Fixed. +# +# 2005-02-07 V1.36 Gregor Herrmann / Steve Campbell +# Added average sizes to HTML Top tables. =head1 NAME @@ -419,7 +422,7 @@ use vars qw($COLUMN_WIDTHS); @days_per_month = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334); $gig = 1024 * 1024 * 1024; -$VERSION = '1.35'; +$VERSION = '1.36'; # How much space do we allow for the Hosts/Domains/Emails/Edomains column headers? $COLUMN_WIDTHS = 8; @@ -1003,25 +1006,36 @@ if ($html) { print "<table border=0 width=\"100%\">\n"; print "<tr><td>\n"; print "<table border=1>\n"; - print "<tr><th>Messages</th><th>Bytes</th><th>\u$text</th>\n"; + print "<tr><th>Messages</th><th>Bytes</th><th>Average</th><th>\u$text</th>\n"; # Align non-local addresses to the right (so all the .com's line up). # Local addresses are aligned on the left as they are userids. my $align = ($text !~ /local/i) ? 'right' : 'left'; - $format = "<tr><td align=\"right\">%d</td><td align=\"right\">%s</td><td align=\"$align\" nowrap>%s</td>\n"; + $format = "<tr><td align=\"right\">%d</td><td align=\"right\">%s</td><td align=\"right\">%s</td><td align=\"$align\" nowrap>%s</td>\n"; } else { printf("%s\n%s\n\n", $temp, "-" x length($temp)); $format = "%7d %10s %s\n"; } -my($key,$htmlkey); +my($key,$htmlkey,$rounded_volume,$rounded_average,$count,$data,$gigs); foreach $key (top_n_sort($topcount,$m_count,$m_data_gigs,$m_data)) { if ($html) { $htmlkey = $key; $htmlkey =~ s/>/\>\;/g; $htmlkey =~ s/</\<\;/g; - printf($format, $$m_count{$key}, volume_rounded($$m_data{$key},$$m_data_gigs{$key}), $htmlkey); + + # When displaying the average figures, we calculate the average of + # the rounded data, as the user would calculate it. This reduces + # the accuracy slightly, but we have to do it this way otherwise + # when using -merge to convert results from text to HTML and + # vice-versa discrepencies would occur. + $rounded_volume = volume_rounded($$m_data{$key},$$m_data_gigs{$key}); + $data = $gigs = 0; + un_round($rounded_volume,\$data,\$gigs); + $count = $$m_count{$key}; + $rounded_average = volume_rounded($data/$count,$gigs/$count); + printf($format, $count, $rounded_volume, $rounded_average, $htmlkey); } else { printf($format, $$m_count{$key}, volume_rounded($$m_data{$key},$$m_data_gigs{$key}), $key); @@ -1078,7 +1092,7 @@ if ($html) { print "<table border=0 width=\"100%\">\n"; print "<tr><td>\n"; print "<table border=1>\n"; - print "<tr><th>Messages</th><th>Bytes</th><th>\u$text</th>\n"; + print "<tr><th>Messages</th><th>Bytes</th><th>Average</th><th>\u$text</th>\n"; } else { printf("%s\n%s\n\n", $temp, "-" x length($temp)); @@ -1099,7 +1113,13 @@ foreach $key (top_n_sort($topcount,$m_data_gigs,$m_data,$m_count)) { $htmlkey = $key; $htmlkey =~ s/>/\>\;/g; $htmlkey =~ s/</\<\;/g; - printf($format, $$m_count{$key}, volume_rounded($$m_data{$key},$$m_data_gigs{$key}), $htmlkey); + + $rounded_volume = volume_rounded($$m_data{$key},$$m_data_gigs{$key}); + $data = $gigs = 0; + un_round($rounded_volume,\$data,\$gigs); + $count = $$m_count{$key}; + $rounded_average = volume_rounded($data/$count,$gigs/$count); + printf($format, $count, $rounded_volume, $rounded_average, $htmlkey); } else { printf($format, $$m_count{$key}, volume_rounded($$m_data{$key},$$m_data_gigs{$key}), $key); @@ -2337,6 +2357,9 @@ sub parse_old_eximstat_reports { #------------------------------------- # # 48 1468KB local +# Could also have average values for HTML output. +# 48 1468KB 30KB local + my($category,$by_count_or_volume) = ($1,$2); #As we show 2 views of each table (by count and by volume), @@ -2382,6 +2405,10 @@ sub parse_old_eximstat_reports { $_ = html2txt($_); #Convert general HTML markup to text. $reached_table = 1 if (/^\s*\d/); next unless $reached_table; + + # Remove optional 'average value' column. + s/^\s*(\d+)\s+(\S+)\s+(\d+(KB|MB|GB|\b)\s+)/$1 $2 /; + if (/^\s*(\d+)\s+(\S+)\s*(.*?)\s*$/) { my($count,$rounded_volume,$entry) = ($1,$2,$3); #Note: $entry fields can be both null and can contain spaces. |