Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site uwmacc.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!uwvax!uwmacc!bllklly From: bllklly@uwmacc.UUCP (Bill Kelly) Newsgroups: net.news.adm Subject: Log cleanup and summary Message-ID: <724@uwmacc.UUCP> Date: Thu, 21-Feb-85 11:11:29 EST Article-I.D.: uwmacc.724 Posted: Thu Feb 21 11:11:29 1985 Date-Received: Tue, 26-Feb-85 06:10:20 EST Distribution: net Organization: UWisconsin-Madison Academic Comp Center Lines: 104 <> 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