Once You Know, You Newegg
Home FAQ Qmail Getting qmailstats to show daily stats only
Getting qmailstats to show daily stats only PDF Print E-mail
Tuesday, 07 April 2009 00:46

For those that are interested, I've found making the following changes
works well.  Since qmailrocks sets up the qmailstats to run once a
day, I changed it to only look at the last days worth (the only way
this works is if you set multilog to rotate the logs (according to its
log size) no more than once a day.

edit the /var/qmail/qmailstats script (which should be in the
/etc/crontab to run once daily) by changing the line:

cat /var/log/qmail/qmail-send/* /var/log/qmail/qmail-pop3d/*
/var/log/qmail/qmail/qmail-smtpd/* | tai64n2tai | awk
'{$1=substr($1,1,index($1,".")+6);print}' | matchup > $QMAILSTATS
5>/dev/null

to:

cat /var/log/qmail/qmail-send/current
/var/log/qmail/qmail-pop3d/current
/var/log/qmail/qmail/qmail-smtpd/current | tai64n2tai | awk
'{$1=substr($1,1,index($1,".")+6);print}' | matchup > $QMAILSTATS
5>/dev/null

What this does it tells the qmailanalog to only look at the log files
that haven't been rotated yet.  Next, add the following line to the
very bottom of the script:

svc -h /service/qmail-smtpd/log /service/qmail-pop3d/log /service/qmail-send/log

I believe -a will work as well, but since I don't understand what it
does and I know the -h works, that's what I'm using.

This forces multilog to rotate the logs whether they need it or not.
If you have multilog set to rotate large files (for my small server
100k is ample), then you'll end up with a rotation once a day and your
qmailstats email (once a day) will reflect only the previous 24 hours.

DISCLAIMER: This may undo multilogs excellent method of using only a
certain amount of disk space for logs, so...  Keep an eye on your logs
and make sure you have enough history for your liking and not taking
up too much disk space.  Tweak the multilog settings (found in
/service/foo/log/run ) accordingly.  As always make backups of
everything before editing, and take my advice with great skepticism

Special thanks to Silver Fox