[news.admin] cnews reporting

nagel@ics.uci.edu (Mark Nagel) (04/06/90)

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. ?

>I used to use report.awk under bnews and would like to find something
>similiar.

Not C or awk, but perl...  Try rep_log.pl available for anonymous
ftp from ics.uci.edu in the directory /pub/news/utils.

--
Mark Nagel
UC Irvine Department of ICS   +----------------------------------------+
ARPA: nagel@ics.uci.edu       | radiation: smog with an attitude       |
UUCP: ucbvax!ucivax!nagel     +----------------------------------------+

ross@contact.uucp (Ross Ridge) (04/06/90)

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						 //

henry@utzoo.uucp (Henry Spencer) (04/07/90)

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. ?

Just to let people know:  official support of something like this is on 
the to-do list, although it won't happen right away.
-- 
Apollo @ 8yrs: one small step.|     Henry Spencer at U of Toronto Zoology
Space station @ 8yrs:        .| uunet!attcan!utzoo!henry henry@zoo.toronto.edu