#!/usr/bin/perl -w ############################################### # This script should be called with a parameter # of a maillog file, for example: # my-virus-report.pl /var/log/maillog # This script outputs a simple report showing the results of # ClamAV virus scans of e-mail attachments as performed by # amavisd-new. # amavisd-new loglevels 0-2 only generates a log entry when a virus # infected e-mail is found. loglevels 3-5 report each scan # performed on every mail part. This report shows # of viruses # found and lists the virus types for loglevels 0-2 and adds # scans performed for loglevels 3-5. my (@Viruses); $j = 0; $ScanCount = 0; while(<>) { next unless ($_ =~ /amavis/); # Skip lines that don't contain "amavis" if ($_ =~ /-clamd result|clamscan status=/) { # Count virus scans performed for loglevel 3-5 $ScanCount++; } elsif ($_ =~ /\) INFECTED \(/) { ($Viruses[$j]{Type}) = /INFECTED\s+\((\S+)., /; #if (! defined $Viruses[$j]{Type}) { print "Line: $_\n"; } #print "debug: $Viruses[$j]{Type}\n"; $j++; } } ############################################# ## Print out virus report ############################################# print < $$b{Count} } @Viruses ); ############################################# ## Print out virus distribution by type (name) ############################################# print <