[exim] Patch for eximstats

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Alain Williams
Dátum:  
Címzett: exim-users
Tárgy: [exim] Patch for eximstats
Here is a patch for eximstats. It adds an option -emptyok, this
suppresses the warning "**** No valid log lines read\n" that is
generated if nothing suitable is found in input; the exit code
of 1 is still returned.

What is the motivation for this ?

I was running eximstats from cron quite frequently (every 5 minutes) on
a lightly used system (that only becomes active when a network fails).
I was getting lots of mail from cron with the above warning message in them.

Given that I expect little activity on this machine, I do not consider
no input to be worthy of note.

Why so frequently running of eximstats ? The machine is monitored with
nagios, which expects to get such information quite frequently.

The patch is against exim-4.63.

I hereby certify that the code of the patch is my own and transfer my copyright
interests in this code to University of Cambridge/Phil Hazel so that it
can be included in exim.

--
Alain Williams
Parliament Hill Computers Ltd.
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/

#include <std_disclaimer.h>
--- src/eximstats.src    2006-07-31 15:19:48.000000000 +0100
+++ src/eximstats.src.new    2006-10-24 01:04:22.000000000 +0100
@@ -554,7 +554,7 @@
 # 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($hist_opt $hist_interval $hist_number $volume_rounding);
+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);
 use vars qw($include_original_destination);
@@ -1718,6 +1718,8 @@
                 from where to include the charts in the html file
                 -chartdir and -chartrel default to '.'


+-emptyok        It is OK if there is no valid input, don't print an error.
+
 -d              Debug mode - dump the eval'ed parser onto STDERR.


 EoText
@@ -2786,6 +2788,7 @@
   while (<$fh>) {
     PARSE_OLD_REPORT_LINE:
     if (/Exim statistics from ([\d\-]+ [\d:]+(\s+[\+\-]\d+)?) to ([\d\-]+ [\d:]+(\s+[\+\-]\d+)?)/) {
+
       $begin = $1 if ($1 lt $begin);
       $end   = $3 if ($3 gt $end);
     }
@@ -3424,6 +3427,7 @@
   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] =~ /^-emptyok$/)  { $emptyOK = 1 }
   elsif ($ARGV[0] =~ /^-nvr$/)      { $volume_rounding = 0 }
   elsif ($ARGV[0] =~ /^-show_rt([,\d\+\-\*\/]+)?$/) { @rcpt_times = parse_time_list($1) }
   elsif ($ARGV[0] =~ /^-show_dt([,\d\+\-\*\/]+)?$/) { @delivery_times = parse_time_list($1) }
@@ -3613,7 +3617,7 @@



if ($begin eq "9999-99-99 99:99:99") {
- print STDERR "**** No valid log lines read\n";
+ print STDERR "**** No valid log lines read\n" unless($emptyOK);
exit 1;
}