X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/6e2b4ccc44cc0e84337b9b74479c347985edab1c..8e669ac162fe3b1040297f1d021de10778dce9d9:/src/src/eximstats.src diff --git a/src/src/eximstats.src b/src/src/eximstats.src index e013b9713..32003889b 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.5 2005/02/16 15:49:36 steve Exp $ +# $Cambridge: exim/src/src/eximstats.src,v 1.6 2005/02/17 11:58:26 ph10 Exp $ # Copyright (c) 2001 University of Cambridge. # See the file NOTICE for conditions of use and distribution. @@ -178,7 +178,7 @@ # Added warnings if required GD::Graph modules are not available or # insufficient -chart* options are specified. # -# 2004-02-20 V1.31 Andrea Balzi +# 2004-02-20 V1.31 Andrea Balzi # Only show the Local Sender/Destination links if the tables exist. # # 2004-07-05 V1.32 Steve Campbell @@ -534,16 +534,16 @@ sub volume_rounded { ####################################################################### # un_round(); -# +# # un_round($rounded_volume,\$bytes,\$gigabytes); -# +# # Given a volume in KB, MB or GB, as generated by volume_rounded(), # do the reverse transformation and convert it back into Bytes and Gigabytes. # These are added to the $bytes and $gigabytes parameters. -# +# # Given a data size in bytes, round it to KB, MB, or GB # as appropriate. -# +# # EG: 500 => (500,0), 14GB => (0,14), etc. ####################################################################### sub un_round { @@ -572,9 +572,9 @@ sub un_round { ####################################################################### # add_volume(); -# +# # add_volume(\$bytes,\$gigs,$size); -# +# # Add $size to $bytes/$gigs where this is a number split into # bytes ($bytes) and gigabytes ($gigs). This is significantly # faster than using Math::BigInt. @@ -593,12 +593,12 @@ sub add_volume { ####################################################################### # format_time(); -# +# # $formatted_time = format_time($seconds); -# +# # Given a time in seconds, break it down into # weeks, days, hours, minutes, and seconds. -# +# # Eg 12005 => 3h20m5s ####################################################################### sub format_time { @@ -623,11 +623,11 @@ $p; ####################################################################### # unformat_time(); -# +# # $seconds = unformat_time($formatted_time); -# +# # Given a time in weeks, days, hours, minutes, or seconds, convert it to seconds. -# +# # Eg 3h20m5s => 12005 ####################################################################### sub unformat_time { @@ -647,9 +647,9 @@ sub unformat_time { ####################################################################### # seconds(); -# +# # $time = seconds($timestamp); -# +# # Given a time-of-day timestamp, convert it into a time() value using # POSIX::mktime. We expect the timestamp to be of the form # "$year-$mon-$day $hour:$min:$sec", with month going from 1 to 12, @@ -659,14 +659,14 @@ sub unformat_time { # (with the -utc option), then we adjust the time by the current local # time offset so that it can be compared with the time recorded in message # IDs, which is UTC. -# +# # To improve performance, we only use mktime on the date ($year-$mon-$day), # and only calculate it if the date is different to the previous time we # came here. We then add on seconds for the '$hour:$min:$sec'. -# +# # We also store the results of the last conversion done, and only # recalculate if the date is different. -# +# # We used to have the '-cache' flag which would store the results of the # mktime() call. However, the current way of just using mktime() on the # date obsoletes this. @@ -714,9 +714,9 @@ sub seconds { ####################################################################### # id_seconds(); -# +# # $time = id_seconds($message_id); -# +# # Given a message ID, convert it into a time() value. ####################################################################### sub id_seconds { @@ -731,13 +731,13 @@ $s; ####################################################################### # calculate_localtime_offset(); -# +# # $localtime_offset = calculate_localtime_offset(); -# +# # Calculate the the localtime offset from gmtime in seconds. -# +# # $localtime = time() + $localtime_offset. -# +# # These are the same semantics as ISO 8601 and RFC 2822 timezone offsets. # (West is negative, East is positive.) ####################################################################### @@ -767,9 +767,9 @@ sub calculate_localtime_offset { ####################################################################### # print_queue_times(); -# +# # $time = print_queue_times($message_type,\@queue_times,$queue_more_than); -# +# # Given the type of messages being output, the array of message queue times, # and the number of messages which exceeded the queue times, print out # a table. @@ -870,9 +870,9 @@ print "\n"; ####################################################################### # print_histogram(); -# +# # print_histogram('Deliverieds|Messages received',@interval_count); -# +# # Print a histogram of the messages delivered/received per time slot # (hour by default). ####################################################################### @@ -985,9 +985,9 @@ if ($html) ####################################################################### # print_league_table(); -# +# # print_league_table($league_table_type,\%message_count,\%message_data,\%message_data_gigs); -# +# # Given hashes of message count and message data, which are keyed by # the table type (eg by the sending host), print a league table # showing the top $topcount (defaults to 50). @@ -1024,7 +1024,7 @@ foreach $key (top_n_sort($topcount,$m_count,$m_data_gigs,$m_data)) { $htmlkey = $key; $htmlkey =~ s/>/\>\;/g; $htmlkey =~ s/ 0. ####################################################################### sub top_n_sort { @@ -1221,15 +1221,15 @@ sub top_n_sort { my $n_minus_1 = $n - 1; my $n_minus_2 = $n - 2; - # Pick out the top $n keys. + # Pick out the top $n keys. my($key,$value1,$value2,$value3,$i,$comparison,$insert_position); while (($key,$value1) = each %$href1) { #print STDERR "key $key ($value1,",$href2->{$key},",",$href3->{$key},") <=> ($minimum_value1,$minimum_value2,$minimum_value3)\n"; - + # Check to see that the new value is bigger than the lowest of the # top n keys that we're keeping. - $comparison = $value1 <=> $minimum_value1 || + $comparison = $value1 <=> $minimum_value1 || $href2->{$key} <=> $minimum_value2 || $href3->{$key} <=> $minimum_value3 || $top_n_key cmp $key; @@ -1256,7 +1256,7 @@ sub top_n_sort { for ($i = 0; $i < $n_minus_1; $i++) { $top_n_key = $top_n_keys[$i]; if ( ($top_n_key eq '_') || - ( ($value1 <=> $href1->{$top_n_key} || + ( ($value1 <=> $href1->{$top_n_key} || $value2 <=> $href2->{$top_n_key} || $value3 <=> $href3->{$top_n_key} || $top_n_key cmp $key) == 1 @@ -1288,9 +1288,9 @@ sub top_n_sort { ####################################################################### # html_header(); -# +# # $header = html_header($title); -# +# # Print our HTML header and start the block. ####################################################################### sub html_header { @@ -1312,9 +1312,9 @@ EoText ####################################################################### # help(); -# +# # help(); -# +# # Display usage instructions and exit. ####################################################################### sub help { @@ -1377,15 +1377,15 @@ EoText ####################################################################### # generate_parser(); -# +# # $parser = generate_parser(); -# +# # This subroutine generates the parsing routine which will be # used to parse the mainlog. We take the base operation, and remove bits not in use. # This improves performance depending on what bits you take out or add. -# +# # I've tested using study(), but this does not improve performance. -# +# # We store our parsing routing in a variable, and process it looking for #IFDEF (Expression) # or #IFNDEF (Expression) statements and corresponding #ENDIF (Expression) statements. If # the expression evaluates to true, then it is included/excluded accordingly. @@ -1724,9 +1724,9 @@ sub generate_parser { ####################################################################### # parse(); -# +# # parse($parser,\*FILEHANDLE); -# +# # This subroutine accepts a parser and a filehandle from main and parses each # line. We store the results into global variables. ####################################################################### @@ -1747,9 +1747,9 @@ sub parse { ####################################################################### # print_header(); -# +# # print_header(); -# +# # Print our headers and contents. ####################################################################### sub print_header { @@ -1803,9 +1803,9 @@ sub print_header { ####################################################################### # print_grandtotals(); -# +# # print_grandtotals(); -# +# # Print the grand totals. ####################################################################### sub print_grandtotals { @@ -1890,9 +1890,9 @@ EoText ####################################################################### # print_user_patterns() -# +# # print_user_patterns(); -# +# # Print the counts of user specified patterns. ####################################################################### sub print_user_patterns { @@ -1938,9 +1938,9 @@ sub print_user_patterns { ####################################################################### # print_transport(); -# +# # print_transport(); -# +# # Print totals by transport. ####################################################################### sub print_transport { @@ -2043,9 +2043,9 @@ sub print_transport { ####################################################################### # print_relay(); -# +# # print_relay(); -# +# # Print our totals by relay. ####################################################################### sub print_relay { @@ -2089,9 +2089,9 @@ sub print_relay { ####################################################################### # print_errors(); -# +# # print_errors(); -# +# # Print our errors. In HTML, we display them as a list rather than a table - # Netscape doesn't like large tables! ####################################################################### @@ -2117,7 +2117,7 @@ sub print_errors { $text =~ s/\s\s+/ /g; #Convert multiple spaces to a single space. $total_errors += $errors_count{$key}; if ($html) { - + #Translate HTML tag characters. Sergey Sholokh. $text =~ s/\/\>\;/g; @@ -2147,36 +2147,36 @@ sub print_errors { ####################################################################### # parse_old_eximstat_reports(); -# +# # parse_old_eximstat_reports($fh); -# +# # Parse old eximstat output so we can merge daily stats to weekly stats and weekly to monthly etc. -# +# # To test that the merging still works after changes, do something like the following. # All the diffs should produce no output. -# +# # options='-bydomain -byemail -byhost -byedomain' # options="$options -pattern 'Completed Messages' /Completed/" # options="$options -pattern 'Received Messages' /<=/" -# +# # ./eximstats $options mainlog > mainlog.txt # ./eximstats $options -merge mainlog.txt > mainlog.2.txt # diff mainlog.txt mainlog.2.txt -# +# # ./eximstats $options -html mainlog > mainlog.html # ./eximstats $options -merge -html mainlog.txt > mainlog.2.html # diff mainlog.html mainlog.2.html -# +# # ./eximstats $options -merge mainlog.html > mainlog.3.txt # diff mainlog.txt mainlog.3.txt -# +# # ./eximstats $options -merge -html mainlog.html > mainlog.3.html # diff mainlog.html mainlog.3.html -# +# # ./eximstats $options -nvr mainlog > mainlog.nvr.txt # ./eximstats $options -merge mainlog.nvr.txt > mainlog.4.txt # diff mainlog.txt mainlog.4.txt -# +# # # double_mainlog.txt should have twice the values that mainlog.txt has. # ./eximstats $options mainlog mainlog > double_mainlog.txt ####################################################################### @@ -2513,9 +2513,9 @@ sub parse_old_eximstat_reports { ####################################################################### # update_relayed(); -# +# # update_relayed($count,$sender,$recipient); -# +# # Adds an entry into the %relayed hash. Currently only used when # merging reports. ####################################################################### @@ -2538,12 +2538,12 @@ sub update_relayed { ####################################################################### # add_to_totals(); -# +# # add_to_totals(\%totals,\@keys,$values); -# +# # Given a line of space seperated values, add them into the provided hash using @keys # as the hash keys. -# +# # If the value contains a '%', then the value is set rather than added. Otherwise, we # convert the value to bytes and gigs. The gigs get added to I-gigs. ####################################################################### @@ -2568,11 +2568,11 @@ sub add_to_totals { ####################################################################### # get_report_total(); -# +# # $total = get_report_total(\%hash,$key); -# +# # If %hash contains values split into Units and Gigs, we calculate and return -# +# # $hash{$key} + 1024*1024*1024 * $hash{"${key}-gigs"} ####################################################################### sub get_report_total { @@ -2586,9 +2586,9 @@ sub get_report_total { ####################################################################### # html2txt(); -# +# # $text_line = html2txt($html_line); -# +# # Convert a line from html to text. Currently we just convert HTML tags to spaces # and convert >, <, and   tags back. ####################################################################### @@ -2609,16 +2609,16 @@ sub html2txt { ####################################################################### # get_next_arg(); -# +# # $arg = get_next_arg(); -# +# # Because eximstats arguments are often passed as variables, # we can't rely on shell parsing to deal with quotes. This # subroutine returns $ARGV[1] and does a shift. If $ARGV[1] # starts with a quote (' or "), and doesn't end in one, then # we append the next argument to it and shift again. We repeat # until we've got all of the argument. -# +# # This isn't perfect as all white space gets reduced to one space, # but it's as good as we can get! If it's esential that spacing # be preserved precisely, then you get that by not using shell