Recently in Log Processing Category

Qmail Statistics

| | Comments (0)

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.
..............
..............
..............

If you get an error saying

/etc/cron.daily/logrotate:
error: error reading top line of /var/lib/logrotate.status
delete /var/lib/logrotate.status, and then run logrotate once with -f flag, like
 #> logrotate -f /etc/logrorate.d/syslog
This should initialize the status file and the error should not be repeating.

I had this requirement for moving/deleting the old bin log files of mysql from my server since they were hogging too much of the server space. I wrote this small script (might need polishing) to do the work.

Check it out and send me your feedback.

About this Archive

This page is a archive of recent entries in the Log Processing category.

HTC Touch is the previous category.

Maintenance is the next category.

Find recent content on the main index or look in the archives to find all content.

Powered by
Movable Type 4.01