SF.net SVN: logwatch:[123]

[email protected]
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Revision: 123
          http://logwatch.svn.sourceforge.net/logwatch/?rev=123&view=rev
Author:   stefjakobs
Date:     2012-12-30 15:34:23 +0000 (Sun, 30 Dec 2012)
Log Message:
-----------
spamassassin statistics (Thanks Orion Poplawski) 

Modified Paths:
--------------
    conf/services/spamassassin.conf
    scripts/services/spamassassin

Modified: conf/services/spamassassin.conf
===================================================================
--- conf/services/spamassassin.conf	2012-12-30 15:31:23 UTC (rev 122)
+++ conf/services/spamassassin.conf	2012-12-30 15:34:23 UTC (rev 123)
@@ -5,7 +5,8 @@
 
 Title = "SpamAssassin"
 LogFile = spamassassin
-*OnlyService = spamd
+# Pull in sendmail for matching msgid to sender for statistics
+*OnlyService = (spamd|sendmail)
 *RemoveHeaders
 
 # Ignore connections from these hosts.

Modified: scripts/services/spamassassin
===================================================================
--- scripts/services/spamassassin	2012-12-30 15:31:23 UTC (rev 122)
+++ scripts/services/spamassassin	2012-12-30 15:34:23 UTC (rev 123)
@@ -69,7 +69,7 @@
       ( $ThisLine =~ m/connection from localhost / ) or
       ( $ThisLine =~ m/setuid to / ) or
       ( $ThisLine =~ m/processing message / ) or
-      ( $ThisLine =~ m/^spamd: result: / ) or
+      ( $ThisLine =~ m/^spamd: result: .*,mid=\(unknown\)/ ) or
       ( $ThisLine =~ m/^prefork: child states: / ) or
       ( $ThisLine =~ m/^spamd: alarm *$/ ) or
       ( $ThisLine =~ m/^spamd: handled cleanup of child / ) or
@@ -77,6 +77,9 @@
       ( $ThisLine =~ m/^logger: removing stderr method/ ) or
       ( $ThisLine =~ m/^spamd: server pid:/ ) or
       ( $ThisLine =~ m/^prefork: adjust: \d+ idle children (less|more) than \d+ (min|max)imum idle children/ ) or
+      # Sendmail messages to ignore
+      ( $ThisLine =~ m/^AUTH=/ ) or
+      ( $ThisLine =~ m/^STARTTLS/ ) or
       0  # Always last in the list, so all above can say "or" at the end
    ) {
       ; # We don't care about these
@@ -99,6 +102,18 @@
       #   ... at /usr/bin/spamd line 1085, <GEN5490> line 212
       $ThisLine =~ s/\d+/___/g;  # Make all numbers "generic"
       $Child{ $ThisLine }++;        # ...and count generic error types
+   } elsif ( ($spam, $score, $msgid) = ($ThisLine =~ m/^spamd: result: (.) (-?\d+).*,mid=<(.*)>/) ) {
+      # Only record the first scan
+      if (!defined($msg{$msgid}->{"score"}) and $spam eq "Y") {
+         $msg{$msgid}->{"score"} = $score;
+         $SpamRelay{$msg{$msgid}->{"relay"}}++;
+      }
+   } elsif ( $ThisLine =~ m/^q\w+:/ ) {
+      # Sendmail lines for statistics
+      if ( ($from, $msgid, $relay) = ($ThisLine =~ m/^q\w+: from=<(.*)>, .*, msgid=<(.*)>, .*, relay=(.*)/) ) {
+         $msg{$msgid}->{"from"} = $from;
+         $msg{$msgid}->{"relay"} = $relay;
+      }
 
    # EVERYTHING ELSE, or, Incentive to identify all "We don't care" lines
    # We on-purpose allow warnings about --max-children to go here
@@ -137,6 +152,15 @@
       int ((100.0 * $SpamTotal / $ttotal) + 0.5);
 }
 
+if (keys %SpamRelay) {
+   print "\nTop 10 Spam Relays:\n";
+   $i = 0;
+   foreach $relay (sort {$SpamRelay{$b}<=>$SpamRelay{$a} } keys %SpamRelay) {
+      print "   $relay: $SpamRelay{$relay} Time(s)\n";
+      last if ++$i == 10;
+   }
+}
+   
 if ( $StillRoot ) {
    print qq{\n"still running as root" error: $StillRoot time(s)\n};
 }

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.