Hi,
I have received this log error mail in my admin email account, this is my fresh smeserver box installed.
Subject: Cron <root@ns1> /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/\@*.s /var/log/qpsmtpd/current
Can't open /var/log/qpsmtpd/@*.s: No such file or directory at /usr/bin/spamfilter-stats-7.pl line 214.
When i check my /var/log, i do able to find this folder as per described.
[root@ns1 qpsmtpd]# ls -al
total 668
drwxr-s--- 2 smelog smelog 4096 Mar 19 19:46 .
drwxr-xr-x 49 root root 4096 Mar 19 19:37 ..
-rw-r--r-- 1 smelog smelog 236971 Mar 18 02:13 @4000000045fc377124c2ce04.u
-rw-r--r-- 1 smelog smelog 189418 Mar 19 16:12 @4000000045fe780a081344b4.u
-rw-r--r-- 1 smelog smelog 231385 Mar 20 00:04 current
-rw------- 1 smelog smelog 0 Mar 17 01:48 lock
-rw-r--r-- 1 smelog smelog 0 Mar 19 19:46 state
[root@ns1 qpsmtpd]#
Please help.
Regards,
Daley
-- spamfilter-stats-7.pl --
#!/usr/bin/perl -w
#############################################################################
#
# This script provides daily SpamFilter statistics and deletes all users
# junkmails. Configuration of the script is done by the Spam Filter
# Server-Manager module
#
# April 2006 - no longer controlled by server manager, and does not delete files
#
# This script has been developed
# by Jesper Knudsen at
http://sme.swerts-knudsen.dk#
# Revision History:
#
# August 13, 2003: Initial version
# August 25, 2004: fixed problem when hostname had no-ASCII chars
# March 23, 2006 Revised for sme7 RM
# March 27, 2006 ditto BJR (
http://www.abandonmicrosoft.co.uk)
# - Merged Clamav and SA stats
# - Moved all analysis to qsmtpd log
# - Removed parameterised interval (for simplicity - not sure of format anyway)
# - add in archived log files for people who have high turnover
# - Alter labels to be more accurate
# - Detect deleted spam (over threshold) without using spam score
# - Detect RBL rejections
# - Detect pattern (executible) rejections
# - Look for the DENY labels - add in Miscellaneous category
# April 6, 2006 - check qpsmtp log level and also DNS enable properties
# - Average spam scores for under and over threshold seperatly
# - Log tag and Reject levels
# - TBD - check that RBL DENY are being detected (I have no date to check this)
# April 7, 2007 - re-written by Charlie Brady totally in Perl
# April 16, 2006 - move warnings to report
# - Spot fetchmail deliveries
# - Spot Internal connections from client PCs
# - TBD check that RBL DENY are being detected (I have no data to check this)
# April 30, 2006 - Pascal Schirrmann Start Time and End Time to noon - should be a param
# so the script can be run at any time in the day.
# - adds 'by recipients domains' stats Useful for MX-Backup or multi domains hosts
# - Add a 'recipients per mail' stat. Useful : until now the sums are correct

# - Correct some messages about rbl who can led to wrong entry in the config database
# ( and without expected results, of course !)
# - improve a regexp in the SPAM detection
# May 1, 2006 - BJR - Fix situation where mxbackup prop is not defined
# - fix a spelling and minor format of domain report
# May 9, 2006 - bjr - Make RBL percentage a percentage of total connections (else it >100%)
# May 9, 2006 - ps - some 'sanity check' in the 'per domains part of the stats (to avoid / 0)
# May 12, 2006 - ps - some cleanup in the 'per domains' stats
# - Add a version number, logged in the mail
#############################################################################
# internal modules (part of core perl distribution)
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use POSIX qw/strftime floor/;
use Time::Local;
use Date::Manip;
use Time::TAI64;
use esmith::ConfigDB;
use esmith::DomainsDB;
use Sys::Hostname;
my $hostname = hostname();
#Configuration section
my %opt = ();
$opt{'version'} = '0.5.0'; # please update at each change.
$opt{'debug'} = 0; # guess what ?
$opt{'sendmail'} = '/usr/sbin/sendmail'; # Path to sendmail stub
$opt{'from'} = 'Admin'; # Who is the mail from
$opt{'end'} = `date --iso-8601`; # midnight today
my $yesterday = $opt{ 'end' };
$yesterday =~ s/\-//g ;
$yesterday--;
$opt{'start'} = `date --iso-8601 -d $yesterday`; # midnight yesterday
$opt{'mail'} = "admin";
$opt{'timezone'} = `date +%z`;
Date_Init("TZ=$opt{'timezone'}");
my $disabled = 0;
my $tstart = time;
#Local variables
my $YEAR = ( localtime(time) )[5]; # this is years since 1900
my $total = 0;
my $spamcount = 0;
my $spamavg = 0;
my $hamcount = 0;
my $hamavg = 0;
my $rejectspamavg = 0;
my $Accepttotal = 0;
my $localAccepttotal = 0; #Fetchmail connections
my $localsendtotal = 0; #Connections from local PCs
my $totalexamined = 0; #total download + RBL etc
my %sendtotalbyhour = ();
my %localLANbyhour = ();
my %localacceptbyhour = ();
my $above15 = 0;
my $RBLcount = 0;
my %RBLbyhour = ();
my $MiscDenyCount = 0;
my $PatternFilterCount = 0;
my %patternfilterbyhour = ();
my $noninfectedcount = 0;
my $okemailcount = 0;
my $infectedcount = 0;
my %infectedbyhour = ();
my %found_viruses = ();
my %spambyhour = ();
my %hambyhour = ();
my $warnnoreject = " ";
my $rblnotset = ' ';
# some storage for by recipient domains stats (PS)
# my bad : I have to deal with multiple simoultaneous connections
# will play with the process number.
# my $currentrcptdomain = '' ;
my %currentrcptdomain ; # temporay store the recipient domain until end of mail processing
my %byrcptdomain ; # Store 'by domains stats'
my @extdomain ; # only useful in some MX-Backup case, when any subdomains are allowed
my $morethanonercpt = 0 ; # count every 'second' recipients for a mail.
# store the domain of interest. Every other records are stored in a 'Other' zone
my $ddb = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB : $!\n";
foreach my $domain( $ddb->get_all_by_prop( type => "domain" ) ) {
$byrcptdomain{ $domain->key }{ 'type' }='local';
}
$byrcptdomain{ esmith::ConfigDB->open_ro->get('SystemName')->value . "."
. esmith::ConfigDB->open_ro->get('DomainName')->value }{ 'type' } = 'local';
# is this system a MX-Backup ?
if (esmith::ConfigDB->open_ro->get('mxbackup')){
if ( ( esmith::ConfigDB->open_ro->get('mxbackup')->prop('status') || 'disabled' ) eq 'enabled' ) {
my %MXValues = split( /,/, ( esmith::ConfigDB->open_ro->get('mxbackup')->prop('name') || '' ) ) ;
foreach my $data ( keys %MXValues ) {
$byrcptdomain{ $data }{ 'type' } = "mxbackup-$MXValues{ $data }" ;
if ( $MXValues{ $data } == 1 ) { # subdomains allowed, must take care of this
push @extdomain, $data ;
}
}
}
}
my ( $start, $end ) = parse_arg( $opt{'start'}, $opt{'end'} );
#
# First check current configuration for logging, DNS enable and Max threshold for spamassassin
#
my $LogLevel = esmith::ConfigDB->open_ro->get('qpsmtpd')->prop('LogLevel');
my $LowLogLevel = ( $LogLevel < 8 );
my $RHSenabled =
( esmith::ConfigDB->open_ro->get('qpsmtpd')->prop('RHSBL') eq 'enabled' );
my $DNSenabled =
( esmith::ConfigDB->open_ro->get('qpsmtpd')->prop('DNSBL') eq 'enabled' );
my $SARejectLevel =
esmith::ConfigDB->open_ro->get('spamassassin')->prop('RejectLevel');
my $SATagLevel =
esmith::ConfigDB->open_ro->get('spamassassin')->prop('TagLevel');
my $DomainName =
esmith::ConfigDB->open_ro->get('DomainName')->value;
if ( !$RHSenabled || !$DNSenabled ) {
$rblnotset = '*';
}
#if ( !$RHSenabled ) {
# print
#"Warning - RHSBL disabled - use 'config setprop qpsmtpd RHSBL enabled' to set it on\n";
#}
#if ( !$DNSenabled ) {
# print
#"Warning - DNSSBL disabled - use 'config setprop qpsmtpd DNSBL enabled' to set it on\n";
#}
if ( $LogLevel < 8 ) {
print
"Warning - qpsmtpd log level needs to be >=8 for full details to be captured - 'config setprop qpsmtpd LogLevel 8'\n";
}
if ( $SARejectLevel == 0 ) {
# print
#"Warning - Spamassassin is configured to not reject any emails - use 'server-manager\\E-mail\\spam rejection level'\n";
$warnnoreject = "(*Warning* 0 = no reject)";
}
#print ('*',$LogLevel,'*',$RHSenabled,'*',$DNSenabled,'*',$SARejectLevel);
#
#---------------------------------------
# Scan the qpsmtpd log files
#---------------------------------------
my $starttai = Time::TAI64::unixtai64n($start);
my $endtai = Time::TAI64::unixtai64n($end);
LINE: while (<>) {
my($tai,$log) = split(' ',$_,2);
# print $tai;
#If date specified, only process lines matching date
next LINE if ( $tai lt $starttai );
last if ( $tai gt $endtai );
my $abstime = Time::TAI64::tai2unix($tai);
my $abshour = floor( $abstime / 3600 ); # Hours since the epoch
# we store the more recent recipient domain, for domain statistics
# in fact, we only store the first recipient. Could be sort of headhache
# to obtain precise stats with many recipients on more than one domain !
if ( m/(\d+)\s+dispatching RCPT TO:.+@(.+)$/ ) {
my $proc = $1 ;
if ( ( $currentrcptdomain{ $proc } || '' ) eq '' ) {
$currentrcptdomain{ $proc } = lc($2) ;
$currentrcptdomain{ $proc } =~ s/[^\w\-\.]//g ;
my $NotableDomain = 0 ;
if ( defined ( $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'type' } ) ) {
$NotableDomain = 1 ;
}
else {
foreach ( @extdomain ) {
if ( $currentrcptdomain{ $proc } =~ m/$_$/ ) {
$NotableDomain = 1 ;
last ;
}
}
}
if ( !$NotableDomain ) {
$currentrcptdomain{ $proc } = 'Others' ;
}
$byrcptdomain{ $currentrcptdomain{ $proc } }{ 'total' }++ ;
}
else {
# there more than a recipient for a mail, how many daily ?
$morethanonercpt++;
}
}
if (m/^\S+\s+(\d+).*DENY/)
{
my $proc = $1 ;
$MiscDenyCount++;
if ( ( $currentrcptdomain{ $proc } || '' ) ne '' ) {
$byrcptdomain{ $currentrcptdomain{ $proc } }{ 'deny' }++ ;
$currentrcptdomain{ $proc } = '' ;
}
# count spams to be deleted
if (m/.*DENY, spam score exceeded threshold.*/) {
$above15++;
}
#Check for DNSRBL reject
if (m/.*Plugin (dnsbl|rhsbl|rbsbl), hook rcpt returned DENY.*/) {
$RBLcount++;
$RBLbyhour{$abshour}++;
}
#check for Pattern Filter reject
if (m/.*Plugin virus::pattern_filter, hook data_post returned DENY.*/) {
$PatternFilterCount++;
$patternfilterbyhour{$abshour}++
}
}
#
# Then do the acceptance, spamassassin and Anti Virus records
#
if (m/spamassassin|Virus|Accepted|spooling/)
{
my $score = 0;
#Count total number connections
if (m/.*Accepted connection.*/) {
$Accepttotal++;
if (m/.*localhost.*/) {
$localAccepttotal++;
$localacceptbyhour{$abshour}++;
}
if (m/$DomainName/) {
$localsendtotal++;
$localLANbyhour{$abshour}++
}
$sendtotalbyhour{$abshour}++;
}
#Count total number emails downloaded
if (m/.*spooling message to disk.*/) {
$total++;
}
#Spam scores
if (
# PS Hack change in the regular expression to better catch the required score
# m/.*spamassassin plugin: check_spam: Yes, hits=(.*), required=(.*),.*/
m/.*spamassassin plugin: check_spam: Yes, hits=(.*), required=([0-9\.]+),.*/
)
{
$spamcount++;
$score = $1;
# keep seperate averages of under and over max threshold
if ( $score >= $SARejectLevel ) {
$rejectspamavg += $score;
}
else {
$spamavg += $score;
}
$spambyhour{$abshour}++;
}
#Non Spam scores
if (
# PS Hack change in the regular expression to better catch the required score
# m/.*spamassassin plugin: check_spam: No, hits=(.*), required=(.*),.*/
m/.*spamassassin plugin: check_spam: No, hits=(.*), required=([0-9\.]+),.*/
)
{
$hamcount++;
$score = $1;
$hamavg += $score;
$hambyhour{$abshour}++;
}
#Virus Found
if (m/.*552 Virus Found:(.*)/) {
$infectedcount++;
$infectedbyhour{$abshour}++;
$found_viruses{$1}++;
}
}
# Messages going in the delivery queue
if (m/(\d+) 250 Queued.*/) {
my $proc = $1 ;
if ( ( $currentrcptdomain{ $proc } || '' ) ne '' ) {
$byrcptdomain{ $currentrcptdomain{ $proc } }{ 'accept' }++ ;
$currentrcptdomain{ $proc } = '' ;
}
}
# For debugging purpose : normally, at the cleaning up line,
# the corresponding currentrcptdomain should be empty
if (m/cleaning up after (\d+)/) {
my $proc = $1 ;
if ( ( $currentrcptdomain{ $proc } || '' ) ne '' ) {
$byrcptdomain{ $currentrcptdomain{ $proc } }{ 'xfer' }++ ;
$currentrcptdomain{ $proc } = '' ;
}
}
}
$MiscDenyCount = $MiscDenyCount - $RBLcount - $above15 - $PatternFilterCount;
#Calculate some numbers
$spamavg = $spamavg / ( $spamcount - $above15 ) if $spamcount - $above15;
$rejectspamavg = $rejectspamavg / $above15 if $above15;
$totalexamined = $total + $RBLcount + $PatternFilterCount + $MiscDenyCount;
$hamavg = $hamavg / $hamcount if $hamcount;
#my $threshavg=$threshtotal/$total if $total;
# RBL etc percent of total emails examined
my $rblpercent = ( ( $RBLcount / $totalexamined ) * 100 ) if $totalexamined;
my $PatternFilterpercent = ( ( $PatternFilterCount / $totalexamined ) * 100 ) if $totalexamined;
my $Miscpercent = ( ( $MiscDenyCount / $totalexamined ) * 100 ) if $totalexamined;
#Spam and virus percent of total email downloaded
my $spampercent = ( ( $spamcount / $total ) * 100 ) if $total;
my $hampercent = ( ( $hamcount / $total ) * 100 ) if $total;
my $hrsinperiod = ( ( $end - $start ) / 3600 );
my $emailperhour = ( $total / $hrsinperiod ) if $total;
my $above15percent = ( ( $above15 / $spamcount ) * 100 ) if $spamcount;
my $infectedpercent = ( ( $infectedcount / ($total) ) * 100 ) if $total;
# Mails sucessfully sent through - AV check follows spam check
$okemailcount = $total - $infectedcount - $PatternFilterCount - $above15;
my $okemailpercent = ( ( $okemailcount / $total ) * 100 ) if $total;
my $oldfh;
#Open Sendmail if we are mailing it
if ( $opt{'mail'} && !$disabled ) {
open( SENDMAIL, "|$opt{'sendmail'} -oi -t -odq" )
or die "Can't open sendmail: $!\n";
print SENDMAIL "From: $opt{'from'}\n";
print SENDMAIL "To: $opt{'mail'}\n";
print SENDMAIL "Subject: Spam Filter Statistics from $hostname - ",
strftime( "%F", localtime($start) ), "\n\n";
$oldfh = select SENDMAIL;
}
my $telapsed = time - $tstart;
if ( !$disabled ) {
#Output results
print "SMEServer daily Anti-Virus and Spamfilter statistics", "\n";
print "----------------------------------------------------", "\n\n";
print "$0 Version : $opt{'version'}", "\n\n";
print "Period Beginning : ", strftime( "%c", localtime($start) ), "\n";
print "Period Ending : ", strftime( "%c", localtime($end) ), "\n";
print "\n";
print "Clam Version : ", `freshclam -V`;
print "SpamAssassin Version : ", `spamassassin -V`;
printf "Tag level: %3d; Reject level: %3d $warnnoreject\n", $SATagLevel,
$SARejectLevel;
print "\n";
printf "Reporting Period : %.2f hrs\n", $hrsinperiod;
print "----------------------------\n";
print "\n";
printf "All SMTP connections accepted : %8d \n", $Accepttotal;
if ($localAccepttotal>0) {
printf "Connections from Fetchmail : %8d \n",
$localAccepttotal;
}
printf "SMTP from local workstations : %8d \n\n", $localsendtotal;
printf "RBL rejected : %8d (%6.2f%%)\n", $RBLcount,
$rblpercent || 0;
printf "Pattern filter rejected : %8d (%6.2f%%)\n",
$PatternFilterCount, $PatternFilterpercent || 0;
printf "Misc.rejected : %8d (%6.2f%%)\n", $MiscDenyCount,
$Miscpercent || 0;
printf "Infected by Virus : %8d (%6.2f%%)\n", $infectedcount,
$infectedpercent || 0;
printf "Spam rejected (over reject level): %8d (%6.2f%%)\n", $above15,
$above15percent || 0;
printf "Spam detected (over tag level) : %8d (%6.2f%%)\n", $spamcount,
$spampercent || 0;
printf "Ham detected (under tag level) : %8d (%6.2f%%)\n", $hamcount,
$hampercent || 0;
printf "Total emails accepted : %8d (%6.2f%%)\n", $okemailcount,
$okemailpercent || 0;
print " --------------------\n";
printf "Total emails processed : %8d (%8.2f/hr)\n", $total,
$emailperhour || 0;
print "\n";
printf "Average spam score (accepted): %11.2f\n", $spamavg || 0;
printf "Average spam score (rejected): %11.2f\n", $rejectspamavg || 0;
printf "Average ham score : %11.2f\n", $hamavg || 0;
print "\n";
print "Statistics by Hour\n";
if ($localAccepttotal>0) {
print "----------------------------------------------------------------------------- \n";
print
"Hour Fetchml Local Virus Spam Ham RBL/DNS$rblnotset Execut. \n";
print "-------------- -------- -------- -------- -------- -------- -------- -------- \n";
my $hour = floor( $start / 3600 );
while ( $hour < $end / 3600 ) {
printf(
"%s %8d %8d %8d %8d %8d %8d %8d\n",
strftime( "%F, %H", localtime( $hour * 3600 ) ),
$localacceptbyhour{$hour} || 0,
$localLANbyhour{$hour} || 0,
$infectedbyhour{$hour} || 0,
$spambyhour{$hour} || 0,
$hambyhour{$hour} || 0,
$RBLbyhour{$hour} || 0,
$patternfilterbyhour{$hour} || 0
);
$hour++;
}
} else {
print "-------------------------------------------------------------------- \n";
print
"Hour Local Virus Spam Ham RBL/DNS$rblnotset Execut. \n";
print "-------------- -------- -------- -------- -------- -------- -------- \n";
my $hour = floor( $start / 3600 );
while ( $hour < $end / 3600 ) {
printf(
"%s %8d %8d %8d %8d %8d %8d \n",
strftime( "%F, %H", localtime( $hour * 3600 ) ),
$localLANbyhour{$hour} || 0,
$infectedbyhour{$hour} || 0,
$spambyhour{$hour} || 0,
$hambyhour{$hour} || 0,
$RBLbyhour{$hour} || 0,
$patternfilterbyhour{$hour} || 0
);
$hour++;
}
}
print "-------------------------------------------------------------------- \n";
if ($localAccepttotal>0) {
print "*Fetchml* means connections from Fetchmail delivering email\n";
}
print "*Local* means connections from workstations on local LAN\n";
print "\n";
if ( !$RHSenabled || !$DNSenabled ) {
# comment about RBL not set
print
"* - This means that one or more of the possible spam black listing services\n that are available have not been enabled.\n";
print " You have not enabled:\n";
if ( !$RHSenabled ) {
print " RHSBL\n";
}
if ( !$DNSenabled ) {
print " DNSBL\n";
}
print " To enable these you can use the following commands:\n";
if ( !$RHSenabled ) {
print " config setprop qpsmtpd RHSBL enabled\n";
}
if ( !$DNSenabled ) {
print " config setprop qpsmtpd DNSBL enabled\n";
}
# there so much templates to expand... (PS)
print " Followed by:\n expanding templates and\n svc -t /service/qpsmtpd\n\n";
}
# time to do a 'by recipient domain' report
print "\nIncoming mails by recipient domains usage\n";
print "------------------------------------------\n";
print
"Domains Type Total Denied XferErr Accept \%accept\n";
print
"-------------------- ---------- ------ ------ ------- ------ -------\n";
my %total = (
total => 0,
deny => 0,
xfer => 0,
accept => 0,
);
foreach my $domain (
sort {
join( "\.", reverse( split /\./, $a ) ) cmp
join( "\.", reverse( split /\./, $b ) )
} keys %byrcptdomain
)
{
next if ( ( $byrcptdomain{$domain}{'total'} || 0 ) == 0 );
my $tp = $byrcptdomain{$domain}{'type'} || 'other';
my $to = $byrcptdomain{$domain}{'total'} || 0;
my $de = $byrcptdomain{$domain}{'deny'} || 0;
my $xr = $byrcptdomain{$domain}{'xfer'} || 0;
my $ac = $byrcptdomain{$domain}{'accept'} || 0;
printf "%-20s %-10s %6d %6d %7d %6d %6.2f%%\n", $domain, $tp, $to,
$de, $xr, $ac, $ac * 100 / $to;
$total{'total'} += $to;
$total{'deny'} += $de;
$total{'xfer'} += $xr;
$total{'accept'} += $ac;
}
print
"-------------------- ---------- ------ ------- ------ ------ -------\n";
# $total{ 'total' } can be equal to 0, bad for divisions...
my $perc1 = 0;
my $perc2 = 0;
if ( $total{'total'} != 0 ) {
$perc1 = $total{'accept'} * 100 / $total{'total'};
$perc2 = ( ( $total{'total'} + $morethanonercpt ) / $total{'total'} );
}
printf "Total %6d %6d %7d %6d %6.2f%%\n\n",
$total{'total'}, $total{'deny'}, $total{'xfer'}, $total{'accept'},
$perc1;
printf
"%d mails were processed for %d Recipients\nThe average recipients by mail is %4.2f\n\n",
$total{'total'}, ( $total{'total'} + $morethanonercpt ), $perc2;
if ( $infectedcount > 0 ) {
show_virus_variants();
}
} # not disabled
List_Junkmail();
if ( !$disabled ) {
print "\nDone. Report generated in $telapsed sec.\n\n";
#Close Senmdmail if it was opened
if ( $opt{'mail'} ) {
select $oldfh;
close(SENDMAIL);
}
}
#All done
exit 0;
#############################################################################
# Subroutines ###############################################################
#############################################################################
########################################
# Process parms #
########################################
sub parse_arg {
my $startdate = shift;
my $enddate = shift;
my $secsinday = 86400;
my $time = 0;
my $start = UnixDate( $startdate, "%s" );
my $end = UnixDate( $enddate, "%s" );
if ( !$start && !$end ) {
$end = time;
$start = $end - $secsinday;
return ( $start, $end );
}
if ( !$start ) {
$start = $end - $secsinday;
return ( $start, $end );
}
if ( !$end ) {
$end = $start + $secsinday;
return ( $start, $end );
}
if ( $start > $end ) {
return ( $end, $start );
}
return ( $start, $end );
}
sub dbg {
my $msg = shift;
if ( $opt{debug} ) {
print STDERR $msg;
}
}
sub List_Junkmail {
#
# Show how many junkmails in each user's junkmail folder.
#
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open_ro;
my $entry;
foreach my $user ($adb->users) {
my $found = 0;
my $junkmail_dir = "/home/e-smith/files/users/" .
$user->key . "/Maildir/.junkmail";
# print $user->key;
foreach my $dir (qw(new cur)) {
# Now get the content list for the directory.
if (opendir( QDIR, "$junkmail_dir/$dir" )) {
while ($entry=readdir(QDIR) ) {
next if $entry =~ /^\./;
$found++;
}
closedir(QDIR);
}
}
if ( !$disabled ) {
printf "User \"%s\" ", $user->key;
printf "- %d email(s) left in junkmail folder\n", $found;
}
}
}
sub show_virus_variants
#
# Show a league table of the different virus types found today
#
# This is actually the only bit that does rely on running at midnight, as it uses yesterdays date
# to select the log records to look at
# No longer true - it now uses an array created by the earlier scan
{
# my $mydate;
# my %month_list = (
# 'Jan' => 1,
# 'Feb' => 2,
# 'Mar' => 3,
# 'Apr' => 4,
# 'May' => 5,
# 'Jun' => 6,
# 'Jul' => 7,
# 'Aug' => 8,
# 'Sep' => 9,
# 'Oct' => 10,
# 'Nov' => 11,
# 'Dec' => 12
# );
# my ( $month, $day ) = UnixDate( "yesterday", "%b", "%e" );
# my $monthnum = $month_list{$month};
#
# #sort out leading zeros
# if ( $monthnum < 10 ) {
# $mydate = "0$monthnum-$day";
# }
# else {
# $mydate = "$monthnum-$day";
# }
# $mydate =~ s/ /0/; #Map space in front of $day to zero
print("Virus Statistics by name:\n");
print("---------------------------------------------\n");
foreach my $virus (sort { $found_viruses{$b} <=> $found_viruses{$a} }
keys %found_viruses)
{
print "Rejected $found_viruses{$virus}\t$virus\n";
}
print("---------------------------------------------\n");
}