1case $# in 20) 3 FILE=/usr/spool/uucp/SYSLOG 4 ;; 51) 6 FILE=$* 7 ;; 8*) 9 echo "usage: uustat [syslog]" 10 ;; 11esac 12awk ' \ 13 $5 ~ /received/ {ftotal++; fcount[$2]++; fbytes[$2] += $7; \ 14 fsecs[$2] += $9} \ 15 $5 ~ /sent/ {ttotal++; tcount[$2]++; tbytes[$2] += $7; \ 16 tsecs[$2] += $9} \ 17 { curtime = substr($4, 5, 6); \ 18 dtmp = curtime - int($9) - lasttime[$2]; \ 19 if (dtmp > 0) if (dtmp < 20) \ 20 dead[$2] += dtmp; \ 21 lasttime[$2] = curtime; \ 22 live[$2] += $9 ; \ 23 } \ 24 END { if (ftotal) for (i in fbytes) { \ 25 printf "got from %8s %4d files %7d bytes %5d secs", i, \ 26 fcount[i], fbytes[i], fsecs[i]; \ 27 if (fsecs[i]) printf " %.2f bytes/sec", fbytes[i]/fsecs[i]; \ 28 printf "\n"; } \ 29 if (ttotal) for (i in tbytes) { \ 30 printf "sent to %8s %4d files %7d bytes %5d secs", i, \ 31 tcount[i], tbytes[i], tsecs[i]; \ 32 if (tsecs[i]) printf " %.2f bytes/sec", tbytes[i]/tsecs[i]; \ 33 printf "\n"; } \ 34 for (i in live) { \ 35 printf "%8s live%5d secs dead%5d secs\n", i, live[i], dead[i]; } \ 36 }' \ 37$FILE 38