During my search for scripts and templates for generating statistics for sendmail, spamassassin and clamav, i couldn't find what i am looking for.
Since i'm not good in creating graph templates i took the template from http://forums.cacti.net/viewtopic.php?t=15651 written by warnesj. Thanks
The template is modified to use the gsum variable so it can display total number of mails. http://forums.cacti.net/about19336.html Thanks gauret
If you want the "Total" feature in the graph to work, you will have to follow gauret's instruction to add the gsum variable to your system too. Also cyberwizzard's addition for the /= 300 so that values are calculated correctly.
This is my version of the stats gathering script. I have no intentions of rewriting/altering it to work for other systems, I am just posting it in case people like me need it. Feel free to change it in any ways you need.
I am currently using clamav-milter and spamass-milter.
For virus messages to be identified, clamav-milter must add the X-Virus-Status: Infected header. You can do that by adding to your clamav-milter.conf :
Code: Select all
AddHeader Replace
The software's main features are:
- daemon - it's not parsing the whole log file (which can be 100s of MB) everytime it's executed
sendmail integration - it uses the local-host-names and aliases file from sendmail so that it successfully identifies received mails
light - it's not using up too much resources since it's a simple daemon written in C
custom timer interval - you can set how often to write the stats file so that it's not rewriting the file everytime an email reaches the mailserver
selective writing of stats file - it only writes the stats file when an event has happened (eg when an email has been marked as spam) and not just when the timer takes place
logrotate support - when logs are rotated it re-opens the maillog file
- only one poller - the stats file is being reset everytime snmp asks for it. so only one cacti poller can use them
Installation:
1) compile the source using:
Code: Select all
gcc -o maillog_watcher maillog_watcher.c -lpthread
3) add the following lines to your snmpd.conf
Code: Select all
exec .1.3.6.1.4.100.2 maillog_received /opt/maillog_watcher/maillog_watcher_read.sh received
exec .1.3.6.1.4.100.4 maillog_sent /opt/maillog_watcher/maillog_watcher_read.sh sent
exec .1.3.6.1.4.100.5 maillog_virus /opt/maillog_watcher/maillog_watcher_read.sh virus
exec .1.3.6.1.4.100.6 maillog_spam /opt/maillog_watcher/maillog_watcher_read.sh spam
exec .1.3.6.1.4.100.7 maillog_rejected /opt/maillog_watcher/maillog_watcher_read.sh rejected
Code: Select all
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/maillog_watcher.pid 2> /dev/null` 2> /dev/null || true
endscript
}
Code: Select all
[root@mail ~]# /opt/maillog_watcher/maillog_watcher
[root@mail ~]#