Xref: utzoo news.admin:8656 news.software.b:4513 Path: utzoo!dciem!nttor!contact!ross From: ross@contact.uucp (Ross Ridge) Newsgroups: news.admin,news.software.b Subject: Re: cnews reporting Message-ID: <1990Apr6.123442.20375@contact.uucp> Date: 6 Apr 90 12:34:42 GMT References: <1990Apr5.044943.2355@comspec.uucp> Reply-To: ross@contact.UUCP (Ross Ridge) Distribution: na Organization: Contact Public Unix BBS. Toronto, Canada. Lines: 212 In article <1990Apr5.044943.2355@comspec.uucp> rick@comspec.uucp (Rick McCalla) writes: >Does anyone have an awk script or c program that can scan the log files >created by cnews and produce a report of how many articles received /sent >per site, error messages, groups received etc. ? A while ago I posted an awk script to generate a report from the C news log file, however it didn't work on older awks, and got Ihave/Sendme all wrong. This is a corrected version. It generates a report like this: Sitename Accept Reject Junked I-have Sendme Total Sent ------------------------------------------------------------------------------ bkj386 875 contact 3 3 geac 3504 6 3510 7 nttor 127 1881 2008 23 Totals: 3634 1887 5521 905 Junked Newsgroups: Why articles were rejected: duplicate: 1884 <> brackets missing in Message-ID: 3 Ross Ridge ------------------------------------------------------------------------------- # # newsstats.awk -- by Ross Ridge (ross@contact.uucp) Public Domain # fixed for old awks and ihave/sendme # # for older awks... BEGIN { why[""]=""; badngs[""]=""; } # $5 == "+" { accepted[$4]++; for(i = 7; i <= NF; i++) { sent[$i]++; name[$i] = $i; } } # $5 == "-" { rejected[$4]++; s = "" for(i = 7; i <= NF; i++) s = s " " $i why[s]++ } # $5 == "j" { junked[$4]++; badngs[$NF]++; } # $5 == "i" { ihave[$4]++; for(i = 7; i <= NF; i++) { sent[$i]++; name[$i] = $i; } } # $5 == "s" { sendme[$4]++; for(i = 7; i <= NF; i++) { sent[$i]++; name[$i] = $i; } } # { if ($5 ~ /^[-+jis]$/) { total[$4]++; name[$4] = $4; } else unknown++; lines++; } # END { if (lines == unknown) { if (lines == "") print "empty log file" else print "no valid lines in input" exit 1; } # # Do a simple O(n^2) sort on the site names. # I've always wondered how to sort in awk. # for (i in name) { highest = name[i]; for (j in name) if (name[j] > highest) highest = j names[namecount++] = highest; name[highest] = "" } # # 123456789012345678901234567890123456789012345678901234567890112345678901 print "Sitename Accept Reject Junked I-have Sendme Total Sent" print "------------------------------------------------------------------------------" while (namecount) { s = names[--namecount] printf("%-26.26s ", s); if (accepted[s] == "") printf(" "); else { printf("%6d ", accepted[s]); atotal += accepted[s]; } if (rejected[s] == "") printf(" "); else { printf("%6d ", rejected[s]); rtotal += rejected[s]; } if (junked[s] == "") printf(" "); else { printf("%6d ", junked[s]); jtotal += junked[s]; } if (ihave[s] == "") printf(" "); else { printf("%6d ", ihave[s]); itotal += ihave[s]; } if (sendme[s] == "") printf(" "); else { printf("%6d ", sendme[s]); stotal += sendme[s]; } if (total[s] == "") printf(" "); else { printf(" %6d ", total[s]); thetotal += total[s]; } if (sent[s] == "") printf("\n"); else { printf(" %6d\n", sent[s]); senttotal += sent[s]; } } printf("%26s ", "Totals:"); if (atotal == "") printf(" "); else printf("%6d ", atotal); if (rtotal == "") printf(" "); else printf("%6d ", rtotal); if (jtotal == "") printf(" "); else printf("%6d ", jtotal); if (itotal == "") printf(" "); else printf("%6d ", itotal); if (stotal == "") printf(" "); else printf("%6d ", stotal); if (thetotal == "") printf(" "); else printf(" %6d ", thetotal); if (senttotal == "") printf("\n"); else printf(" %6d\n", senttotal); # # You may want to remove the next part if you get a lot of junked articles. # print print "Junked Newsgroups:" for (s in badngs) if (s != "") printf("\t%s: %d\n", s, badngs[s]); # # You also might want to remove this part if you get a lot of articles # rejected for reasons other than being duplicates. # print print "Why articles were rejected:" for (s in why) if (s != "") printf("\t%s: %d\n", s, why[s]); print # if (unknown != "") printf("\nUnknown lines: %d\n", unknown); } -- Ross Ridge // "The Great HTMU" [oo] ross@contact.uucp -()- ross@watcsc.waterloo.edu //