Drew Hawn <[EMAIL PROTECTED]> wrote:
> Please tell me what I'm doing wrong!  :)  Somebody has to be doing this
> properly, and it's sure not me.  
> 
> What I want is simple enough, I want to know how many messages were
> sent/received, etc. June 18th.  That information is contained within my
> "current" file, but I can find no way to report on this data using
> qmailanalog, tai64n, tai64nlocal, tai64n2tai, etc. 
> 
> I have a "current" log file that contains log entries that span
> approximately 1 week.  I can successfully use qmailanalog to view
> information about the messages that were sent and logged into my "current"
> file.  This gives me information beginning when the log file was created and
> ending at the last entry of the log file, but I don't want a report that
> spans the entire week, I want one for a particular day.

I have a script that runs every night to give me a summary of the day's
activity on each mail server.  There's a slightly different version that does
it at the end of the month for a month's logs.  This script may have
bash-specific constructions, it's not optimized, and it uses tools from Bruce
Guenter's qlogtools package in addition to daemontools and qmail-analog.  Pick
up Bruce's software at untroubled.org.

#!/bin/bash
set -e
HOST=`hostname -f`
MAILTO=admin-mailstats@your_domain
export PATH="$PATH:/root/bin:/usr/bin/qmailanalog"
tmpdir=/tmp/qmail-cron.$$.$RANDOM
mkdir $tmpdir
pushd $tmpdir >/dev/null

s_year=`date -d '1 day ago' +%Y`
s_month=`date -d '1 day ago' +%m`
s_day=`date -d '1 day ago' +%d`
e_year=`date +%Y`
e_month=`date +%m`
e_day=`date +%d`

start="$s_year-$s_month-$s_day"
end="$e_year-$e_month-$e_day"

LOGDIR=/var/log/qmail

cat "$LOGDIR"/{"@",cur}* \
  | tai64n2tai \
  | qlogselect start $start end $end \
  | matchup >logfile 5>/dev/null

for ana in zoverall zddist zdeferrals zfailures zrhosts zsuids zrxdelay; do
  $ana 2>/dev/null <logfile >$ana
  attach="$attach -a $ana"
done
rm -f logfile
mutt -s "$HOST: mailstats for $s_year-$s_month-$s_day" \
  -x $attach $MAILTO </dev/null
popd >/dev/null
rm -rf $tmpdir


Change the list list of reports you want as appropriate.  You'll also likely
have to change the PATH setting, etc in the script.

> For Charles sake, I don't want to simply look at the log files.  I want a
> qmailanalog-style report on a subset of the information contained within my
> "current" file.

Just like the above?  :)

Charles

P.S.  Russell, if there's any interest in putting this up on your site, feel
free to make a local copy.  I don't have it on any ftp or http servers at the
moment.
-- 
-----------------------------------------------------------------------
Charles Cazabon                            <[EMAIL PROTECTED]>
GPL'ed software available at:  http://www.qcc.sk.ca/~charlesc/software/
Any opinions expressed are just that -- my opinions.
-----------------------------------------------------------------------

Reply via email to