Guide updated on 29th of February 2016

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network links. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic

Qmailmrtg7 takes the smtp and qmail transaction logs and sends them to different mrtg graphs.

aptitude install mrtg zlibc libpng12-dev

cd /downloads/
tar -zxvf qmailmrtg7-4.2.tar.gz
cd /downloads/qmailmrtg7-4.2
make && make install (Ignore compilation warning)

cd /usr/local/bin/
cp /downloads/scripts/courierstats .
mv /usr/local/bin/courierstats /usr/local/bin/courierstats.pl
chmod +x /usr/local/bin/courierstats.pl
(courierstats)

mkdir -p /var/www/mail/mrtg
cd /var/www/mail/mrtg
cp /downloads/scripts/index.mrtg .
sed -i "s/MRTGHOSTNAME/`hostname`/" /var/www/mail/mrtg/index.mrtg
mv /var/www/mail/mrtg/index.mrtg /var/www/mail/mrtg/index.html
(index.mrtg)

cd /etc/
mv /etc/mrtg.cfg /etc/mrtg.cfg.orig
cp /downloads/scripts/qmail.mrtg.cfg .
sed -i "s/MRTGHOSTNAME/`hostname`/" /etc/qmail.mrtg.cfg
mv /etc/qmail.mrtg.cfg /etc/mrtg.cfg
(qmail.mrtg.cfg)

Edit /etc/logrotate.d/rsyslog to rotate courier's log daily:

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
	rotate 30
	daily
	missingok
	notifempty
	compress
	delaycompress
	sharedscripts
	postrotate
		invoke-rc.d rsyslog reload > /dev/null
	endscript
}

Point your browser on http://mailadmin.yourdomain.tld/mrtg/ to check your stats (wait 10 minutes before having the first graphs)

Install Roundcubemail


Users comments
Color Coded Qmail Installation Key
  Regular Black Text     Qmail installation notes and summaries by the author.
  Bold Black Text     Commands to be run by you, the installer.
  Bold/Regular Red Text    Vital and/or critical information.
  Regular Blue text     Denotes helpful tips and hints or hyperlinks.
  Regular Orange Text     Command line output.
  Bold/Regular green text     Denotes the contents of a file or script.