Newsgroups: comp.mail.uucp
Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!hybrid!torag!utdoe!contact!ross
From: ross@contact.uucp (Ross Ridge)
Subject: Re: Log summaries
Reply-To: ross@contact.UUCP (Ross Ridge)
Organization: Contact Public Unix BBS. Toronto, Canada.
Date: Fri, 19 Apr 91 03:11:13 GMT
Message-ID: <1991Apr19.031113.5025@contact.uucp>
References: <N+3_XYC@cs.widener.edu> <280B2BB2.243@tct.com> <1794@twg.bc.ca>

chip@tct.com (Chip Salzenberg) writes:
>Sure.  This one, "uuconstat", is for HDB UUCP.  Shar and enjoy.

In article <1794@twg.bc.ca> bill@twg.bc.ca (Bill Irwin) writes:
>Do you have this in a /bin/sh flavour?  I don't have Perl.

Well since every one is posting their Perl scripts, I might as well
post my awk script. (This should work with old awk, but I've said that
before and been wrong.)  This works with HDB UUCP as well.

Basically you use it by saving the script in a file called uucpstats.awk
and run "awk -f uucpstats.awk /usr/spool/uucp/.Old/xferstats" after
after your uucp logs are cleaned out each night.

You get output like this:

--------------------------------------------------------------------------
                      Recieved                             Sent
Site       files    bytes     time    cps   files    bytes     time    cps
--------------------------------------------------------------------------
becker         6     3857     0:17    222      52   243533     5:34    728
birchmt        4     1235     0:12     97       3   634163  1:00:11    175
bkj386                                          6     5165     0:04   1237
dmntor        18    21949     1:27    251      28    76073     4:42    269
geac          16    49125     1:29    547      34   341543     8:11    694
jetpen         2      603     0:05    106  
mauxci         2     1679     0:06    269       4     3097     0:02   1277
nttor                                          28    46052     0:35   1312
robohack      16    38948     4:02    160      24    43608     3:48    190
spocom         2     2758     0:17    153      30    65609     6:09    177
tsltor                                         30    57721     0:46   1229
utdoe         98   911022    19:03    796      58    77013     1:04   1191
zooid          2      405     0:05     75       2     1064     0:06    171
--------------------------------------------------------------------------
 Totals:     166  1031581    27:08    633     299  1594641  1:31:00    291
--------------------------------------------------------------------------
                      Recieved                             Sent
tty        files    bytes     time    cps   files    bytes     time    cps
--------------------------------------------------------------------------
tty1A        158  1019461    25:48    658     282   930535    28:20    547
tty3A          6     3993     0:30    130      15   660394  1:02:39    175
tty3C          2     8127     0:48    166       2     3712     0:18    198
--------------------------------------------------------------------------

Total files: 465
Total bytes: 2626222
Total time:  1:58:26
Overall cps: 369

#
# uucpstats.awk -- by Ross Ridge (ross@contact.uucp) Public Domain
#
# $1       $2 $3   $4  $5    $6  $7   $8 $9   $10   $11 $12
# site!who C  date pid [tty] <-> size /  time secs, cps bytes/sec.

BEGIN	       {
		sitersize[""] = ""
		sitercount[""] = ""
		sitessize[""] = ""
		sitescount[""] = ""
		ttyrsize[""] = ""
		ttyrcount[""] = ""
		ttyssize[""] = ""
		ttyscount[""] = ""
	       }

	       {
		split($1, a, "!")
		site = a[1]
		tty = substr($5, 2, length($5) - 2)
		size = $7
		time = $9
# Fix for broken Xenix uucico:
#		time = $9 / 2

		sites[site] = site
		ttys[tty] = tty
	       }

$6 == "<-"     {
		sitersize[site] += size
		sitertime[site] += time
		sitercount[site]++
		ttyrsize[tty] += size
		ttyrtime[tty] += time
		ttyrcount[tty]++
		Rsize += size
		Rtime += time
		Rcount++
               }

$6 == "->"     {
		sitessize[site] += size
		sitestime[site] += time
		sitescount[site]++
		ttyssize[tty] += size
		ttystime[tty] += time
		ttyscount[tty]++
		Ssize += size
		Stime += time
		Scount++
               }
		
END	       {
		if (Scount + Rcount == 0) {
			print "empty log file"
			exit 1
		}
#
# Do a simple O(n^2) sort on the site names.
#
		for (i in sites) {
			highest = sites[i]
			for (j in sites)
				if (sites[j] > highest)
					highest = j
			s_sites[sitecount++] = highest
			sites[highest] = ""
		}
#
		for (i in ttys) {
			highest = ttys[i]
			for (j in ttys)
				if (ttys[j] > highest)
					highest = j
			s_ttys[ttycount++] = highest
			ttys[highest] = ""
		}
#		       12345678901234567890123456789012345678901234567890123456789012345678901234567890
		print "--------------------------------------------------------------------------"
		print "                      Recieved                             Sent"
		print "Site       files    bytes     time    cps   files    bytes     time    cps"
		print "--------------------------------------------------------------------------"
		while (sitecount) {
			s = s_sites[--sitecount]
			printf("%-8.8s  ", s)
			if (sitercount[s] == "")
				printf("                                 ")
			else {
				printf("%6d ", sitercount[s])
				printf("%8d ", sitersize[s])
				t = sitertime[s]
				if (t < 3600)
					printf("   %2d:%02d ", t / 60, t % 60)
				else
					printf("%2d:%02d:%02d ", t / 3600, (t / 60) % 60, t % 60)
				printf("%6d  ", sitersize[s] / t)
			}
			if (sitescount[s] == "")
				printf("\n")
			else {
				printf("%6d ", sitescount[s])
				printf("%8d ", sitessize[s])
				t = sitestime[s]
				if (t < 3600)
					printf("   %2d:%02d ", t / 60, t % 60)
				else
					printf("%2d:%02d:%02d ", t / 3600, (t / 60) % 60, t % 60)
				printf("%6d\n", sitessize[s] / t)
			}
		}
		print "--------------------------------------------------------------------------"
		printf(" Totals:  ")
		if (Rcount == "")
			printf("                                  ")
		else {
			printf("%6d ", Rcount)
			printf("%8d ", Rsize)
			if (Rtime < 3600)
				printf("   %2d:%02d ", Rtime / 60, Rtime % 60)
			else
				printf("%2d:%02d:%02d ", Rtime / 3600, (Rtime / 60) % 60, Rtime % 60)
			printf("%6d  ", Rsize / Rtime)
		}
		if (Scount == "")
			printf("\n")
		else {
			printf("%6d ", Scount)
			printf("%8d ", Ssize)
			if (Stime < 3600)
				printf("   %2d:%02d ", Stime / 60, Stime % 60)
			else
				printf("%2d:%02d:%02d ", Stime / 3600, (Stime / 60) % 60, stime % 60)
			printf("%6d\n", Ssize / Stime)
		}
		print "--------------------------------------------------------------------------"
		print "                      Recieved                             Sent"
		print "tty        files    bytes     time    cps   files    bytes     time    cps"
		print "--------------------------------------------------------------------------"
		while (ttycount) {
			s = s_ttys[--ttycount]
			printf("%-8.8s  ", s)
			if (ttyrcount[s] == "")
				printf("                                 ")
			else {
				printf("%6d ", ttyrcount[s])
				printf("%8d ", ttyrsize[s])
				t = ttyrtime[s]
				if (t < 3600)
					printf("   %2d:%02d ", t / 60, t % 60)
				else
					printf("%2d:%02d:%02d ", t / 3600, (t / 60) % 60, t % 60)
				printf("%6d  ", ttyrsize[s] / t)
			}
			if (ttyscount[s] == "")
				printf("\n")
			else {
				printf("%6d ", ttyscount[s])
				printf("%8d ", ttyssize[s])
				t = ttystime[s]
				if (t < 3600)
					printf("   %2d:%02d ", t / 60, t % 60)
				else
					printf("%2d:%02d:%02d ", t / 3600, (t / 60) % 60, t % 60)
				printf("%6d\n", ttyssize[s] / t)
			}
		}
		print "--------------------------------------------------------------------------"

		print
		printf("Total files: %d\n", Rcount + Scount); 
		printf("Total bytes: %d\n", Rsize + Ssize); 
		printf("Total time: ");
		t = Rtime + Stime;
		if (t < 3600)
			printf("%2d:%02d\n", t / 60, t % 60)
		else
			printf("%2d:%02d:%02d\n", t / 3600, (t / 60) % 60, t % 60)
		printf("Overall cps: %d\n", (Rsize + Ssize) / t);
		print
}
-- 
Ross Ridge								 //
"The Great HTMU"							[oo]
ross@contact.uucp							-()-
ross@watcsc.uwaterloo.ca						 //
