"Ronny" == Ronny Haryanto <[EMAIL PROTECTED]> writes:

    Ronny> I use this script to send me a log analysis nightly (via crontab).
    Ronny> Add the z* commands as you like before ")| qmail-inject".

    Ronny> #!/bin/sh
    Ronny> PATH=/usr/local/qmailanalog/bin:/var/qmail/bin:/bin
    Ronny> QMAILLOG="/tmp/q.$$"
    Ronny> umask 077
    Ronny> cat /var/log/qmail/* | matchup > $QMAILLOG 5>/dev/null

    Ronny> DATE=`date +'%a %d %b'`

    Ronny> (echo "To: [EMAIL PROTECTED]"
    Ronny> echo "From: [EMAIL PROTECTED]"
    Ronny> echo "Subject: qmail report $DATE"
    Ronny> echo ""
    Ronny> zoverall < $QMAILLOG
    Ronny> zfailures < $QMAILLOG
    Ronny> zdeferrals < $QMAILLOG)| qmail-inject

    Ronny> rm -f $QMAILLOG

You really shouldn't be throwing away the output from fd5. It's there
for a reason. I use this script:

#!/bin/sh

PATH="/usr/local/bin/qmailanalog:/usr/local/bin:$PATH"
export PATH

umask 077

TMP_FILE="/var/log/qmail/qmailanalog.tmp"
EXT_FILE="/var/log/qmail/qmailanalog.ext"
OUT_FILE="/var/log/qmail/qmailanalog.out"
LOG_FILE="/var/log/qmail/log.1.gz"

rm -f $TMP_FILE $OUT_FILE

cat << MAIL_HEADER > $OUT_FILE
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: `hostname` qmail statistics

MAIL_HEADER

touch $EXT_FILE
(cat $EXT_FILE; gunzip -c $LOG_FILE | tai64nepoch) | matchup > $TMP_FILE 
5>$EXT_FILE.new
mv $EXT_FILE.new $EXT_FILE

zoverall < $TMP_FILE >> $OUT_FILE
echo "------------------------------------------" >> $OUT_FILE
zddist   < $TMP_FILE >> $OUT_FILE

/var/qmail/bin/qmail-inject < $OUT_FILE
rm -f $TMP_FILE $OUT_FILE

I've attached a patch for daemontools-0.61 which creates tai64nepoch,
something I hacked from tai64nlocal. I happen to rotate my logs
nightly, using qfilelog instead of using multilog (rotating logs based
on size is fine, but multilog really should support logs rotated based
on time as well - something as simply as rotating whenever it receives
a HUP or USR1 would make me happy).

j.
--
Jay Soffian <[EMAIL PROTECTED]>                            UNIX Systems Engineer
404.572.1941                                             Cox Interactive Media

Reply via email to