Log summaries
Vince Skahan
vince at bcsaic.UUCP
Fri Apr 19 01:19:21 AEST 1991
In article <1991Apr16.070654.15375 at pronto.mh.nl> Johan Vromans <jv at mh.nl> writes:
>
>> Has anybody written a program (Perl?) to parse UUCP log files, to
>> give an idea how much each UUCP connection's being used, and for how
>> long?
>
Here's a HDB UUCP report generator in sh and awk.... it should scream if you
run it through a2p and use split rather than awk-isms
#------------------------- cut here --------------------------------
#!/bin/sh
STATS="/usr/spool/uucp/.Admin/xferstats"
TMP="/tmp/hdb.tmp"
cat $STATS | sort > $TMP # sort by system then process
awk '{
#
# ------------ sample data for incoming information ------------
#
#dsinc!uucp M (11/9-7:37:59) (C,701,1) [sio1] <- 475 / 5.933 secs, 80 bytes/sec
#
# ----------- sample data for outgoing information --------------
#
#dsinc!bcs212 M (11/9-8:02:16) (C,828,1) [sio1] -> 341 / 0.450 secs, 757 bytes/sec
#
#-------------------------------------------------------------------
BEGIN{
# initialize NAME to nothing
NAME=" "
# print header
printf ("\n Summary of UUCP Statistics\n")
printf ("\n Total Incoming Outgoing Percent\n")
printf (" Bytes Bytes/sec Bytes/sec Bytes/sec Outgoing\n")
printf (" ----- ---------- --------- --------- --------\n")
}
# step through the data file
# outcoming data indicated by ->
# ingoing data indicated by <-
# find which system by /systemname/
# incoming
/<-/ {
time_in = time_in + $9
bytes_in = bytes_in + $7
total_intime = total_intime + $9
total_inbytes = total_inbytes + $7
}
#outgoing
/->/ {
time_out = time_out + $9
bytes_out = bytes_out + $7
total_outtime = total_outtime + $9
total_outbytes = total_outbytes + $7
}
{
if ( $1 != NAME )
{
if ( NAME != " " )
{
printf ("%15s %7d %7d %11d %11d %13d \n", NAME, host_bytes, host_rate, host_inrate, host_outrate, host_pct_out);
}
NAME = $1
host_intime = 0
host_inbytes = 0
host_outtime = 0
host_outbytes = 0
host_time = 0
host_bytes = 0
host_inrate = 0
host_outrate = 0
host_pct_out = 0
}
if (( ( $1 == NAME ) || ( $1 == " " ) ))
{
if ( $6 == "<-" ) {
host_intime = host_intime + $9
host_inbytes = host_inbytes + $7
}
else {
host_outtime = host_outtime + $9
host_outbytes = host_outbytes + $7
}
host_time = host_intime + host_outtime
host_bytes = host_inbytes + host_outbytes
if ( host_time > 0 ) {
host_rate = host_bytes/host_time
}
if ( host_intime > 0 ) {
host_inrate = host_inbytes/host_intime
}
if ( host_outtime > 0 ) {
host_outrate = host_outbytes/host_outtime
}
if (host_bytes > 0 ) {
host_pct_out = host_outbytes * 100 / host_bytes
}
}
}
END {
# summarize, print the last guy, and print the totals pretty
printf ("%15s %7d %7d %11d %11d %13d \n", NAME, host_bytes, host_rate, host_inrate, host_outrate, host_pct_out)
total_bytes = total_inbytes + total_outbytes
total_time = total_intime + total_outtime
if ( total_time > 0 ) {
total_rate = total_bytes/total_time
}
if ( total_intime > 0 ) {
total_inrate = total_inbytes/total_intime
}
if ( total_outtime > 0 ) {
total_outrate = total_outbytes/total_outtime
}
if (( (total_inbytes > 0 ) || ( total_outbytes > 0 ) ))
{
total_bytes = total_inbytes + total_outbytes
total_time = total_intime + total_outtime
total_pct_out = total_outbytes * 100 / total_bytes
printf("\n")
printf(" total %7d %7d %11d %11d %13d \n", total_bytes, total_rate, total_inrate, total_outrate, total_pct_out);
printf("\n")
}
}' $TMP
rm $TMP
--
Vince Skahan vince at atc.boeing.com ...uw-beaver!bcsaic!vince
(what is there in the construction of mobile homes that seems
to attract tornadoes ??? )
More information about the Alt.sources
mailing list