Qmail Statistics

Being a sendmail guy, I was wondering if qmail had any mail log parser. I came across qmailanalog but then, it came with no useful docs on using it. I got some info on the net, and this is how you do it.

#!/bin/sh
#
PATH=/usr/local/qmailanalog/bin:/var/qmail/bin:$PATH
MAILLOG=”/var/log/maillog”
QMAILLOG=”/tmp/qmail.$$”
/usr/bin/awk ‘{$1=””;$2=””;$3=””;$4=””;$5=””;print}’ < $MAILLOG | matchup > $QMAILLOG
(
echo “To: rampras@domain.com”
echo “From: ram@domain.com”
echo “Subject: maillog”
echo “”
./zoverall < $QMAILLOG ./zfailures < $QMAILLOG ./zdeferrals < $QMAILLOG ./recipients < $QMAILLOG ./senders < $QMAILLOG) | qmail-inject -f ram@domain.com rm -f $QMAILLOG

This produces a very nice summary like the following:

Basic statistics

qtime is the time spent by a message in the queue.

ddelay is the latency for a successful delivery to one recipient—the
end of successful delivery, minus the time when the message was queued.

xdelay is the latency for a delivery attempt—the time when the attempt
finished, minus the time when it started. The average concurrency is the
total xdelay for all deliveries divided by the time span; this is a good
measure of how busy the mailer is.

Completed messages: 181
Recipients for completed messages: 234
Total delivery attempts for completed messages: 235
Average delivery attempts per completed message: 1.29834
Bytes in completed messages: 1651675
Bytes weighted by success: 1724065
Average message qtime (s): 2.6932

Total delivery attempts: 242
success: 220
failure: 14
deferral: 8
Total ddelay (s): 495.335359
Average ddelay per success (s): 2.251524
Total xdelay (s): 521.833090
Average xdelay per delivery attempt (s): 2.156335
Time span (days): 1.59635
Average concurrency: 0.00378347
Reasons for failure
………………
………………
………………
One line per reason for delivery failure. Information on each line:
* del is the number of deliveries that ended for this reason.
* xdelay is the total xdelay on those deliveries.
…………..
…………..
…………..