sdb%hotmomma@uunet.uu.net (Scott Ballantyne) (02/18/91)
Hello: Is there a canonical way to keep track of connect time on a per-site basis when our system calls out with mail/news? After looking at the manuals, it appears the only way is to write a program to scan the uucp log files and compute connect time and charges based on the entries for each system. We would prefer not to enable process accounting. 1) Did I miss an option to UUCP that will cause it to keep connect time totals on its own? 2) Has anyone done this that could provide a solution/advice before I re-invent the wheel on my own? OS is SunOS 4.1 on a 3/60, with the new HDB/BNU UUCP. Mail or post replies, if there is enough interest, I will summarize for the net. Scott -- {sdb%hotmomma@uunet.uu.net | hotmomma!sdb@uunet.uu.net | uunet!hotmomma!sdb} "A hacker is a machine for turning coffee into programs"
bill@twg.bc.ca (Bill Irwin) (02/18/91)
sdb%hotmomma@uunet.uu.net (Scott Ballantyne) writes: }1) Did I miss an option to UUCP that will cause it to keep connect time } totals on its own? }2) Has anyone done this that could provide a solution/advice before I } re-invent the wheel on my own? I use an awk script I got from the net. It produces output like so: System Xfers Bytes rec Bytes xmt Connect Avg Xf Avg rec Avg xmt van-bc 6 806928 0 1:01:55 134488 217 0 TOTALS 6 806928 0 1:01:55 TTY Connect % Data % [ttyi1P] 01:01:55 100 806928 100% This report is not very full because the daily report has already run and the log files rotated, but you get the idea. If this could be of use to you, mail me and I will mail it to you. -- Bill Irwin - The Westrheim Group - Vancouver, BC, Canada ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uunet!van-bc!twg!bill (604) 431-9600 (voice) | Your Computer bill@twg.bc.ca (604) 430-4329 (fax) | Systems Partner
mpd@anomaly.SBS.COM (Michael P. Deignan) (02/19/91)
sdb%hotmomma@uunet.uu.net (Scott Ballantyne) writes: >Is there a canonical way to keep track of connect time on a per-site >basis when our system calls out with mail/news? After looking at >the manuals, it appears the only way is to write a program to scan the >uucp log files and compute connect time and charges based on the >entries for each system. We would prefer not to enable process >accounting. Programs already exist to do exactly this. One is called "uutraf", which digests the contents of your .Admin/xferstats file. Just adding one line of code to your nitely UUCP cleanup task can give you all the accounting data you need. If you need a copy, I can mail one to you - its rather small. MD -- -- Michael P. Deignan / They're not "bombs". -- Domain: mpd@anomaly.sbs.com / They're "gifts". -- UUCP: ...!uunet!rayssd!anomaly!mpd / "Gifts From Above". -- Telebit: +1 401 455 0347 /
bill@twg.bc.ca (Bill Irwin) (02/20/91)
bill@twg.bc.ca (Bill Irwin) writes: }I use an awk script I got from the net. It produces output like }so: }System Xfers Bytes rec Bytes xmt Connect Avg Xf Avg rec Avg xmt }van-bc 6 806928 0 1:01:55 134488 217 0 }TOTALS 6 806928 0 1:01:55 }TTY Connect % Data % }[ttyi1P] 01:01:55 100 806928 100% }This report is not very full because the daily report has already }run and the log files rotated, but you get the idea. If this }could be of use to you, mail me and I will mail it to you. Boy did I get a dump of requests in my mailbox for this! Here are the sources. One, "uucp_traffic" is just a shell script run manually. It will accept a file name as an argument and analyze it instead of the default. If you store your uucp xferstats into a monthly file, this file could be given as the argument and you would see the month's activity. The script "uucp_daily" is run from cron about 11:45 pm. It processes the days uucp xferstats file, mails the output and appends the file to a monthly log. The other file is the awk program that actually does the analysis and produces the report. Enjoy. ---- Cut Here and unpack ---- #!/bin/sh # This is a shell archive (shar 3.32) # made 02/20/1991 08:15 UTC by bill@TWG # Source directory /tmp/uucp.awk # # existing files WILL be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 3168 -rw-rw-r-- uucp.awk # 266 -rwxrwxr-x uucp_daily # 233 -rwxrwxr-x uucp_traffic # if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= uucp.awk ============== echo "x - extracting uucp.awk (Text)" sed 's/^X//' << 'SHAR_EOF' > uucp.awk && X# USAGE: awk -f syslog_awk /usr/spool/uucp/SYSLOG X# An awk script for printing a pretty report of UUCP activities from the X# UUCP SYSLOG - Erik E. Fair October 2, 1984 X# X# v7 UUCP X$4 == "received" { X sysname[$2] = $2; X by_rec[$2] += $6; X sec_rec[$2] += $8; X sys_xf[$2] ++; X} X# X# 4.2 BSD UUCP X$5 == "received" { X sysname[$2] = $2; X by_rec[$2] += $7; X sec_rec[$2] += $9; X sys_xf[$2] ++; X} X# X# System V UUCP X$6 == "<-" { X $1 = substr($1, 1, (index($1, "!") - 1)); X sysname[$1] = $1; X by_rec[$1] += $7; X sec_rec[$1] += $9; X sys_xf[$1] ++; X ttytime[$5] += $9; X ttyxfer[$5] += $7; X} X# X# v7 UUCP X$4 == "sent" { X sysname[$2] = $2; X by_xmt[$2] += $6; X sec_xmt[$2] += $8; X sys_xf[$2] ++; X} X# X# 4.2 BSD UUCP X$5 == "sent" { X sysname[$2] = $2; X by_xmt[$2] += $7; X sec_xmt[$2] += $9; X sys_xf[$2] ++; X} X# X# System V UUCP X$6 == "->" { X $1 = substr($1, 1, (index($1, "!") - 1)); X sysname[$1] = $1; X by_xmt[$1] += $7; X sec_xmt[$1] += $9; X sys_xf[$1] ++; X ttytime[$5] += $9; X ttyxfer[$5] += $7; X} XEND { X# X# print a report header X printf("System Xfers Bytes rec Bytes xmt Connect Avg Xf Avg rec Avg xmt\n") X for(i in sysname) { X# X# sort report by most connect time (selection sort) X first = 0; X for(j in sysname) { X if (sys_xf[j] > 0) { X tmp1 = sec_xmt[j]; X tmp2 = sec_rec[j]; X# Stupid AWK bug - needs a simple expression X time = (tmp1 + tmp2); X if (time > first) { X first = time; X sys = sysname[j]; X } X } X } X# X# 4.2 BSD awk seems to have problems. This check should not be necessary. X# Oddly enough, this problem also shows up in System V. WHY??? X if (sys_xf[sys] != 0) { X# X# time for some bean counting X tmp1 = sec_xmt[sys]; X tmp2 = sec_rec[sys]; X# Stupid AWK bug - needs a simple expression X time = (tmp1 + tmp2); X hours = time / 3600; X sec = time % 3600; X min = sec / 60; X sec %= 60; X tot_xf += sys_xf[sys]; X tot_by_rec += by_rec[sys]; X tot_by_xmt += by_xmt[sys]; X tot_time += time; X# X# protect myself against mathematical crime (divide by zero) X if (sec_rec[sys] == 0) X sec_rec[sys] = 1; X if (sec_xmt[sys] == 0) X sec_xmt[sys] = 1; X# X# print a pretty system report (god what an awful printf format...) X printf("%-8s%8d%11d%11d%4d:%.2d:%.2d%8d%9d%9d\n", \ Xsysname[sys], sys_xf[sys], by_rec[sys], by_xmt[sys], hours, min, sec, \ X((by_rec[sys] + by_xmt[sys]) / sys_xf[sys]), \ X(by_rec[sys] / sec_rec[sys]), \ X(by_xmt[sys] / sec_xmt[sys])); X# X# make certain we will not see this system again... (selection sort) X sys_xf[sys] = 0; X } X } X# X# calculate time split for total time (and print totals [*shudder*]) X hours = tot_time / 3600; X sec = tot_time % 3600; X min = sec / 60; X sec %= 60; X printf("\n%-8s%8d%11d%11d%4d:%.2d:%.2d\n", \ X "TOTALS", tot_xf, tot_by_rec, tot_by_xmt, hours, min, sec); X X X# X# tty usage report X# X printf("\n\n\nTTY\t\tConnect\t\t\%"); X printf("\tData\t\t\%\n"); X for(i in ttytime) { X X hours = ttytime[i] / 3600; X sec = ttytime[i] % 3600; X min = sec / 60; X sec %= 60; X X printf("%-10s\t%02d:%02d:%02d\t%3d\%\t%8d\t%3d\%\n", X i,hours,min,sec,ttytime[i]*100/tot_time, X ttyxfer[i],ttyxfer[i]*100/(tot_by_rec+tot_by_xmt)); X X } X} X SHAR_EOF $TOUCH -am 0219235491 uucp.awk && chmod 0664 uucp.awk || echo "restore of uucp.awk failed" set `wc -c uucp.awk`;Wc_c=$1 if test "$Wc_c" != "3168"; then echo original size 3168, current size $Wc_c fi # ============= uucp_daily ============== echo "x - extracting uucp_daily (Text)" sed 's/^X//' << 'SHAR_EOF' > uucp_daily && X: X# Mail the daily UUCP activity and append the file to the X# monthly log. X XSAGBIN=`cat /.SAGBIN` Xawk -f $SAGBIN/uucp.awk /usr/spool/uucp/.Admin/xferstats | \ X mail -s "Daily UUCP Activity" UUCP X Xset `date` XFile=$6$2 Xcd /usr/spool/uucp/.Admin Xcat xferstats >> $File SHAR_EOF $TOUCH -am 0220001491 uucp_daily && chmod 0775 uucp_daily || echo "restore of uucp_daily failed" set `wc -c uucp_daily`;Wc_c=$1 if test "$Wc_c" != "266"; then echo original size 266, current size $Wc_c fi # ============= uucp_traffic ============== echo "x - extracting uucp_traffic (Text)" sed 's/^X//' << 'SHAR_EOF' > uucp_traffic && X: X# Check the current day UUCP traffic by default or X# the traffic from a named file. X XSAGBIN=`cat /.SAGBIN` XFile=/usr/spool/uucp/.Admin/xferstats Xif [ $# -gt 0 ] Xthen X File=/usr/spool/uucp/.Admin/$* Xfi Xawk -f $SAGBIN/uucp.awk $File SHAR_EOF $TOUCH -am 0219235391 uucp_traffic && chmod 0775 uucp_traffic || echo "restore of uucp_traffic failed" set `wc -c uucp_traffic`;Wc_c=$1 if test "$Wc_c" != "233"; then echo original size 233, current size $Wc_c fi exit 0 -- Bill Irwin - The Westrheim Group - Vancouver, BC, Canada ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uunet!van-bc!twg!bill (604) 431-9600 (voice) | Your Computer bill@twg.bc.ca (604) 430-4329 (fax) | Systems Partner