[Mimedefang] Mail stats via rrdtool

Kevin A. McGrail kmcgrail at pccc.com
Mon Jan 19 14:54:50 EST 2004


I needed something very similar to this so I actually was modifying it this
morning.  However, I think your system will fail because strftime will
return Jan 01 and sendmail will log Jan  1 (space padded).

I further modified it to do a larger range of dates by using mysql to do the
date processing.  My version is here but this is a really simple script.

The main point of my email was to point out the potential bug above for
single digit dates and I wouldn't recommend this in cron.  I just needed to
produce a one-time report on a system and I ran it like this:

zcat /var/log/maillog.?.gz | cat /var/log/maillog - |
/usr/local/sbin/parse_maillog.pl

http://www.peregrinehw.com/downloads/MIMEDefang/parse_maillog.pl

Regards,
KAM

> Be sure to modify your MDLOG tags so they match.
> Then call the script like: mail.pl /var/log/maillog
> /Fredrik
>
> #!/usr/bin/perl
> use POSIX qw(strftime);
> my $mail_counter = 0;
> my $spam_counter = 0;
> my $virus_counter = 0;
>
> $date = strftime "%b %e %H:", localtime;
>   while (<>) {
>     if (m|$date|) {
>      if ($_ =~ /mail_in/){
>      $mail_counter++;
>      }
>      if ($_ =~ /spam/){
>      $spam_counter++;
>      }
>      if ($_ =~ /virus/){
>      $virus_counter++;
>      }
>    } else {
>    }
>  }
> printf("mail_in:%d mail_spam:%d
> mail_virus:%d",$mail_counter,$spam_counter,$virus_counter);



More information about the MIMEDefang mailing list