qpsmtpd denial statistics
Update
Check out my RRdtool graphs for qpsmtpd!
I thought I’d display some statistics on how qpsmtpd has performed in the last week.

Surely, adding the contents of me to the HELO hosts that aren’t allowed stopped a considerable amount of spam. Whether the same is true for localhost or whether those are misconfigured hosts trying to send legit e-mail is open for discussion.
I’m not using SPF yet as the required perl module was a bit of a hassle to install.
SpamAssassin is also quite effective as you can see, even though the Bayeisan filter isn’t in effect yet — it’s only had about 50 spam e-mails to train on so far, and the module won’t come into effect until it’s received 200. Of those 50 spam e-mails, about 30 were e-mails that were so spammy that spamd auto-learned them, 10 were spam messages I actually received, and 20 were from the junk I got on the previous server. I’ve had no ham that got scores of more than 5.0 (my munge_headers threshold), although some may have had a score over 10, in which case they were denied.
How I did this
Basically, I did a lot of grep, sed, sort and uniq:
#!/bin/sh
# Count all hard denials
cat /var/log/qmail/qpsmtpd/* | \
grep ‘returned DENY,’ | sed ’s/^.*Plugin //’ | \
sort | uniq -c | sort -n
#!/bin/sh
# Count earlitalker soft denials
cat /var/log/qmail/qpsmtpd/* | \
grep ‘earlytalker.*DENYSOFT,’ | wc -l
#!/bin/sh
# Count messages accepted
cat /var/log/qmail/qpsmtpd/* | \
grep ‘Queued!’ | wc -l
You’d have to adapt the cat to match whatever logfile(s) you want to analyse.
This of course misses out on all the other DENYSOFT, some of which do belong in correct stats (such as require_resolvable_fromhost) while others don’t (or need more detailed analysis), such as greylisting.
The figures from the above exercises were then assembled by hand and fed into a snippet of code from the documentation of the perl module GD::Graph3d:
#!/usr/bin/perl -w
use GD::Graph::pie3d;
my @data = (
['Message accepeted','SpamHELO localhost', 'earlytalker',
'SpamHELO me', 'SpamAssassin', 'SBL',
'RelayDeny','badmailfrom','ORDB'],
[386,212,121, 111, 102, 37, 28, 6, 6]
);
my $graph = new GD::Graph::pie3d( 300, 300 );
$graph->set(
title => ‘Spam stopping statistics’,
start_angle => 290
);
my $gd = $graph->plot( \@data );
binmode STDOUT;
print $gd->png();
…and make sure to redirect the output to a file
2006-06-21 at 12.07 pm
[...] As my first spam statistics graph generated quite some interest, here’s a new one. [...]