> > Lots of open-source tools can do the quarantine thing for you.. 
> > MailScanner does great quarantines for example. You just need a cron-job 
> > to go through and clear out your quarantine every once in a while. (It 
> > stores them under date-named directories)
> 
> Quarantining is not a problem, since procmail could do that job; I'm 
> looking more into the posibility in that spam report thing with the 
> option to deliever that email. Anybody? ;-)
> 

You could probably hack up some procmail scripts to do what you want.

Off the top of my head in 15 seconds : Create a <user>-quarentine alias
which invokes a procmail script.  The report could include a magic token
(md5 hash, etc.) in a mailto: url 
(mailto:user-quarentine?subject=deliver-<magictoken> or
mailto:user-quarentine?subject=delete-<magictoken> ) 
which the procmail would look for in order to deliver the quarentined mail.

As for a report, the following may be a start. cat your maillog (or
whereever spamd logs to) to this.  insert a 'grep <username>' before
this to get a report for one user.  Note: this report works for me, if
it doesn't for you hack it into submission.

 #!/usr/bin/perl

 # note : this is a 10 minute hack, and its ugly perl.

LINE:
while (<>) { 
        if ( $_ =~ /identified/ ) { 
                @fields = split;
                $spamd{$fields[3]}++;
                $total_msg_count++;
                $total_bytes += $fields[13];
                $total_seconds += $fields[11];
                $score = $fields[7];
                $score =~ s/\(//;
                $score =~ s/\/.*//;
                $total_score += $score;
                $spam_msg_count++;
                $spam_bytes += $fields[13];
        $spam_seconds += $fields[11];
                $spam_score += $score;
        }
        elsif ( $_ =~ /clean/ ) { 
                @fields = split;
                $spamd{$fields[3]}++;
                $total_msg_count++;
                $total_bytes += $fields[13];
                $total_seconds += $fields[11];
        $score = $fields[7];
        $score =~ s/\(//;
        $score =~ s/\/.*//;
                $total_score += score;
                $clean_msg_count++;
                $clean_bytes += $fields[13];
        $clean_seconds += $fields[11];
                $clean_score += $score;
        } else { 
                next LINE;
        }
}
$hours_of_scanning = int($total_seconds / 360) /10;
$total_seconds = int($total_seconds * 10)/10;
$mbytes = int(($total_bytes/1048576)*10)/10;
$spam_perc = int($spam_msg_count/$total_msg_count*10000)/100;
$clean_perc = int($clean_msg_count/$total_msg_count*10000)/100;
print "-------------------------------------------------------\n";
print "TOTALS \n";
print "-------------------------------------------------------\n";
print "Total Message Scanned : $total_msg_count\n";
print "Total Seconds Spent Scanning : $total_seconds ($hours_of_scanning 
hours)\n";
print "Total Bytes Scanned : $total_bytes ($mbytes MBytes)\n";
print "Total Messages Identified As Spam : $spam_msg_count ($spam_perc %)\n";
print "Total Messages Identified As Non-Spam : $clean_msg_count ($clean_perc 
%)\n";
print "Load Balancing:\n";
foreach $host (sort (keys(%spamd))) { 
        $host_perc = int(($spamd{$host}/$total_msg_count)*100000)/1000;
        print "\t$host used $spamd{$host} times. ($host_perc\%)\n";
}
print "\n";
$seconds_per_msg = int($total_seconds/$total_msg_count * 10)/10;
$average_msg_bytes = int($total_bytes/$total_msg_count);
$average_score = int(($total_score/$total_msg_count)*10)/10;
print "-------------------------------------------------------\n";
print "All Message Averages \n";
print "-------------------------------------------------------\n";
print "Average seconds To Scan Each Message : $seconds_per_msg\n";
print "Average Bytes Per Message : $average_msg_bytes\n";
print "Average Message Score : $average_score\n";
print "\n";
$hours_of_scanning = int($clean_seconds / 360) /10;
$clean_seconds = int($clean_seconds * 10)/10;
$mbytes = int(($clean_bytes/1048576)*10)/10;
$seconds_per_msg = int($clean_seconds/$clean_msg_count * 10)/10;
$average_msg_bytes = int($clean_bytes/$clean_msg_count);
$average_score = int(($clean_score/$clean_msg_count)*10)/10;
print "-------------------------------------------------------\n";
print "Clean Messages\n";
print "-------------------------------------------------------\n";
print "Total Seconds Spent Scanning Clean : $clean_seconds ($hours_of_scanning 
hours)\n";
print "Average Seconds Per Clean : $seconds_per_msg\n";
print "Total Clean Bytes Scanned : $clean_bytes ($mbytes MBytes)\n";
print "Average Bytes Per Clean : $average_msg_bytes\n";
print "Average Clean Message Score : $average_score\n";
print "\n";
$hours_of_scanning = int($spam_seconds / 360) /10;
$spam_seconds = int($spam_seconds * 10)/10;
$mbytes = int(($spam_bytes/1048576)*10)/10;
$seconds_per_msg = int($spam_seconds/$spam_msg_count * 10)/10;
$average_msg_bytes = int($spam_bytes/$spam_msg_count);
$average_score = int(($spam_score/$spam_msg_count)*10)/10;
print "-------------------------------------------------------\n";
print "Spam Messages\n";
print "-------------------------------------------------------\n";
print "Total Seconds Spent Scanning Spam : $spam_seconds ($hours_of_scanning 
hours)\n";
print "Average Seconds Per Spam : $seconds_per_msg\n";
print "Total Spam Bytes Scanned : $spam_bytes ($mbytes MBytes)\n";
print "Average Bytes Per Spam : $average_msg_bytes\n";
print "Average Spam Message Score : $average_score\n";
print "\n";

Reply via email to