improved version of afpstat script


Subject: improved version of afpstat script
From: jhart@abacus.bates.edu
Date: Thu Mar 23 2000 - 12:42:19 EST


This will print the main info in neat columns, one line per user.

----------------cut here------------------
#!/bin/sh
# Must be run as superuser.
#
# set up the raw work files
ps aux |
  grep afpd |
  grep -v grep |
  awk '$1 != "root" {print $2, $1}' |
  sort -k 1 > /tmp/afpstat1
grep 'afpd\[' /var/log/messages |
 awk '{match($5,/\[.*\]/);print substr($5,RSTART + 1, RLENGTH - 2), $0}' |
 sort -k 1 > /tmp/afpstat2
# now, join the results together by process id
join /tmp/afpstat1 /tmp/afpstat2|
 awk '
BEGIN{ OFS = "\t"
    printf "%-9s%-16s%-16s%-13s%8s%8s\n", "username", "loginDT",
"IPAddr", "ATAd
dr", "userID", "groupID"
    printf "%-9s%-16s%-16s%-13s%8s%8s\n", "--------", "-------",
"------", "----
--", "------", "-------"
}
procid != $1 {
  if( procid != "" ) {
    printf "%-9s%-16s%-16s%-13s%8d%8d\n",username, loginDT, IPAddr,
ATAddr, user
ID, groupID
  }
}
/session.*from/ {
  username = $2
  loginDT = $3 " " $4 " " $5
  if( $8 == "ASIP") {
    IPAddr = substr($11,1,index($11,":") - 1)
    ATAddr = "-"
  } else {
    ATAddr = $10
    IPAddr = "-"
  }
  procid = $1
}
$8 == "login" {
  userID = substr($11,1,length($11) - 1)
  groupID = substr($13,1,length($13) - 1)
  procid = $1
}
END {
    printf "%-9s%-16s%-16s%-13s%8d%8d\n",username, loginDT, IPAddr,
ATAddr, user
ID, groupID
}'
# get rid of the work files
rm /tmp/afpstat*
--------------------cut here-------------------------

---
Jim Hart
"Organization is necessary for things to exist; Chaos is necessary for 
things to evolve."

-----BEGIN PGP PUBLIC KEY BLOCK----- Version: PGPfreeware 5.0 for non-commercial use <http://www.pgp.com>

mQBvAzOe/64AAAEDAM2s9O/EPXKlnvPOnJDH0f1KWg0iIM4i5tT7aywHcbW2Acgr b7aaTMe0eEMu+aSDjAto9+nYSHGOG/8ni/V7aW60W2zF1AQ8dPcyLZ9l1FaoWcr2 CP8uL2bZNGZvghpEdQARAQABtCBKaW0gSGFydCA8amhhcnRAbWFpbC5hdmNuZXQu b3JnPg== =ymPR -----END PGP PUBLIC KEY BLOCK-----



This archive was generated by hypermail 2b28 : Wed Jan 17 2001 - 14:30:17 EST