head	1.4;
access;
symbols
	perseant-exfatfs-base-20250801:1.4
	perseant-exfatfs-base-20240630:1.4
	cjep_sun2x:1.4.0.44
	cjep_sun2x-base:1.4
	cjep_staticlib_x-base1:1.4
	cjep_staticlib_x:1.4.0.42
	cjep_staticlib_x-base:1.4
	phil-wifi-20200421:1.4
	phil-wifi-20200411:1.4
	phil-wifi-20200406:1.4
	pgoyette-compat-merge-20190127:1.4
	pgoyette-compat-20190127:1.4
	pgoyette-compat-20190118:1.4
	pgoyette-compat-1226:1.4
	pgoyette-compat-1126:1.4
	pgoyette-compat-1020:1.4
	pgoyette-compat-0930:1.4
	pgoyette-compat-0906:1.4
	pgoyette-compat-0728:1.4
	pgoyette-compat-0625:1.4
	pgoyette-compat-0521:1.4
	pgoyette-compat-0502:1.4
	pgoyette-compat-0422:1.4
	pgoyette-compat-0415:1.4
	pgoyette-compat-0407:1.4
	pgoyette-compat-0330:1.4
	pgoyette-compat-0322:1.4
	pgoyette-compat-0315:1.4
	pgoyette-compat:1.4.0.40
	pgoyette-compat-base:1.4
	perseant-stdc-iso10646:1.4.0.38
	perseant-stdc-iso10646-base:1.4
	prg-localcount2-base3:1.4
	prg-localcount2-base2:1.4
	prg-localcount2-base1:1.4
	prg-localcount2:1.4.0.36
	prg-localcount2-base:1.4
	pgoyette-localcount-20170426:1.4
	bouyer-socketcan-base1:1.4
	pgoyette-localcount-20170320:1.4
	bouyer-socketcan:1.4.0.34
	bouyer-socketcan-base:1.4
	pgoyette-localcount-20170107:1.4
	pgoyette-localcount-20161104:1.4
	localcount-20160914:1.4
	pgoyette-localcount-20160806:1.4
	pgoyette-localcount-20160726:1.4
	pgoyette-localcount:1.4.0.32
	pgoyette-localcount-base:1.4
	netbsd-5-2-3-RELEASE:1.4
	netbsd-5-1-5-RELEASE:1.4
	yamt-pagecache-base9:1.4
	yamt-pagecache-tag8:1.4
	tls-earlyentropy:1.4.0.28
	tls-earlyentropy-base:1.4
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.4
	riastradh-drm2-base3:1.4
	netbsd-5-2-2-RELEASE:1.4
	netbsd-5-1-4-RELEASE:1.4
	netbsd-5-2-1-RELEASE:1.4
	netbsd-5-1-3-RELEASE:1.4
	agc-symver:1.4.0.30
	agc-symver-base:1.4
	tls-maxphys-base:1.4
	yamt-pagecache-base8:1.4
	netbsd-5-2:1.4.0.26
	yamt-pagecache-base7:1.4
	netbsd-5-2-RELEASE:1.4
	netbsd-5-2-RC1:1.4
	yamt-pagecache-base6:1.4
	yamt-pagecache-base5:1.4
	yamt-pagecache-base4:1.4
	netbsd-5-1-2-RELEASE:1.4
	netbsd-5-1-1-RELEASE:1.4
	yamt-pagecache-base3:1.4
	yamt-pagecache-base2:1.4
	yamt-pagecache:1.4.0.24
	yamt-pagecache-base:1.4
	bouyer-quota2-nbase:1.4
	bouyer-quota2:1.4.0.22
	bouyer-quota2-base:1.4
	matt-nb5-pq3:1.4.0.20
	matt-nb5-pq3-base:1.4
	netbsd-5-1:1.4.0.18
	netbsd-5-1-RELEASE:1.4
	netbsd-5-1-RC4:1.4
	netbsd-5-1-RC3:1.4
	netbsd-5-1-RC2:1.4
	netbsd-5-1-RC1:1.4
	netbsd-5-0-2-RELEASE:1.4
	netbsd-5-0-1-RELEASE:1.4
	jym-xensuspend-nbase:1.4
	netbsd-5-0:1.4.0.16
	netbsd-5-0-RELEASE:1.4
	netbsd-5-0-RC4:1.4
	netbsd-5-0-RC3:1.4
	netbsd-5-0-RC2:1.4
	jym-xensuspend:1.4.0.14
	jym-xensuspend-base:1.4
	netbsd-5-0-RC1:1.4
	netbsd-5:1.4.0.12
	netbsd-5-base:1.4
	mjf-devfs2:1.4.0.10
	mjf-devfs2-base:1.4
	yamt-pf42-base4:1.4
	yamt-pf42-base3:1.4
	hpcarm-cleanup-nbase:1.4
	yamt-pf42-base2:1.4
	yamt-pf42:1.4.0.8
	yamt-pf42-base:1.4
	keiichi-mipv6:1.4.0.6
	keiichi-mipv6-base:1.4
	cube-autoconf:1.4.0.4
	cube-autoconf-base:1.4
	hpcarm-cleanup:1.4.0.2
	hpcarm-cleanup-base:1.4
	netbsd-3-1-1-RELEASE:1.3
	netbsd-3-0-3-RELEASE:1.3
	abandoned-netbsd-4-base:1.3
	abandoned-netbsd-4:1.3.0.28
	netbsd-3-1:1.3.0.30
	netbsd-3-1-RELEASE:1.3
	netbsd-3-0-2-RELEASE:1.3
	netbsd-3-1-RC4:1.3
	netbsd-3-1-RC3:1.3
	netbsd-3-1-RC2:1.3
	netbsd-3-1-RC1:1.3
	netbsd-3-0-1-RELEASE:1.3
	netbsd-3-0:1.3.0.26
	netbsd-3-0-RELEASE:1.3
	netbsd-3-0-RC6:1.3
	netbsd-3-0-RC5:1.3
	netbsd-3-0-RC4:1.3
	netbsd-3-0-RC3:1.3
	netbsd-3-0-RC2:1.3
	netbsd-3-0-RC1:1.3
	netbsd-2-0-3-RELEASE:1.3
	netbsd-2-1:1.3.0.24
	netbsd-2-1-RELEASE:1.3
	netbsd-2-1-RC6:1.3
	netbsd-2-1-RC5:1.3
	netbsd-2-1-RC4:1.3
	netbsd-2-1-RC3:1.3
	netbsd-2-1-RC2:1.3
	netbsd-2-1-RC1:1.3
	netbsd-2-0-2-RELEASE:1.3
	netbsd-3:1.3.0.22
	netbsd-3-base:1.3
	netbsd-2-0-1-RELEASE:1.3
	netbsd-2:1.3.0.20
	netbsd-2-base:1.3
	netbsd-2-0-RELEASE:1.3
	netbsd-2-0-RC5:1.3
	netbsd-2-0-RC4:1.3
	netbsd-2-0-RC3:1.3
	netbsd-2-0-RC2:1.3
	netbsd-2-0-RC1:1.3
	netbsd-2-0:1.3.0.18
	netbsd-2-0-base:1.3
	netbsd-1-6-PATCH002-RELEASE:1.3
	netbsd-1-6-PATCH002:1.3
	netbsd-1-6-PATCH002-RC4:1.3
	netbsd-1-6-PATCH002-RC3:1.3
	netbsd-1-6-PATCH002-RC2:1.3
	netbsd-1-6-PATCH002-RC1:1.3
	netbsd-1-6-PATCH001:1.3
	netbsd-1-6-PATCH001-RELEASE:1.3
	netbsd-1-6-PATCH001-RC3:1.3
	netbsd-1-6-PATCH001-RC2:1.3
	netbsd-1-6-PATCH001-RC1:1.3
	fvdl_fs64_base:1.3
	netbsd-1-6-RELEASE:1.3
	netbsd-1-6-RC3:1.3
	netbsd-1-6-RC2:1.3
	netbsd-1-6-RC1:1.3
	netbsd-1-6:1.3.0.16
	netbsd-1-6-base:1.3
	netbsd-1-5-PATCH003:1.3
	netbsd-1-5-PATCH002:1.3
	netbsd-1-5-PATCH001:1.3
	netbsd-1-5-RELEASE:1.3
	netbsd-1-5-BETA2:1.3
	netbsd-1-5-BETA:1.3
	netbsd-1-4-PATCH003:1.3
	netbsd-1-5-ALPHA2:1.3
	netbsd-1-5:1.3.0.14
	netbsd-1-5-base:1.3
	netbsd-1-4-PATCH002:1.3
	wrstuden-devbsize-19991221:1.3
	wrstuden-devbsize:1.3.0.12
	wrstuden-devbsize-base:1.3
	comdex-fall-1999:1.3.0.10
	comdex-fall-1999-base:1.3
	netbsd-1-4-PATCH001:1.3
	netbsd-1-4-RELEASE:1.3
	netbsd-1-4:1.3.0.8
	netbsd-1-4-base:1.3
	netbsd-1-3-PATCH003:1.3
	netbsd-1-3-PATCH003-CANDIDATE2:1.3
	netbsd-1-3-PATCH003-CANDIDATE1:1.3
	netbsd-1-3-PATCH003-CANDIDATE0:1.3
	netbsd-1-3-PATCH002:1.3
	netbsd-1-3-PATCH001:1.3
	netbsd-1-3-RELEASE:1.3
	netbsd-1-3-BETA:1.3
	netbsd-1-3:1.3.0.4
	netbsd-1-3-base:1.3
	netbsd-1-2-PATCH001:1.3
	netbsd-1-2-RELEASE:1.3
	netbsd-1-2-BETA:1.3
	netbsd-1-2-base:1.3
	netbsd-1-2:1.3.0.6
	netbsd-1-1-PATCH001:1.3
	netbsd-1-1-RELEASE:1.3
	netbsd-1-1:1.3.0.2
	netbsd-1-1-base:1.3
	netbsd-1-0-PATCH06:1.1
	netbsd-1-0-PATCH05:1.1
	netbsd-1-0-PATCH04:1.1
	netbsd-1-0-PATCH03:1.1
	netbsd-1-0-PATCH02:1.1
	netbsd-1-0-PATCH1:1.1
	netbsd-1-0-PATCH0:1.1
	netbsd-1-0-RELEASE:1.1
	netbsd-1-0:1.1.0.2
	netbsd-1-0-base:1.1;
locks; strict;
comment	@# @;


1.4
date	2006.11.12.01.20.00;	author christos;	state dead;
branches;
next	1.3;

1.3
date	95.08.24.05.19.25;	author jtc;	state Exp;
branches;
next	1.2;

1.2
date	94.10.24.22.18.03;	author jtc;	state Exp;
branches;
next	1.1;

1.1
date	93.08.04.19.31.44;	author jtc;	state Exp;
branches;
next	;


desc
@@


1.4
log
@goodbye uucp
@
text
@#!/usr/bin/perl
# uutraf.pl -- UUCP Traffic Analyzer
# SCCS Status     : @@(#)@@ uutraf	1.8
# Author          : Johan Vromans
# Created On      : ***
# Last Modified By: Johan Vromans
# Last Modified On: Mon Aug 30 15:02:22 1993
# Update Count    : 6
# Status          : OK
# Requires:       : Perl V4 or later

# Reads UUCP syslog, and generates a report from it.
#
# Created by Johan Vromans <jv@@mh.nl>
# Loosely based on an idea by Greg Hackney (hack@@texbell.swbt.com)

# Usage: uutraf [-taylor|-hdb|-bnu|-bsd] [syslog]

# Logfile formats:
#
# BSD:
#
# jv mhres (2/23-5:18) (698818735) received 135 b 2 secs
# root mhres (2/23-5:19) (698818742) sent 2365 b 3 secs, Pk: 38, Rxmt: 0
#
# HDB:
#
# uunet!uucp M (12/10-09:04:22) (C,16390,1) [ttyXX] <- 2371 / 5.000 secs, \
#     474 bytes/sec
#
# Taylor:
#
# jv mhres (1992-02-24 20:49:04.06) sent 16234 bytes in 148.780 seconds \
#    (109 bytes/sec)
# jv mhres (1992-02-24 21:04:05.76) received 449 bytes in 6.550 seconds \
#    (68 bytes/sec)

$uucp_type = "gnu";

%hosts = ();		# hosts seen
%bytes_in = ();		# of bytes received from host
%bytes_out = ();	# of bytes sent to host
%secs_in = ();		# of seconds connect for recving
%secs_out = ();		# of seconds connect for sending
%files_in = ();		# of input requests
%files_out = ();	# of output requests

# read info, break the lines and tally

if ( $ARGV[0] =~ /^-/ ) {
    ($uucp_type = substr (shift (@@ARGV), 1)) =~ tr/A-Z/a-z/;
}

if ( $uucp_type eq "taylor" || $uucp_type eq "gnu" ) {
    @@ARGV = ("/usr/local/spool/uucp/Stats") unless $#ARGV >= 0;
    $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/ .]+)\\) " .
	"(sent|received) (\\d+) bytes in (\\d+)\\.(\\d+) seconds";
    $uucp_type = 0;
    $recv = "received";
}
elsif ( $uucp_type eq "hdb" || $uucp_type eq "bnu" ) {
    @@ARGV = ("/usr/spool/uucp/.Admin/xferstats") unless $#ARGV >= 0;
    $pat = "^([^!]+)![^(]+\\(([-0-9:\\/]+)\\).+([<>])-? " .
	"(\\d+) \\/ (\\d+)\\.(\\d+) secs";
    $uucp_type = 1;
    $recv = "<";
}
elsif ( $uucp_type eq "bsd" || $uucp_type eq "v7" ) {
    @@ARGV = ("/usr/spool/uucp/SYSLOG") unless $#ARGV >= 0;
    $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/]+)\\) \\([^)]+\\) " .
	"(sent|received) (\\d+) b (\\d+) secs";
    $uucp_type = 2;
    $recv = "received";
}
else {
    die ("FATAL: Unknown UUCP type: $uucp_type\n");
}

$garbage = 0;

while ( <> ) {
    unless ( /$pat/o ) {
	print STDERR "$_";
	next if /failed/;
	if ( $garbage++ > 10 ) {
	    die ("FATAL: Too much garbage; wrong UUCP type?\n");
	}
	next;
    }

    # gather timestamps
    $last_date = $2;
    $first_date = $last_date unless defined $first_date;
	
    # initialize new hosts
    unless ( defined $hosts{$1} ) {
	$hosts{$1} = $files_in{$1} = $files_out{$1} = 
	    $bytes_in{$1} = $bytes_out{$1} =
		$secs_in{$1} = $secs_out{$1} = 0;
    }

    # Taylor and HDB have milliseconds, BSD has not.
    $secs = ($uucp_type == 2) ? ($5 + ($5 == 0 ? 0.5 : 0)) : ($5 + $6/1000);

    # tally
    if ( $3 eq $recv ) {		# recv
	$bytes_in{$1} += $4;
	$files_in{$1}++;
	$secs_in{$1} += $secs;
    }
    else {			# xmit
	$bytes_out{$1} += $4;
	$files_out{$1}++;
	$secs_out{$1} += $secs;
    }
    $garbage = 0;
}

@@hosts = keys (%hosts);
die ("No info found, stopped\n") if $#hosts < 0;

################ report section ################

$thishost = &gethostname();
$thishost = (defined $thishost) ? "on node $thishost" : "report";

if ( $uucp_type eq 0 ) {	# Taylor UUCP
    substr ($first_date, 16) = "";
    substr ($last_date, 16) = "";
}

format std_head =
@@|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"UUCP traffic $thishost from $first_date to $last_date"

Remote   -----------K-Bytes----------- ----Hours---- --Avg CPS-- --Files--
 Host         Recv      Sent     Total   Recv   Sent  Recv  Sent Recv Sent
.
format std_out =
@@<<<<<<< @@>>>>>>>> @@>>>>>>>> @@>>>>>>>> @@>>>>> @@>>>>> @@>>>> @@>>>> @@>>> @@>>>
$Zhost,   $Zi_bytes, $Zo_bytes, $Zt_bytes, $Zi_hrs, $Zo_hrs, $Zi_acps, $Zo_acps, $Zi_count, $Zo_count
.

$^ = "std_head";
$~ = "std_out";

&print_dashes ();

reset "T";	       # reset totals

foreach $host (@@hosts) {
  &print_line ($host, $bytes_in{$host}, $bytes_out{$host},
		 $secs_in{$host},  $secs_out{$host},
		 $files_in{$host}, $files_out{$host});

}

&print_dashes ();
&print_line ("Total", $Ti_bytes, $To_bytes,
	       $Ti_secs, $To_secs, $Ti_count, $To_count);

################ that's it ################

sub print_line {
  reset "Z";		# reset print fields
  local ($Zhost, 
	 $Zi_bytes, $Zo_bytes, 
	 $Zi_secs, $Zo_secs, 
	 $Zi_count, $Zo_count) = @@_;
  $Ti_bytes += $Zi_bytes;
  $To_bytes += $Zo_bytes;
  $Zt_bytes = $Zi_bytes + $Zo_bytes;
  $Tt_bytes += $Zt_bytes;
  $Zi_acps = ($Zi_secs > 0) ? sprintf ("%.0f", $Zi_bytes/$Zi_secs) : "0";
  $Zo_acps = ($Zo_secs > 0) ? sprintf ("%.0f", $Zo_bytes/$Zo_secs) : "0";
  $Zi_bytes = sprintf ("%.1f", $Zi_bytes/1000);
  $Zo_bytes = sprintf ("%.1f", $Zo_bytes/1000);
  $Zt_bytes = sprintf ("%.1f", $Zt_bytes/1000);
  $Zi_hrs = sprintf ("%.1f", $Zi_secs/3600);
  $Zo_hrs = sprintf ("%.1f", $Zo_secs/3600);
  $Ti_secs += $Zi_secs;
  $To_secs += $Zo_secs;
  $Ti_count += $Zi_count;
  $To_count += $Zo_count;
  write;
}

sub print_dashes {
  $Zhost = $Zi_bytes = $Zo_bytes = $Zt_bytes =
    $Zi_hrs = $Zo_hrs = $Zi_acps = $Zo_acps = $Zi_count = $Zo_count = 
      "------------";
  write;
  # easy, isn't it?
}

################ missing ################

sub gethostname {
  $ENV{"SHELL"} = "/bin/sh";
  $try = `(hostname) 2>/dev/null`;
  chop $try;
  return $+ if $try =~ /^[-.\w]+$/;
  $try = `uname -n 2>/dev/null`;
  chop $try;
  return $+ if $try =~ /^[-.\w]+$/;
  $try = `uuname -l 2>/dev/null`;
  chop $try;
  return $+ if $try =~ /^[-.\w]+$/;
  return undef;
}
@


1.3
log
@Upgraded to Taylor UUCP 1.06.1 (Thanks to John Kohl).
@
text
@@


1.2
log
@Upgraded to Taylor UUCP 1.05 (Thanks to John Kohl).
@
text
@d200 1
a200 1
  $try = `hostname 2>/dev/null`;
@


1.1
log
@Upgrade to Taylor UUCP 1.04
@
text
@d1 1
a1 1
#!/usr/local/bin/perl
d3 1
a3 1
# SCCS Status     : @@(#)@@ uutraf	1.7
d7 2
a8 2
# Last Modified On: Wed Feb 26 08:52:56 1992
# Update Count    : 4
d55 1
a55 1
    @@ARGV = ("/usr/spool/uucp/Stats") unless $#ARGV >= 0;
d76 1
a76 1
    die ("Unknown UUCP type: $uucp_type\n");
d83 2
a84 1
	print STDERR "Possible garbage: $_";
d86 1
a86 1
	    die ("Too much garbage; wrong UUCP type?\n");
d94 1
a94 1

d97 1
a97 1
	$hosts{$1} = $files_in{$1} = $files_out{$1} =
d166 3
a168 3
  local ($Zhost,
	 $Zi_bytes, $Zo_bytes,
	 $Zi_secs, $Zo_secs,
d190 1
a190 1
    $Zi_hrs = $Zo_hrs = $Zi_acps = $Zo_acps = $Zi_count = $Zo_count =
d200 6
@
