steve 2005/02/16 15:49:36 GMT
Modified files:
exim-src/src eximstats.src
Log:
Added Gregor Herrmann's code to show the average sizes in the HTML top tables.
Revision Changes Path
1.5 +34 -7 exim/exim-src/src/eximstats.src
Index: eximstats.src
===================================================================
RCS file: /home/cvs/exim/exim-src/src/eximstats.src,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- eximstats.src 21 Dec 2004 11:33:55 -0000 1.4
+++ eximstats.src 16 Feb 2005 15:49:36 -0000 1.5
@@ -1,5 +1,5 @@
#!PERL_COMMAND -w
-# $Cambridge: exim/exim-src/src/eximstats.src,v 1.4 2004/12/21 11:33:55 steve Exp $
+# $Cambridge: exim/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 @@
@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 @@
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 @@
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 @@
$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 @@
#-------------------------------------
#
# 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 @@
$_ = 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.