Subject: tallyho wrapper for INN [was Re: Daily Statistics [script]]

From: [email-masked] (Kean Stump)
Date: 9 Dec 92 22:25:12 GMT

To use tallyho nicely with INN, add this to your newsfeeds file:

TALLY:*:Tf,Wnb:/var/log/news/tally/tally

then run the enclosed script after your news.daily.

I took sendbatches (thanks to [email-masked] for 
the INN version of sendbatches), removed the batching section from it, added
in log rotation for my site and a call to tallyho.  Run tally.driver 
after your news.daily executes.  I haven't checked control conflicts
between this script and innd, hence run it after news.daily.

This appears to work for me.  Your mileage may vary, if this breaks you're
guaranteed to posess at least two pieces of broken code etc etc.

--kean

ps - tallyho may be retrieved from ftp.cs.toronto.edu:pub/news/{tallyho,
tally.doc}.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  tally.driver
# Wrapped by [email-masked] on Wed Dec  9 14:11:02 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'tally.driver' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tally.driver'\"
else
echo shar: Extracting \"'tally.driver'\" \(1789 characters\)
sed "s/^X//" >'tally.driver' <<'END_OF_FILE'
X#! /bin/sh
X##  $Revision: 1.1 $
X##  SH script to drive tally
X
X# =()<NEWSBIN=@<_PATH_NEWSBIN>@>()=
XNEWSBIN=/inn/bin
XTALLYHO=tallyho
XTALLY=tally
XPATH=${NEWSBIN}/batch:${NEWSBIN}:${PATH}:/bin:/usr/bin:/usr/ucb:/inn/local/bin; export PATH
X
X# =()<LOG=@<_PATH_LOGDIR>@>()=
XLOG=/var/log/news/tally
X# =()<BATCH=@<_PATH_BATCHDIR>@>()=
XBATCH=/inn/spool/out.going
X# =()<LIB=@<_PATH_NEWSLIB>@>()=
XLIB=/inn/lib
X# =()<LOCKS=@<_PATH_LOCKS>@>()=
XLOCKS=/inn/locks
X## =()<TMPDIR=${TMPDIR-@<_PATH_TMP>@}>()=
XTMPDIR=${TMPDIR-/tmp}
XXPID=$$ ; export XPID
X
XPNAME=`basename $0`
XCTLFILE=${LIB}/${PNAME}.ctl
X
X## Go to the right dir
Xcd ${LOG}
X
X##  Anyone else there?
XLOCK=${LOCKS}/LOCK.tally
Xtrap 'rm -f ${LOCK} ; exit 1' 1 2 3 15
Xshlock -p $$ -f ${LOCK} || {
X    echo "${PNAME}: [$$] locked by [`cat ${LOCK}`]"
X    exit 0
X}
X
X# Hackery.  Will fix later, if we really care...
XLIST=tally
X#if [ ! -z "$1" ] ; then
X#    LIST="$*"
X#else
X#    echo "${PNAME}: [$$] no site specified"
X#    exit 1
X#fi
X
X
X##  Do the log...
Xfor SITE in ${LIST}; do
X    BATCHFILE=${SITE}.tmp
X    if [ -f ${SITE}.log ] ; then
X        cat ${SITE}.log >>${BATCHFILE}
X        rm ${SITE}.log
X    fi
X    mv ${SITE} ${SITE}.log
X    ctlinnd -s -t30 flush ${SITE} || {
X       echo "${PNAME}: [$$] Can't flush ${SITE}."
X       continue
X    }
X    cat ${SITE}.log >>${BATCHFILE}
X    rm -f ${SITE}.log
X    if [ ! -s ${BATCHFILE} ] ; then
X        echo "${PNAME}: [$$] no articles for ${SITE}"
X        continue
X    fi
X
Xecho "INN traffic stats for `date`"
X	$TALLYHO ${BATCHFILE}
X
X	cat $TALLY.7 >>$TALLY.all
X	mv $TALLY.6 $TALLY.7
X	mv $TALLY.5 $TALLY.6
X	mv $TALLY.4 $TALLY.5
X	mv $TALLY.3 $TALLY.4
X	mv $TALLY.2 $TALLY.3
X	mv $TALLY.1 $TALLY.2
X	mv $TALLY.0 $TALLY.1
X	cp ${BATCHFILE} $TALLY.0
X	rm -f ${BATCHFILE}
X
X
Xdone
X##  Remove the lock file.
Xrm -f ${LOCK}
Xexit 0
END_OF_FILE
if test 1789 -ne `wc -c <'tally.driver'`; then
    echo shar: \"'tally.driver'\" unpacked with wrong size!
fi
chmod +x 'tally.driver'
# end of 'tally.driver'
fi
echo shar: End of shell archive.
exit 0
-- 
Kean Stump   
[email-masked]                                         (503)-737-4740 
Oregon State Network Operations                           Cthulu Saves, In Case 
OSU doesn't pay me enough to have official opinions.      It's Hungry Later