Xref: utzoo news.software.b:1959 news.admin:4926 Path: utzoo!mnetor!tmsoft!mason From: mason@tmsoft.uucp (Dave Mason) Newsgroups: news.software.b,news.admin Subject: News/Mail status Extraction Message-ID: <1989Feb24.183022.20381@tmsoft.uucp> Date: 24 Feb 89 18:30:22 GMT Reply-To: mason@tmsoft.UUCP (Dave Mason) Followup-To: news.software.b Organization: TM Software Assocaiates Inc., Toronto, Ontario, Canada Lines: 147 This is my version of a stats program that several people in the Toronto area use. It does news, mail, and uucp including backlogs. You will doubtless have to hack on this to change the statistics gathering portion of the code. This uses Cnews and smail log files. ../Dave --------------------------------------------------- # Copyright 1989 Dave Mason, Toronto, Canada, All rights reserved # This software can be used for any purpose, so long as this notice # stays intact and the following people are correctly attributed. # This software is provided AS IS, with NO GUARANTEES. USE AT # YOUR OWN RISK. # # Mark Brader msb@sq ...87 original code # (public domain) # # David Sherman dave@lsuc 87 & 88 hacking # (public domain) # # Dave Mason mason@tmsoft 89-01-05 added backlog # 89-02-03 added mail information # # site=tmsoft cat < *(.*)/> /'|awk ' # utzoo + <...> hcr ncrcan sickkids $5 == "+" { rec[$4]++; } # utzoo - <....> duplicate $7 == "duplicate" { dup[$4]++; } $5 == "+" && NF > 6 { for (i = 7; i <= NF; ++i) { if ($i=="x"||$i=="unix"||$i=="misc"||$i=="games") snt[""]++ else snt[$i]++; } } END { for (sys in rec) {all[sys]=0;rT+=rec[sys]} for (sys in dup) {all[sys]=0;dT+=dup[sys]} for (sys in snt) {all[sys]=0;sT+=snt[sys]} all["Total"]=0 rec["Total"]=rT;dup["Total"]=dT;snt["Total"]=sT for (sys in all) print sys, 0, 0, 0, rec[sys]+0, dup[sys]+0, snt[sys]+0 }' | sed 's/[.][Uu][Uu][Cc][Pp]// s/,//' # # now gather UUCP transfer information # awk <${2-/usr/spool/uucp/SYSLOG.last} ' $6=="->" {w=substr($1,1,index($1,"!")-1);snt[w] += $7; snt["Total"] += $7; total[w] += $7;time[w] += $9;time["Total"] += $9} $6=="<-" {w=substr($1,1,index($1,"!")-1);rec[w]+=$7; rec["Total"]+=$7; total[w]+=$7;time[w] += $9;time["Total"] += $9} END { total["Total"] = snt["Total"] + rec["Total"] for (sys in total) print sys, total[sys], rec[sys]+0, snt[sys]+0,0,0,0,0,time[sys]} ' # # get UUCP backlog statistics # uuq | awk ' {w=substr($1,1,length($1)-1) print w,0,0,0,0,0,0,0,0,$2,$9+0 }' # # extract mail volumes queued from smail log file # if test -s /usr/lib/newsbin/maint/mailsize then # this bit is so we get the portion of the log file we haven't output before c=`wc -l /usr/spool/uucp/mail.log|sed -e 's/^[ ]*//' -e 's/[ ].*//'` ms=`cat /usr/lib/newsbin/maint/mailsize` if test "$c" -lt "$ms" then ms="$c" fi else ms=0 fi awk 'BEGIN{from[SITE]=0} NR<='$ms' {next} $5~/!/{ ++from[substr($5,1,index($5,"!")-1)] } $(NF-1)~/!/{ ++to[substr($(NF-1),1,index($(NF-1),"!")-1)] } END{ for (s in from) to[s] += 0 for (s in to) if (sys!=SITE) { print s,0,0,0,0,0,0,0,0,0,0,from[s]+0,to[s] tf+=from[s] tt+=to[s] } print "Total",0,0,0,0,0,0,0,0,0,0,tf,tt print NR >"/usr/lib/newsbin/maint/mailsize" }' SITE=$site /usr/spool/uucp/mail.log # # OK, we've extracted all the info, now format it # ) | awk ' { sys = substr($1,0,6) if (length($1) > length(n[sys])) n[sys] = $1 t[sys] += $2; r[sys] += $3; s[sys] += $4 a[sys] += $5; d[sys] += $6; q[sys] += $7; local += $8 i[sys] += $9; j[sys] += $10; b[sys] += $11 mf[sys]+= $12; mt[sys]+=$13 } END { for (sys in t) if (sys != SITE) { if (i[sys]==0) av=0 else av=int(t[sys]/i[sys]) if (substr(n[sys],1,1)=="<") t[sys]= 1 printf "%12d:%-12s%7d%6d%7d%6d%5d%8d%7d%6d", t[sys]-b[sys], \ n[sys], a[sys], d[sys], q[sys], mf[sys], mt[sys], \ int((r[sys]+999)/1000), int((s[sys]+999)/1000), av if (sys == "Total") printf("\n") else if (b[sys]<1) printf("%5d \n",j[sys]) else if (b[sys]==1) printf("%5d 1 hour\n",j[sys]) else if (b[sys]<=24) printf("%5d %2d hours\n", j[sys],b[sys]) else printf("%5d %4.1f days\n", j[sys],b[sys]/24) } else printf "%12d:%19d originated locally\n", -1000, a[sys] }' SITE=$site - | sort -r -n +0 -1| sed 's/.*:// s/ \([^ ]*[0-9]\)\([0-9][0-9][0-9][^0-9]\)/\1,\2/g s/ \([^ ]*[0-9]\)\([0-9][0-9][0-9][^0-9]\)/\1,\2/g /Total/ !s/ 0 / /g s/ *$// 1s/$/\ /' # /locally/s/ orig/0 orig/ # this line used to follow the /Total/ line in the sed script