Monitor SpamAssassin with MRTG

 

Contributions by:

Based on Howto by Rich Puhek from his web

Created/Updated: 09-02-2004
Versions supported: 5.5, 5.6 and 6.0

 


If you want to monitor how many e-mails are tagged SPAM you can use MRTG (which I love). First install MRTG as mentioned in the guide. You need to place two statistics gathering "programs" in your /etc/mrtg directory. An example of SpamAssassin MRTG statistics can be seen here.

 

[root@e-smith]# cd /etc/mrtg

[root@e-smith]# wget http://sme.swerts-knudsen.dk/downloads/MRTG/spamstats.pl

[root@e-smith]# wget http://sme.swerts-knudsen.dk/downloads/MRTG/spam-stats

[root@e-smith]# chmod 755 spamstats.pl

[root@e-smith]# chmod 755 spam-stats

 

 

if you want to use my spamassassin MRTG config file then also download that

 

[root@e-smith]# wget http://sme.swerts-knudsen.dk/downloads/MRTG/spamassassin.cfg

 

You now need to create the output directory where MRTG will place result data. This directory is configured in the spamassassin.cfg file and in my case /home/e-smith/files/ibays/mrtg

 

[root@e-smith]# mkdir /home/e-smith/files/ibays/mrtg/html/spamassassin

 

You should now be able to run MRTG (notice that you get warnings in the first two runs)

 

[root@e-smith]# mrtg spamassassin.cfg

 

You would properly like to have this added to your existing MRTG cron job so add a line in the all-ip file (also located in /etc/mrtg)

[root@e-smith ]# pico all-ip

Insert the following line in the bottom and press CTRL-X, Y, to save:

/usr/bin/mrtg /etc/mrtg/spamassassin.cfg;

If you want to verify that you get data from your log files you can run both programs (spam-stats and spamstats.pl) from the command line.

ex.

[root@e-smith ]# ./spam-stats

spam: 4
clean: 19
skipped: 0
total: 23
processed: 23

[root@e-smith ]# perl spamstats.pl localhost spam

4
23