Like many others here, the core of this template is based on the script for Net-SNMP written by Martin Adolfsson. My version of the script has been cleaned up to make it more friendly and includes debugging which can be activated by using the "-v" switch. Note that debugging should only be run when testing the script from the command line.
One other thing, the script requires "Getopt::Long". I think this is part of most Perl distributions but if not use the perl package manager to install it from CPAN.
Code: Select all
perl -MCPAN -e shell
install Getopt::Long
1. Get you Spamd and Net-SNMP working and make sure Spamd is logging. A sample Spamd configuration is on my web site at http://www.napthali.com/ramblings/openbsd.aspx#spamd however there are plenty of other examples on the net.
2. Copy the script to your server and make sure it is executable. I suggest "/usr/local/sbin".
3. Edit the script to suit the paths, MIN_RESET value and OID you wish to use. Note particularly that MIN_RESET should be set slightly less than the polling interval. The defaults assume a 5 minute polling interval:
Code: Select all
MIN_RESET is "240"
Base OID is ".1.3.6.1.4.1.2021.256"
Spamd log file is "/var/log/spamd"
Data file (used for caching) is "/var/db/spamd-data.db"
Code: Select all
pass .1.3.6.1.4.1.2021.256 /usr/local/sbin/get-spamd-data.pl
Code: Select all
# /usr/local/sbin/get-spamd-data.pl -v -g .1.3.6.1.4.1.2021.256.0
DEBUG : [2008-11-26 06:41:02] : Starting.
DEBUG : [2008-11-26 06:41:02] : Testing logfile "/var/log/spamd" exists
DEBUG : [2008-11-26 06:41:02] : Getting last update time and log file position
DEBUG : [2008-11-26 06:41:02] : Last update time is: 59
DEBUG : [2008-11-26 06:41:02] : Log position is: 35408
DEBUG : [2008-11-26 06:41:02] : Outputting SNMP data
DEBUG : [2008-11-26 06:41:02] : SNMP Base OID is : .1.3.6.1.4.1.2021.256
DEBUG : [2008-11-26 06:41:02] : SNMP Request OID is : .1.3.6.1.4.1.2021.256.0
DEBUG : [2008-11-26 06:41:02] : SNMP Method is : -g
.1.3.6.1.4.1.2021.256.0
integer
0
DEBUG : [2008-11-26 06:41:02] : Finishing.
Code: Select all
# snmpget -v1 -c community localhost .1.3.6.1.4.1.2021.256.0
UCD-SNMP-MIB::ucdavis.256.0 = INTEGER: 1
8. Add the template to a host and create a graph.
9. After a few cycles the graph should have some data to view.
Please note that my own mail server does not receive enough mail to assist testing so I did much of my testing using "generated" data. The numbers seem to be correct so I trust the template is correct. Post here if there are any issues and I'll try to fix them. As noted, this template assumes a 5 minute polling interval. If you use a different interval you will have to modify the MIN_RESET value in the script and probably the multiplier used in the "Spamd (5 Minute Polling)" CDEF.
To get the "look" right I had to do create manual CDEFS for the "Spamd - Adjust Time (T1)", "Spamd - Adjust Time (T2)" and "Spamd - Adjust Time (T3)" CDEFs so if you muck about with the template you may have to change these CDEFs so they point to the right sources.
The graph shows the following:
- Number of open connections for the period.
- Connection time for all connections for the period.
- Number of hosts whitelisted for the period.
- Number of hosts that are in a blacklist for the period.