[Exim] a script to generate a reject report

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: David Bremner
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: [Exim] a script to generate a reject report
I liked the output from exiqsumm, so I decided to do something
similar.

Here is a simple minded perl script.

#!/usr/bin/perl -w

# David Bremner
# bremner@???
# $Id: exirejectsumm.pl,v 1.3 2004/05/21 12:06:32 bremner Exp $

# This file is placed in the public domain.

my $summary_only=0;

if ($ARGV[0]=~/-s/){
$summary_only=1;
shift;
}

$^L="\n";

while(<>){
  chomp();
  next if(!m/\d\d\d\d-\d\d-\d\d/);
  next if (!m/.*rejected RCPT/);
  if (m|F=<([^>]+)>.*: ([^:]+)$|){
    $reason=$2;
    $from=$1;


    ($user,$domain)=split(/@/,$from);


    if (!defined($sender_domain{$domain})){
      $sender_domain{$domain}=1;
      $dom_permanent{$domain}=0;
      $dom_temporary{$domain}=0;


    }


    if (!defined($sender{$from})){
      $sender{$from}=1;
      $permanent{$from}=0;
      $temporary{$from}=0;
    }


    if ($reason =~ /^Sender verify failed/){
      $permanent{$from}++;
      $dom_permanent{$domain}++
    } else {
      $dom_temporary{$domain}++;
      $temporary{$domain}++;
    }


}
}


print "Exim rejected domains\n";

foreach $from (sort (keys %sender_domain)){
$temp= $dom_temporary{$from};
$perm= $dom_permanent{$from};
write;
}

if (!$summary_only){
print "\nExim rejected addresses";
$-=0; # force header

  foreach $from (sort (keys %sender)){
    $temp= $temporary{$from};
    $perm= $permanent{$from};
    write;
  }
}


format STDOUT_TOP =
Address                          Temporary    Permanent
-------------------------------------------------------
.
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@>>>>>>>>    @>>>>>>>>
$from,              $temp,  $perm
.