[net.sources] UUCP analysis

tim@dciem.UUCP (Tim Pointing) (11/08/83)

Long, long ago, in a newsgroup far, far away...
Way back in April, zemon@trwspp submitted a couple of awk scripts for
analyzing the information in the uucp LOGFILE and SYSFILE. Since this
site is in the process of setting up several new connections, we wanted
to keep track of how well the connections were being made. Since the
awk script mentioned above provided success/failue/locked counts for
each site, it seemed reasonable to extract this from the output from awk.
At this site, the LOGFILE and SYSFILE are backed-up and zero'ed every
morning. zemon's awk scripts are run just before this to get the information
on the previous day's activity, with the output concatenated to a permanent
log file. The awk script below uses this log file to provide a summary
of connection statuses.


----------------------------------------------------------------------------
# USAGE: awk -f thisfile logfilefromuucpanalysis

BEGIN	{
	nsystems = 0;
	}
/summary/,/AVAILABLE/ {
	if (insummary == 0)
		{
		insummary = 1;
		next;
		}

	if (insummary) {
		if (NF == 3 && $1 != "NO" && $1 != "UUCP") {
			system=$1
			for(i=0; i<nsystems; i++)
				if (system == systems[i])
					break;
			if (i == nsystems) {
				systems[nsystems++] = system;
				successes[system] = 0;
				failures[system] = 0;
				locked[system] = 0;
			}
		}
		if ($3=="successes")
			successes[system] += $2;
		if ($2=="failures")
			failures[system] += $1;
		if ($2=="locked")
			locked[system] += $1;
		}
	}

END	{
	for (i=0; i<nsystems; i++) {
		system = systems[i];
		printf("%-7s: %3d succ;  %3d fail;  %3d lock\n", system,			successes[system], failures[system], locked[system]);
	}
}


--------------------------------------------------------------------------

Sample output:


rhodniu:   7 succ;    0 fail;    0 lock
trigrap:  26 succ;    8 fail;    3 lock
hcr    :  14 succ;    1 fail;    0 lock
utzoo  :  25 succ;   31 fail;    1 lock
per    :  39 succ;    8 fail;    0 lock
rds    :  48 succ;    0 fail;   11 lock
utcsrgv:  23 succ;    2 fail;    1 lock
psddevl:   7 succ;   11 fail;    0 lock


--------------------------------------------------------------------------
From this, one can vary quickly see that we are having trouble contacting
"utzoo" and "psddevl". The above represents several (8?) days connections.

ajs@hpfcla.UUCP (11/13/83)

#R:dciem:-47200:hpfcla:21800001:000:3108
hpfcla!ajs    Nov 11 17:52:00 1983

While the subject is still  warm,  here's  another  neat little  LOGFILE
script,  called  "uulast".  This one tells you when the last  successful
connection  to each system took place, the total  number of them (in all
LOG* files), and which systems appear in LOG* but not in L.sys (and vice
versa).  For best  results,  you need a LOGFILE  that's  reamed out less
than daily, say, weekly.  I run it nightly (from cron, su'd to uucp) and
mail myself the results.

Alan Silverstein, Hewlett-Packard Fort Collins Systems Division, Colorado
ucbvax!hplabs!hpfcla!ajs, 303-226-3800 x3053, N 40 31'31" W 105 00'43"

-------------

# Shell script to find the last time of successful uucp startup for
# each remote nodename in all LOG* files (since uustat doesn't work!),
# and report on missing and unknown nodenames.

# Assumes all $log files have the correct format:
#
#	username nodename (month/date-hour:min-pid) message
#
# The algorithm will always produce the latest startup DATE in any year
# represented, there is no information about years in the logfiles.


# Initialize:

	PATH=/bin:/usr/bin
	log=/usr/spool/uucp/LOG*

	temp1=/tmp/uul$$a
	temp2=/tmp/uul$$b
	trap "rm -f $temp1 $temp2; trap '' 0; exit" 0 1 2 3

	echo "nodename   last startup   total\n"

# Find startup lines and add a last (dummy) line for awk:

{	grep "OK (startup)" $log
	echo "zzzzzzzzzz"			# must sort out last!
}	|					# note pipe.


# Stream edit as follows:
#	- strip usernames;
#	- put in a default nodename if the original was null (e.g. the file
#	  contained two blanks in a row);
#	- add leading zeroes before 1-digit months;
#	- add leading zeroes before 1-digit days;
#	- add leading zeroes before 3-digit times;
#	- strip the leading "(";
#	- strip the trailing "-pid) message".

	sed	-e 's/[^ ]* //'		\
		-e 's/^ /<blank> /'	\
		-e 's;(\(.\)/;(0\1/;'	\
		-e 's;/\(.\)-;/0\1-;'	\
		-e 's/-\(.\):/-0\1:/'	\
		-e 's/(//'		\
		-e 's/-[^-]*).*//'	|	# note pipe.


# Select last entry for each nodename:
# Note that the first line is skipped, and the last line is the dummy line
# (from above) so the last true data line IS printed.

	sort				|
	awk '	node != $1 {
			if (length (node))
				printf ("%-12s%11s%8d\n", node, time, count);
			count = 0;
		}
		{node = $1; time = $2; count++}
	'				|	# note pipe.

# Sort by age, oldest first, and dump the results to stdout and temp file:

	sort -b +1			|
	tee $temp1


# Print totals as a separate step (so temp file is pure for later use):

	awk <$temp1 '
			{count += $3}
		END	{printf ("total%26d\n", count)}
	'


# Reduce the known systems to sorted nodenames only:

	awk  <$temp1 '{print $1}'	|
	sort >$temp2


# Compare against known systems, less junk lines:

	echo "\nKnown systems with no startup ('<') and unknown systems ('>'):"

	uuname				|	# known system nodenames.
	sed	-e '/^</d'		\
		-e '/^$/d'		|	# less "<" and null lines.
	sort				|
	uniq				|	# just in case.
	diff - $temp2			|	# get comparison.
	sed '/^[<>]/!d'			|	# toss except "<" and ">" lines.
	sort					# group by type.
-------------------------------------------------------------------------------