kovar@husc4.harvard.edu (David Kovar) (05/30/89)
When I run ac over my wtmp files, I tend to get output that looks like
this:
s89aa008101.61 (Account name is "s89aa008")
s89ad002 4.24
jkahng 9.89
s89ad000 4.36
s89ad003132.50 (Account name is "s89ad003")
wade 12.51
s89aa003 29.69
s89ad008 71.95
s89aa004226.27 (Account name is "s89aa004")
Any account names that are eight characters long run into any time fields
that are three digits wide on the left side of the decimal point. This
makes parsing the output with awk a tad difficult. Does anyone have a
patch or a new copy of ac that will fix this problem?
-David C. Kovar
Technical Consultant ARPA: kovar@husc4.harvard.edu
Office of Information Technology BITNET: corwin@harvarda.bitnet
Harvard University MacNET: DKovar
Ma Bell: 617-495-5947
"It is easier to get forgiveness than permission."dupuy@cs.columbia.edu (06/21/89)
No fix for ac(8) (or sa(8), same problems), but this is what I do to break
apart the fields:
echo " user connect"
/usr/etc/ac -p | awk '
NF == 1 { printf("\t%-8.8s %9.9s\n", substr($0, 2, 8), substr($0, 10)); }
NF == 2 { printf("\t%-8.8s %9.9s\n", $1, $2); }' | sort -nr +1
echo " user processes cpu mins i/o blocks memory usage"
/usr/etc/sa -m 2>&1 | egrep -v '32767|65534' | awk '
NF == 4 { printf("\t%-8.8s %s\n", substr($0, 1, 8), substr($0, 9)); }
NF == 5 { printf("\t%-8.8s %s\n", $1, substr($0, 9)); }' \
| sort -nr +2 -3 +4 -5 +3 -4 +1 -2
Together, these two make a very nice cpu usage and connect time summary.
If someone was very motivated, they could do a join(1) on the ac and sa
output, to get a single accounting entry, but it wouldn't fit in 80
characters anymore.
@alex