uucp xferstats script
Rodian Paul
rpaul at crow.UUCP
Thu Mar 21 17:24:53 AEST 1991
Someone may find this script helpful, it prints out xfer statistics in
a decent manner, here's an example of it's output:
Remote KB KB KB Hr:Mn:Sc Hr:Mn:Sc AvCPS AvCPS Files Files
Site Recv Xmit Total Recv Xmit Recv Xmit Recv Xmit
------ -------- -------- -------- -------- -------- ----- ----- ----- -----
tiger 0.0 5.7 5.7 0:00:00 0:00:25 0 236 0 4
gungadin 1.2 2.9 4.1 0:00:17 0:00:18 77 164 2 2
tokyo 9074.5 0.0 9074.5 1:59:45 0:00:00 1293 0 334 0
apache 3.1 139.1 142.2 0:00:14 0:01:20 224 1775 8 124
ccut 165.3 12.4 177.6 0:05:47 0:00:07 488 1883 152 18
sesi 0.0 16.8 16.8 0:00:00 0:01:07 0 259 0 3
------ -------- -------- -------- -------- -------- ----- ----- ----- -----
Totals 9244.1 176.9 9421.0 2:06:02 0:03:16 1252 922 496 151
Just before all the log files and stuff are cleaned up via cron, I have cron
run the shell and mail the output to the postmaster. You'll need to set the
term to unknown in the crontab file or remove the tput stuff from the script:
50 23 * * 1 TERM=unknown; export TERM; /usr/local/bin/uutot | /usr/sbin/Mail -s uutot postmaster
The tput stuff will print the totals row in bold.
# --- sNiP --- SnIp --- sNiP --- SnIp --- sNiP --- SnIp --- sNiP --- SnIp
#
#!/bin/sh
#
# From the Nutshell Handbook: sed & awk by O'Reilly & Associates
# p. 318, "uutot.awk" by R. A. Cornelius.
#
# Modified by Rodian Paul, Fri Feb 22 18:52:35 JST 1991
#
cat /usr/spool/uucp/.Admin/xferstats | \
nawk 'BEGIN {
doall = 1;
if( ARGC > 2 ) {
doall = 0;
for( i = 1; i < ARGC-1; i++) {
dosome[ ARGV[i] ];
ARGV[i] = "";
}
}
"tput bold" | getline BLD
"tput rmso" | getline NRM
kbyte = 1024
bang = "!";
sending = "->";
xmitting = "->" "|" "<-";
hdr1 = "Remote KB KB KB " \
"Hr:Mn:Sc Hr:Mn:Sc AvCPS AvCPS Files Files\n";
hdr2 = "Site Recv Xmit Total " \
" Recv Xmit Recv Xmit Recv Xmit\n";
hdr3 = "------ -------- -------- -------- -------- --------" \
" ----- ----- ----- -----\n";
fmt1 = "%-8.8s %8.1f %8.1f %8.1f %2d:%02d:%02.0f "\
"%2d:%02d:%02.0f %5.0f %5.0f %5d %5d\n";
fmt2 = "Totals %8.1f %8.1f %8.1f %2d:%02d:%02.0f "\
"%2d:%02d:%02.0f %5.0f %5.0f %5d %5d\n";
}
{
if( $6 !~ xmitting )
next;
direction = ( $6 == sending ? 1 : 2)
site = substr($1,1,index($1,bang)-1);
if( site in dosome || doall ) {
remote[site];
bytes[site,direction]+= $7;
time[site,direction]+= $9;
files[site,direction]++;
}
}
END {
printf hdr1 hdr2 hdr3
for( k in remote ) {
rbyte+= bytes[k,2]; sbyte+= bytes[k,1];
rtime+= time[k,2]; stime+= time[k,1];
rfiles+= files[k,2]; sfiles+= files[k,1];
printf(fmt1, k, bytes[k,2]/kbyte, bytes[k,1]/kbyte,
(bytes[k,2]+bytes[k,1])/kbyte,
time[k,2]/3600, (time[k,2]%3600)/60, time[k,2]%60,
time[k,1]/3600, (time[k,1]%3600)/60, time[k,1]%60,
bytes[k,2] && time[k,2] ? bytes[k,2]/time[k,2] : 0,
bytes[k,1] && time[k,1] ? bytes[k,1]/time[k,1] : 0,
files[k,2], files[k,1]);
}
printf hdr3
printf "%s", BLD
printf(fmt2, rbyte/kbyte, sbyte/kbyte, (rbyte+sbyte)/kbyte,
rtime/3600, (rtime%3600)/60, rtime%60,
stime/3600, (stime%3600)/60, stime%60,
rbyte && rtime ? rbyte/rtime : 0,
sbyte && stime ? sbyte/stime : 0,
rfiles, sfiles);
printf "%s\n", NRM
}'
# --- sNiP --- SnIp --- sNiP --- SnIp --- sNiP --- SnIp --- sNiP --- SnIp
-------------------------------------------------------------------------------
crow!rpaul at ccut.cc.u-tokyo.ac.jp phone: +81 (3) 5706-8357
ccut.cc.u-tokyo.ac.jp!crow!rpaul FAX: +81 (3) 5706-8437
More information about the Comp.sys.sgi
mailing list