Monitoring qmail with Cacti & net-snmp

September 14th, 2005

You'll need a fairly recent install of net-snmp for this, as it uses the 'extend' MIB.

You also need Inter7's excellent qmail-mrtg7 installed. You don't need MRTG though - we just stand on the shoulders of Inter7's log parsing to get our numbers.

In snmpd.conf:

extend qmail-message-status /usr/local/bin/qmailmrtg7 s /var/log/qmail
extend qmail-bytes-transfer /usr/local/bin/qmailmrtg7 b /var/log/qmail
extend qmail-smtp-concurrency /usr/local/bin/qmailmrtg7 t /var/log/smtpd
extend qmail-smtp-sessions /usr/local/bin/qmailmrtg7 a /var/log/smtpd
extend qmail-pop3-concurrency /usr/local/bin/qmailmrtg7 t /var/log/pop3d
extend qmail-pop3-sessions /usr/local/bin/qmailmrtg7 a /var/log/pop3d
extend qmail-queue /usr/local/bin/qmailmrtg7 q /var/qmail/queue
extend qmail-messages /usr/local/bin/qmailmrtg7 m /var/log/qmail
extend qmail-concurrency /usr/local/bin/qmailmrtg7 c /var/log/qmail

extend qmail-virus /usr/local/bin/qmailmrtg7 C /var/log/clamd
extend qmail-spam /usr/local/bin/qmailmrtg7 S /var/log/spamd

extend dnscache /usr/local/bin/dnscache-stats
dnscache-stats is a one-liner:

/usr/bin/grep stats /etc/dnscache/log/main/current | /usr/bin/tail -1 | /usr/bin/awk '{ printf("%d\n%d\n%d\n%d\n",$3,$4,$5,$6); }'
Now you can monitor with the following MIBs:
QMail Queue size
QMail Unprocessed Queue
QMail SMTPd Connections
djbdns queries
TODO: add rest of MIBs.

It's not exactly rocket-science, but it does mean you can get a central view of your Qmail servers in Cacti.

Copyright 1994-2005, by Howard Jones.