I also found some ideas/documentation (which I have not read yet) at:
http://llug.sep.bnl.gov/doc/mrtg/examples/mrtg-mail/
http://www.jsw4.net/resources/mrtg-stuff/examples.html
http://spark.student.utwente.nl/doc/mrtg/examples/mrtg-mail/
(This is included with Debian under /doc/mrtg/examples/mrtg-mail/)
(I would also like to be able to do this with Exim and Postfix. If you have ideas, please share them.)
I am using mrtg-mailstats (available from http://mail.mandli.com/~jrowan/mrtg-mailstats.html), MRTG version 2.8.12 and mailstats (which comes with Sendmail).
On the system running MRTG, I have the following cron jobs:
*/5 * * * * root /usr/local/mrtg/mrtg /usr/local/mrtg/mail-mrtg.cfg 2>&1 > /dev/null */5 * * * * root /usr/local/mrtg/mrtg /usr/local/mrtg/mail-mrtg-msgs.cfg 2>&1 > /dev/nullmail-mrtg.cfg
WorkDir: /usr/local/mrtg/docs # gather statistics from mail server with the mailerstats # program running on port 2525 # count bytes instead of messages Target[mail.remote]: `/usr/local/mrtg/mrtg-mailstats -b -s mail.server.here -p 2525` MaxBytes[mail.remote]: 1250000 Title[mail.remote]: mail.server.here Mail Traffic (bytes) PageTop[mail.remote]: <font size="+1"><b>mail.server.here Mail Traffic</b><br>\n Bytes per second</font><br>\n <font size=2>Maintainer: <a href="mailto:postmaster@mail.server.here">postmaster@mail.server.here</a></font><br>\n YLegend[mail.remote]: Bytes per second WithPeak[mail.remote]: ymw ShortLegend[mail.remote]: b/sec
mail-mrtg-msgs.cfg
WorkDir: /usr/local/mrtg/docs # gather statistics from mail.server.here with the mailerstats # program running on port 2525 # counting messages instead of bytes Target[mail.messages]: `/usr/local/mrtg/mrtg-mailstats -f 60 -s mail.server.here -p 2525` MaxBytes[mail.messages]: 999999999 Title[mail.messages]: mail.server.here Mail Traffic (Messages per minute) PageTop[mail.messages]: <font size="+1"><b>mail.server.here Mail Traffic</b><br>\n Messages per minute</font><br>\n <font size=2>Maintainer: <a href="mailto:postmaster@mail.server.here">postmaster@mail.server.here</a></font><br>\n YLegend[mail.messages]: Messages/minute WithPeak[mail.messages]: ymw ShortLegend[mail.messages]: Messages/min
On the mail server, I use inetd to run mailstats. My /etc/inetd.conf file contains:
#run mailstats on port 2525 smtp-stats stream tcp nowait nobody /usr/libexec/tcpd /usr/sbin/mailstatsThe /etc/services has:
smtp-stats 2525/tcp snmp-stats