[Mimedefang] Mail stats via rrdtool

Mattias Ahnberg mattias at ahnberg.pp.se
Thu Jan 22 06:36:01 EST 2004


>> "FH" == Fredrik Hansen <fredrik.hansen at dataservice.mine.nu> writes:

Be careful with $date stuff since it is easy to make them mismatch
with the logs own formatting of times. I've stumbled over this kind
of issues many times.

Without actually testing I foresee your script generating false
positives without having more specific matches in your regexps. For
example, consider the following line:

    Jan 22 00:00:18 yadda sm-mta[1528]: i0JDeK5a058704: to=<myspammer at freeware.ru>, delay=2+09:19:58, \
      xdelay=00:02:30, mailer=esmtp, pri=10112593, relay=host1.ware.ru. [195.54.192.114], dsn=4.0.0, \
      stat=Deferred: Operation timed out with host1.ware.ru.

Wouldn't your $spam_counter be increased by this line too due to
/spam/ matching spam in myspammer? I'd recommend that you first
grep out all lines matching /: MDLOG,/ in maillog and then to be
more specific about the regexps that increase your counters.

Or am I missing something in your logic?

/ahnberg.

FH> $date = strftime "%b %e %H:", localtime;
FH>   while (<>) {
FH>     if (m|$date|) {
FH>      if ($_ =~ /mail_in/){
FH>      $mail_counter++;
FH>      }
FH>      if ($_ =~ /spam/){
FH>      $spam_counter++;
FH>      }
FH>      if ($_ =~ /virus/){
FH>      $virus_counter++;
FH>      }
FH>    } else {
FH>    }
FH>  }
FH> printf("mail_in:%d mail_spam:%d 
FH> mail_virus:%d",$mail_counter,$spam_counter,$virus_counter);

FH> _______________________________________________
FH> Visit http://www.mimedefang.org and http://www.canit.ca
FH> MIMEDefang mailing list
FH> MIMEDefang at lists.roaringpenguin.com
FH> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang



More information about the MIMEDefang mailing list