diff -ruN smeserver-mailstats-1.1.old/root/etc/cron.d/mailstats.cron smeserver-mailstats-1.1/root/etc/cron.d/mailstats.cron --- smeserver-mailstats-1.1.old/root/etc/cron.d/mailstats.cron 2012-05-26 17:09:22.000000000 +0200 +++ smeserver-mailstats-1.1/root/etc/cron.d/mailstats.cron 2015-06-11 00:38:15.000000000 +0200 @@ -1,2 +1,2 @@ -0 0 * * * root perl /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/\@* /var/log/qpsmtpd/current +0 0 * * * root sleep $[ $RANDOM \% 3600 ]; perl /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/\@* /var/log/qpsmtpd/current /var/log/sqpsmtpd/\@* /var/log/sqpsmtpd/current diff -ruN smeserver-mailstats-1.1.old/root/usr/bin/spamfilter-stats-7.pl smeserver-mailstats-1.1/root/usr/bin/spamfilter-stats-7.pl --- smeserver-mailstats-1.1.old/root/usr/bin/spamfilter-stats-7.pl 2014-06-16 17:56:40.000000000 +0200 +++ smeserver-mailstats-1.1/root/usr/bin/spamfilter-stats-7.pl 2015-06-11 00:38:15.000000000 +0200 @@ -1,3 +1,5 @@ + + #!/usr/bin/perl -w ############################################################################# @@ -9,6 +11,10 @@ # and re-written by brian read at bjsystems.co.uk (with some help from the community - thanks guys) # # bjr - 02sept12 - Add in qpsmtpd failure code auth::auth_cvm_unix_local as per Bug 7089 +# bjr - 10Jun15 - Sort out multiple files as input parameters as per bug 5613 +# - Sort out geoip failure status as per Bug 4262 +# - change final message about the DB (it is created automatically these days by the rpm) +# # ############################################################################# # @@ -61,7 +67,7 @@ #Configuration section my %opt = ( - version => '0.6.26', # please update at each change. + version => '0.6.27', # please update at each change. debug => 0, # guess what ? sendmail => '/usr/sbin/sendmail', # Path to sendmail stub from => 'spamfilter-stats', # Who is the mail from @@ -130,12 +136,13 @@ my $CATRBLDNS='RBL/DNS'; my $CATEXECUT='Execut.'; my $CATNONCONF='Non.Conf.'; +my $CATBADCOUNTRIES='Geoip.'; my $CATSPAMDEL='Del.Spam'; my $CATSPAM='Qued.Spam?'; my $CATHAM='Ham'; my $CATTOTALS='TOTALS'; my $CATPERCENT='PERCENT'; -my @categs = ($CATHOUR,$CATFETCHMAIL,$CATWEBMAIL,$CATMAILMAN,$CATLOCAL,$CATVIRUS,$CATRBLDNS,$CATEXECUT,$CATNONCONF,$CATSPAMDEL,$CATSPAM,$CATHAM,$CATTOTALS,$CATPERCENT); +my @categs = ($CATHOUR,$CATFETCHMAIL,$CATWEBMAIL,$CATMAILMAN,$CATLOCAL,$CATVIRUS,$CATRBLDNS,$CATEXECUT,$CATBADCOUNTRIES,$CATNONCONF,$CATSPAMDEL,$CATSPAM,$CATHAM,$CATTOTALS,$CATPERCENT); my $GRANDTOTAL = '99'; #subs for count arrays, for grand total my $PERCENT = '98'; # for column percentages @@ -270,16 +277,18 @@ my @ARGV2; foreach ( map { glob } @ARGV){ push(@ARGV2,($_)); +#print "\nFound $_"; } @ARGV=@ARGV2; LINE: while (<>) { +#print "\nLine:$_"; my($tai,$log) = split(' ',$_,2); #If date specified, only process lines matching date next LINE if ( $tai lt $starttai ); - last if ( $tai gt $endtai ); + next LINE if ( $tai gt $endtai ); # pull out spamasassin rule lists if ( $_ =~m/spamassassin plugin: check_spam:.*hits=(.*), required.*tests=(.*)/ ) @@ -297,6 +306,8 @@ #only select Logterse output next LINE unless m/terse plugin/; +#print "\nFound $_"; + my $abstime = Time::TAI64::tai2unix($tai); my $abshour = floor( $abstime / 3600 ); # Hours since the epoch @@ -454,6 +465,8 @@ if ($log_items[5] eq 'count_unrecognized_commands') {$MiscDenyCount++;$counts{$abshour}{$CATNONCONF}++;mark_domain_rejected($proc);next LINE} + if ($log_items[5] eq 'check_badcountries') {$MiscDenyCount++;$counts{$abshour}{$CATBADCOUNTRIES}++;mark_domain_rejected($proc);next LINE} + if ($log_items[5] eq 'tnef2mime') { next LINE} #Not expecting this one. if ($log_items[5] eq 'spamassassin') { $above15++;$counts{$abshour}{$CATSPAMDEL}++; @@ -851,7 +864,7 @@ if ($savedata) { save_data(); } else { print "No data saved - if you want to save data to a MySQL database, then please use:\n". - "config setprop mailstats SaveDataToMySQL yes\nYou must have created the database first."; + "config setprop mailstats SaveDataToMySQL yes\n"; } @@ -1320,3 +1333,5 @@ my $daterec = $sth->fetchrow_hashref(); $daterec->{"dateid"}; } + +