Made some modifications to an existing script set. I was trying to extend pfixmrtg but had a lot of trouble with the bdb stuff.
1) put this kludgy mofo into /usr/local/sbin/spam-stats #!/bin/bash # # spam-stats -- print counts of clean and spammy messages # from spamassassin. echo -e "spam:" `grep "identified spam" /var/log/mail/info | wc -l` echo -e "clean:" `grep "clean message" /var/log/mail/info | wc -l` echo -e "skipped:" `grep "skipped large" /var/log/mail/info | wc -l` echo -e "total:" `grep "spamd[[0-9]*]: connection from" /var/log/mail/info | wc -l` echo -e "processed:" `grep "processing message" /var/log/mail/info | wc -l` 2) put this less kludgy attachment into /usr/local/sbin/spamstats.pl. 3) edit your mrtg.cfg and add something like: # show number of messages that were spam, total number of # messages _processed_ by spamd Target[spam]: `/usr/local/sbin/spamstats.pl localhost spam` Directory[spam]: felix MaxBytes[spam]: 100000 Options[spam]: gauge, nopercent, growright Title[spam]: Spam Statistics PageTop[spam]: <H1>SA-identified spam, SA-processed email</H1> WithPeak[spam]: dwmy YLegend[spam]: No. of messages ShortLegend[spam]: messages LegendI[spam]: spam: LegendO[spam]: total: run indexmaker. Results at: http://www.monkeynoodle.org/statistics, but there's a few hours of bad data from the unmodified script which tracked totals instead of five-minute deltas. -- Jack Coates Monkeynoodle: A Scientific Venture...
#!/usr/bin/perl # # spamstats.pl -- pull spam statistics from # spamd server, parse for MRTG # relies on kludgy bash script spam-stats # # 9/12/2002 by Rich Puhek ([EMAIL PROTECTED]) # 2/4/2003 by Jesper Knudsen ([EMAIL PROTECTED]) # 10/16/2003 by Jack Coates ([EMAIL PROTECTED]) # # usage: $0 host [spam|nonspam] # # returns the number of [spam|nonspam] and total spam messages # # inspired by mailstats program from Petter Reinholdtsen # <[EMAIL PROTECTED]> # $value=0; $datafile = "/var/lib/pfixmrtg/spamstat.old"; $spamstats = "/usr/local/sbin/spam-stats"; $source = `hostname`; $uptime = `uptime`; $uptime =~ s/^.*\s+up\s+// ; $uptime =~ s/,\s+\d+\s+users,.*// ; chomp($source,$uptime) ; #Behaving oddly, but seems to work... if ( ( $#ARGV != 1 ) or ( $ARGV[1] !~ /spam|clean|skipped/) ){ die "\nUsage: $0 host [spam|clean|skipped]\n"; }; $host=$ARGV[0]; $type=$ARGV[1]; # Get the old stats open(OLD,"<$datafile"); while(<OLD>) { chomp; ($key,$val) = split /=/; $old{$key} = $val; } close(OLD); # Get the new stats open(SPAM,"$spamstats|") or die "$0 unable to open spam-stats $!"; while (<SPAM>) { chomp; ($key,$val) = split /:/; $new{$key} += $val; } close(SPAM) || warn "$0: socket close error $!"; # Send MRTG the deltas print $new{$type}-$old{$type},"\n",$new{total}-$old{total},"\n","$uptime\n$source\n" if ($old{$type}); # Save the old stats open(OLD,">$datafile") ; foreach (keys %new) { print OLD "$_=$new{$_}\n" ; } ; close(OLD) ;
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com