On Fri, Apr 30, 2004 at 09:26:14AM +0200, Kristof Hardy said: > Colin A. Bartlett wrote: > >>http://mail.limelyte.net/admin/virus/ > >NICE! We do something similar. > >http://www.kineticweb.biz/virusreport.htm > >I have a script that parses the log file and reads it into SQL. From there, > >the rest is easy. > > Just some wishfull thinking.. Would any of you care to share some sample > code? Looks neat anyway.. ;)
I rotate my logs weekly, but here's the code I use to generate a simple
list of viruses froma last week. A little fixup to output html would be
pretty easy.
sub grep_clam_log {
my $line;
my $total = 0;
my $last = 0;
my %virii;
open F, "<$clam_log" or die "Couldn't open $clam_log: $!\n";
while($line=<F>) {
print "Parsing line: $line\n"
if($Verbose >= 4);
if ($line =~ /FOUND/) {
my @temp = split /[\s\t]+/, $line;
$virii{$temp[7]} += 1;
}
}
close F;
my @sorted = sort { $b <=> $a } (values %virii);
print "Viruses detected last week\n";
for my $value (@sorted) {
if ($last eq $value) {
next;
}
for my $key (keys %virii) {
if ($virii{$key} == $value) {
print " $virii{$key}\t$key\n";
$total += $value;
}
}
$last = $value;
}
print "Total viruses detected by ClamAV: $total\n";
}
--
--------------------------------------------------------------------------
| Stephen Gran | The only really decent thing to do |
| [EMAIL PROTECTED] | behind a person's back is pat it. |
| http://www.lobefin.net/~steve | |
--------------------------------------------------------------------------
pgp00000.pgp
Description: PGP signature
