Uucp activity summary - awk script
utzoo!decvax!genrad!linus!sch
utzoo!decvax!genrad!linus!sch
Wed Apr 13 11:13:16 AEST 1983
Here is a little ditty to summarize up uucp traffic.
To run:
awk -f uusum </usr/spool/uucp/SYSLOG
for you 4.1bsd folks, just will do:
uusum </usr/spool/uucp/SYSLOG
You could even have cron run it and mail you the results.
--------------------- uusum ----------------------------
#! /bin/awk -f
# Summarize uucp activity.
# Record format in SYSLOG:
# $1 $2 $3 $4 $5 $6 $7 $8 $9
# USER SYSTEM Date/Time sent data NBYTES bytes NSECS secs
{
if( $4 == "sent" ) {
txbytes[$2] += $6;
txtime[$2] += $8;
txsystem[$2] = $2;
next;
}
if( $4 == "received" ) {
rcsystem[$2] = $2;
rcbytes[$2] += $6;
rctime[$2] += $8;
next;
}
}
END {
print "Data sent";
printf " system bytes time rate (cps)\n";
printf "--------------------------------------------\n";
for ( i in txsystem) {
t = txtime[i];
n = txbytes[i];
printf "%-10s %10d ", txsystem[i], n;
printf "%4d:%02d:%02d ", t/3600, (t%3600)/60,t%60;
printf "%10.2f\n", n/t;
intotal += n;
intime += t;
}
printf "Total sent : %d bytes (%d:%02d:%02d)\n\n", intotal, intime/3600, (intime%3600)/60, intime%60;
print "Data received";
printf " system bytes time rate (cps)\n";
printf "--------------------------------------------\n";
for ( i in rcsystem) {
t = rctime[i];
n = rcbytes[i];
printf "%-10s %10d ", rcsystem[i], n;
printf "%3d:%02d:%02d ", t/3600, (t%3600)/60, t%60;
printf "%10.2f\n", n/t;
outtotal += n;
outtime += t;
}
printf "Total received : %d bytes (%d:%02d:%02d)\n\n", outtotal, outtime/3600, (outtime%3600)/60, outtime%60;
total = intotal + outtotal;
time = intime + outtime;
printf "Grand Total : %d bytes (%d:%02d:%02d)\n", total, time/3600, (time%3600)/60, time%60;
}
More information about the Comp.sources.unix
mailing list