#!/bin/sh ## $Revision: 1.4 $ ## Tally/update the unwanted newsgroup log ## Read an innd log on stdin, scan it for articles that were unwanted ## because they newsgroups were not in our active file. Update unwanted.log ## to have the new count of unwanted groups, and how often they were used. ## =()<. @<_PATH_SHELLVARS>@>()= . /usr/lib/news/innshellvars PROGNAME=unwanted LOCK=${LOCKS}/LOCK.${PROGNAME} LOG=${MOST_LOGS}/unwanted.log UNWANTED_NEW=${LOG}.new UNWANTED_OLD=${LOG}.old ## Lock. shlock -f ${LOCK} -p $$ || { echo "$0: cannot lock $LOCK" 1>&2 exit 2 } ## Prepare the files. if [ ! -f ${LOG} ]; then touch ${LOG} chmod 0660 ${LOG} fi rm -f ${UNWANTED_NEW} ${UNWANTED_OLD} ln ${LOG} ${UNWANTED_OLD} touch ${UNWANTED_NEW} chmod 0660 ${UNWANTED_NEW} ## Grab the data. ${AWK} '$4 == "-" && $7 == "437" && $8 == "Unwanted" { print }' \ | ${SED} 's/.*"\(.*\)".*/\1/' \ | sort \ | uniq -c \ | cat - ${LOG} \ | ${AWK} 'BEGIN { unwanted[0]=0; } { unwanted[$2] += $1; } END { for (group in unwanted) { if (group != 0) { print unwanted[group], group; } } }' \ | sort -n -r >${UNWANTED_NEW} mv -f ${UNWANTED_NEW} ${LOG} ## All done. rm -f ${LOCK} exit 0