Logging qmail statistics using QmailMrtg in Linux
What is qmailmrtg ?
QmailMrtg uses qmail’s excellent and extensive logging via multilog, tcpserver and qmail-send. qmailmrtg7 takes the pop3 smtp and qmail transaction logs and sends them to 9 different mrtg graphs, each graph with 4 historical time series.
qmailmrtg Requirements
mrtg
qmail
tcpserver
multilog
Download qmailmrtg
http://www.inter7.com/index.php?page=qmailmrtg7
qmailmrtg FAQ
http://www.inter7.com/qmailmrtg7/FAQ
First thing is you need to install qmail server with multilog,tcp server support and mrtg
If you want to install qmail server check here
If you want to install mrtg check here
Qmailmrtg Installation and Configuration Linux
Make sure you have qmail and mrtg install in your linux box.
# cd /usr/local/src/
# wget http://www.inter7.com/qmailmrtg7/qmailmrtg7-4.2.tar.gz
# tar zxvf qmailmrtg7-4.2.tar.gz
# cd qmailmrtg7-4.2
# make
#make install
#mkdir /var/www/html/qmail-stats/mrtg/
#cp index.html /var/www/html/qmail-stats/mrtg/
#cp /tmp/qmailmrtg7-4.2/qmail.mrtg.cfg /etc/qmail.mrtg.cfg
Edit vi /etc/qmail.mrtg.cfg and change the log file locations to where you store your logs and other configuration.
First, replace all instances of "FQDN" with your domain name.
Now we're going to set the proper logging paths for each of the Qmail functions listed in this file. Below, I've copied to entire contents of the file and highlighted areas that you will need to customize. The paths I've included should work just fine IF you've installed Qmail according to this site. If you haven't, you may have to adjust the paths accordingly..
WorkDir: /path/to/your/qmailstats/directory (Example: /var/www/html/qmailstats)
#############################################################
Title[msg]: mydomain.com - Messages
MaxBytes[msg]: 10000
AbsMax[msg]: 20000
Options[msg]: gauge
Target[msg]: `/usr/local/bin/qmailmrtg7 m /var/log/qmail/qmail-send` (The path to the qmail-send logs)
PageTop[msg]: <B>mydomain.com Messages</B><br>
ShortLegend[msg]: msg
YLegend[msg]: msg
Legend1[msg]: Total Msg
LegendI[msg]: Deliveries:
LegendO[msg]: Attempts:
WithPeak[msg]: ymwd
#-------------------------------------------------------------------
Title[queue-size]: mydomain.com - Queue Size
MaxBytes[queue-size]: 10000
AbsMax[queue-size]: 100000
Options[queue-size]: gauge
Target[queue-size]: `/usr/local/bin/qmailmrtg7 q /var/qmail/queue` (This should reflect the path the Qmail's Queue)
PageTop[queue-size]: <B>mydomain.com Queue Size</B><br>
ShortLegend[queue-size]: Msg
YLegend[queue-size]: Msg
Legend1[queue-size]: Msg
LegendI[queue-size]: Msg:
LegendO[queue-size]: Unprocessed Msg:
WithPeak[queue-size]: ymwd
#-------------------------------------------------------------------
Title[concurrency]: mydomain.com - Local/Remote Concurrency
MaxBytes[concurrency]: 500
AbsMax[concurrency]: 10000
Options[concurrency]: gauge
Target[concurrency]: `/usr/local/bin/qmailmrtg7 c /var/log/qmail/qmail-send` (The path to the qmail-send logs)
PageTop[concurrency]: <B>mydomain.com - Local/Remote Concurrency</B><br>
ShortLegend[concurrency]: Concurrency
YLegend[concurrency]: Concurrency
Legend1[concurrency]: Concurrency
LegendI[concurrency]: Local:
LegendO[concurrency]: Remote:
WithPeak[concurrency]: ymwd
#-------------------------------------------------------------------
Title[messstatus]: mydomain.com - Message Status
MaxBytes[messstatus]: 10000
AbsMax[messstatus]: 100000
Options[messstatus]: gauge
Target[messstatus]: `/usr/local/bin/qmailmrtg7 s /var/log/qmail/qmail-send` (The path to the qmail-send logs)
PageTop[messstatus]: <B>mydomain.com - Message Status</B><BR>
ShortLegend[messstatus]: Msg
YLegend[messstatus]: Msg
Legend1[messstatus]: Msg
LegendI[messstatus]: Success:
LegendO[messstatus]: Failures:
WithPeak[messstatus]: ymwd
#-------------------------------------------------------------------
Title[bytes]: mydomain.com - Bytes Transfered
MaxBytes[bytes]: 200000
AbsMax[bytes]: 30000000
Options[bytes]: gauge
Target[bytes]: `/usr/local/bin/qmailmrtg7 b /var/log/qmail/qmail-send` (The path to the qmail-send logs)
PageTop[bytes]: <B>mydomain.com - Bytes Transfered</B><br>
ShortLegend[bytes]: kB
YLegend[bytes]: kB
Legend1[bytes]: kB
LegendI[bytes]: kB:
LegendO[bytes]: kB:
WithPeak[bytes]: ymwd
#-------------------------------------------------------------------
Title[smtp]: mydomain.com - SMTP Concurrency
MaxBytes[smtp]: 100
AbsMax[smtp]: 500
Options[smtp]: gauge
Target[smtp]: `/usr/local/bin/qmailmrtg7 t /var/log/qmail/qmail-smtpd` (The path to the qmail-smtpd logs)
PageTop[smtp]: <B>mydomain.com - SMTP Concurrency</B><BR>
ShortLegend[smtp]: SMTP
YLegend[smtp]: SMTP
Legend1[smtp]: SMTP
LegendI[smtp]: SMTP:
LegendO[smtp]:
WithPeak[smtp]: ymwd
#-------------------------------------------------------------------
Title[smtpad]: mydomain.com - SMTP Totals
MaxBytes[smtpad]: 1000
AbsMax[smtpad]: 10000
Options[smtpad]: gauge
Target[smtpad]: `/usr/local/bin/qmailmrtg7 a /var/log/qmail/qmail-smtpd` (The path to the qmail-smtpd logs)
PageTop[smtpad]: <B>mydomain.com - SMTP Totals</B><BR>
ShortLegend[smtpad]: SMTP
YLegend[smtpad]: SMTP
Legend1[smtpad]: SMTP
LegendI[smtpad]: Allow:
LegendO[smtpad]: Deny:
WithPeak[smtpad]: ymwd
#-------------------------------------------------------------------
Title[pop3]: mydomain.com - POP3 Concurrency
MaxBytes[pop3]: 100
AbsMax[pop3]: 500
Options[pop3]: gauge
Target[pop3]: `/usr/local/bin/qmailmrtg7 t /var/log/qmail/qmail-pop3d` (The path to the qmail-pop3d logs)
PageTop[pop3]: <B>mydomain.com POP3 Concurrency</B><BR>
ShortLegend[pop3]: POP3
YLegend[pop3]: POP3
Legend1[pop3]: POP3
LegendI[pop3]: POP3:
LegendO[pop3]:
WithPeak[pop3]: ymwd
#-------------------------------------------------------------------
Title[pop3ad]: mydomain.com - POP3 Totals
MaxBytes[pop3ad]: 1000
AbsMax[pop3ad]: 10000
Options[pop3ad]: gauge
Target[pop3ad]: `/usr/local/bin/qmailmrtg7 a /var/log/qmail/qmail-pop3d` (The path to the qmail-pop3d logs)
PageTop[pop3ad]: <B>mydomain.com - POP3 Totals</B><BR>
ShortLegend[pop3ad]: POP3
YLegend[pop3ad]: POP3
Legend1[pop3ad]: POP3
LegendI[pop3ad]: Allow:
LegendO[pop3ad]: Deny:
WithPeak[pop3ad]: ymwd
Add a crontab line
*/5 * * * * /usr/bin/mrtg /etc/qmail.mrtg.cfg (where ever you qmail stats config file path)
Run /usr/bin/mrtg /etc/qmail.mrtg.cfg for manually update
#/usr/bin/mrtg /etc/qmail.mrtg.cfg
Useful Tip :- In order to get qmailmrtg running correctly, you will need to run it 3 times in a row the first time you use it. The first and second times you run it, you will see a bunch of output as qmailmrtg sets itself up. On the 3rd run there will be no output, which is how qmailmrtg will behave from then on.
You have wait 15-20 min to show your graphs
Go to http://yourdomain.com/qmail-stats/mrtg/