[net.news.adm] Log cleanup and summary

bllklly@uwmacc.UUCP (Bill Kelly) (02/21/85)

<>

Here's something that might be of use to news administrators.
As far as I can tell, the news log files grow indefinitely.
Enclosed are a shell script to move the log file to an old log
file when run (I run this nightly with cron), and an awk program
to summarize a 2.10.2 form log file.  Actually, the script keeps
a series of old log files in /usr/lib/news/OLDLOGS, so you have
a little leeway in noticing a problem before the logs disappear.
Oh, one other unusual thing, the script also looks for log.unbatch
file, something I added locally to track down a specific problem.
The awk program looks for the usual
things you see in a log file and counts them, printing out 
unusual things in a separate list.

# ----cut here and run thru sh, not csh----------------------
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by maccunix!bllklly on Thu Feb 21 10:03:02 CST 1985
# Contents:  cleanup cleanup.awk
 
echo x - cleanup
sed 's/^@//' > "cleanup" <<'@//E*O*F cleanup//'
#! /bin/csh
# Shell script to cull unusual messages from news log file
# and clean up old log files automatically in similar manner to
# /usr/adm/newlog
cd /usr/lib/news
# Send error messages and summary to administrator
( cat errlog ; awk -f cleanup.awk log ) | mail -s "News Summary" usenet
cp /dev/null errlog
# Copy logfile
foreach LOG (log log.unbatch)
    cd /usr/lib/news/OLDLOGS
    rm $LOG.7
    mv $LOG.6  $LOG.7
    mv $LOG.5  $LOG.6
    mv $LOG.4  $LOG.5
    mv $LOG.3  $LOG.4
    mv $LOG.2  $LOG.3
    mv $LOG.1  $LOG.2
    mv $LOG.0  $LOG.1
    mv ../$LOG $LOG.0
    cd ..
    cp /dev/null $LOG
    chown news   $LOG
    chmod 666    $LOG
end
@//E*O*F cleanup//
chmod u=rwx,g=rx,o=rx cleanup
 
echo x - cleanup.awk
sed 's/^@//' > "cleanup.awk" <<'@//E*O*F cleanup.awk//'
BEGIN {errors=0; badlinecounts=0; received=0; posted=0; dups=0;
	cancelled=0; cfail=0; csuccess=0; cgroups=0; ctlmsgs=0; old=0}
/Bad option/{next}
/Duplicate/{dups++; next}
/Ctl Msg/  {ctlmsgs++; next}
/Article too old/  {old++; next}
/posted/   {posted++; next}
# Sent to corresponds to posted, except for local group postings.
/sent to/     {next}
/subj 'cmsg cancel/{cancelled++; next}
/subj 'cancel/{cancelled++; next}
/Can't cancel/{cfail++; next}
/Cancelling/{csuccess++; next}
/cancel article/{cgroups++; next}
/from/ {next}
/received/ {received++; next}
/linecount/{badlinecounts++; next}
	{if (length==0) next;
	if (errors++ == 0) {
		print "Miscellaneous errors:";
		}
	 print; next}
/cancel/ {next}
END {print "     SUMMARY"
     if (posted)
	print posted,"articles posted."
     if (ctlmsgs)
	print ctlmsgs,"control messages received."
     if (received)
	print received,"articles received."
     if (old)
	print old " old articles moved to junk."
     if (dups)
	print dups,"duplicate articles rejected."
     if (badlinecounts)
	print badlinecounts,"articles/duplicates had bad line counts."
     if (cancelled) {
	print cancelled " articles cancelled, " cfail " unsuccessfully,"
	print "   " csuccess " successfully in " cgroups " groups."
     }
}
@//E*O*F cleanup.awk//
chmod u=rwx,g=rx,o=rx cleanup.awk
 
exit 0
-- 

Bill Kelly
{allegra, ihnp4, seismo}!uwvax!uwmacc!bllklly
1210 West Dayton St/U Wisconsin Madison/Mad WI 53706

dave@uwvax.UUCP (Dave Cohrs) (02/21/85)

> Here's something that might be of use to news administrators.
> As far as I can tell, the news log files grow indefinitely.
> Enclosed are a shell script to move the log file to an old log
> file when run...

There is a shellscript 'trimlog' which is distributed with 2.10.2 news.
It performs this same function, without the extra old logfiles, it
only keeps one logfile.

-- 
dave cohrs
...!{allegra,harvard,ihnp4,seismo}!uwvax!dave
dave@wisc-rsch.arpa

    (bug?  what bug?  that's a feature!)

phil@amdcad.UUCP (Phil Ngai) (02/23/85)

> There is a shellscript 'trimlog' which is distributed with 2.10.2 news.
> It performs this same function, without the extra old logfiles, it
> only keeps one logfile.
> -- 
> dave cohrs

I *like* having the little log files. It makes it easy to see what
happened on a particular day.
-- 
 This is my opinion, I guess.

 Phil Ngai (408) 749-5720
 UUCP: {ucbvax,decwrl,ihnp4,allegra}!amdcad!phil
 ARPA: amdcad!phil@decwrl.ARPA