On Wed, 22 Sep 2004, David Brodbeck wrote:
Dan Mahoney, System Admin wrote:
Hey all,
In the process of trying to track statistics in SpamAssassin (and other programs), and I'm thinking the easiest way is to have syslog write to a FIFO that another program will read (or write to a pipe, but I'm not sure syslog can do this), and then just have that program keep track of time and store a logfile every so often.
I think syslog-ng can write to pipes and maybe even databases.
Actually under BSD, even the standard syslog is able to do pipes.
Still something like this would be great if implemented WITHIN spamd.
Essentially, for MRTG compatibility, we're just looking to store values, emails received, and spams flagged.
Beyond that, we could set threshholds for use with RRD tool.
Borrowing some code from http://users.2z.net/rpuhek/scripts_public/spamd/ ...
Still, what I'm envisioning is a little thing that does the following.
Before I present the code, how much effort would it take to have the parent spamd process generate this file automatically (i.e. --scoreboard = /var/log/spam-scoreboard --scoreboardflushinterval=100). It's like twenty lines of code to include, and it could be VERY useful in proving the effectiveness of SpamAssassin, rather than having to grok a sendmail log.
while (<STDIN>) { $stats{spam}++ if /identified spam/; $stats{clean}++ if /clean message/; $stats{skipped}++ if /skipped large/; $stats{total}++ if /connection from/; $stats{processed}++ if /processing message/; $counter++; if $counter eq $flushinterval { &flush; }
# possibly something here to roll the values over # at the 32-bit boundary to prevent them from # getting huge, in true MRTG fashion.
};
sub flush { open OUTPUT, ">/var/log/spamstats"; print OUTPUT <<EOF Spam: $stats{spam} Skipped: $stats{skipped} Total: $stats{total} Processed: $stats{processed} EOF close OUTPUT;
--
"It doesn't matter where I live, because I live in dataspace. That's my hometown."
-Steve Roberts, Builder of BEHEMOTH
--------Dan Mahoney-------- Techie, Sysadmin, WebGeek Gushi on efnet/undernet IRC ICQ: 13735144 AIM: LarpGM Site: http://www.gushi.org ---------------------------