Date: Mon, 01 May 2000 03:20:49 -0400 From: Theo E. Schlossnagle To: Philip Hazel Subject: Some useful scripts.. I run some high volume mail servers and I wrote two little perl ditty's that I find invaluable. I thought that other might as well. They monitor receptions and deliveries per second (by tailing the main log file). We typically sendout about 250 message/second on our systems and I find these guys real useful in trying to determine if everything is "healthy". Either pass in the full path to your mainlog as a paramter or set the binary path to exim on the second line of the scripts and it will determine useing exim -bP log_file_path. They are under a BSD license. -- Theo Schlossnagle 33131B65/2047/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7 [ Part 2: "Attached Text" ] #!/usr/bin/perl $path='/usr/exim/bin'; $start = time; $tot=0; $ts = ''; $tsc=0; if(!($file = shift)) { open(CONF, "-|") || exec ("$path/exim", "-bP", "log_file_path"); chomp($response = ); close(CONF); $response =~ s/log_file_path = //; $file = sprintf($response, "main"); } print "File: $file\n"; open(INF, "-|") || exec ("/usr/bin/tail", "-f", "$file"); while() { if(/\s(\S+)\s\S+\sCompleted/) { $nts = $1; if($nts ne $ts) { if(length($ts)) { printf "%3d [AVE=%-5.2f SUM=%7d] $ts\n", $tsc, ($tot/((time()-$start)||1)), $tot; } $ts = $nts; $tsc=0; } $tot++; $tsc++; } } close INF; [ Part 3: "Attached Text" ] #!/usr/bin/perl $path = '/usr/exim/bin'; $start = time; $tot=0; $ts = ''; $tsc=0; if(!($file = shift)) { open(CONF, "-|") || exec ("$path/exim", "-bP", "log_file_path"); chomp($response = ); close(CONF); $response =~ s/log_file_path = //; $file = sprintf($response, "main"); } print "File: $file\n"; @amin, @lmin; foreach (1 .. 60) { push @lmin, 0; push @amin, 0; } sub avg { my($sum) = 0; foreach (@_) { $sum+=$_; } return $sum/scalar(@_); } $SIG{ALRM} = sub { print "error\n"; }; open(INF, "-|") || exec ("/usr/bin/tail", "-f", "$file"); while() { if(/\s(\S+)\s\S+\s<=/) { $nts = $1; if($nts ne $ts) { if(length($ts)) { printf "%3d [AVE=%-5.2f SUM=%7d] $ts\n", $tsc, ($tot/((time()-$start)||1)), $tot; push @lmin, $tsc; push @amin, (shift @lmin); shift @amin; # print avg(@amin)."--".avg(@lmin)."\n"; } $ts = $nts; $tsc=0; } $tot++; $tsc++; } } close INF;