Cover V03, I03
Article
Figure 1
Figure 2
Figure 3
Listing 1
Listing 2
Listing 3

may94.tar


Listing 1: idleout

#!/bin/sh
#
#
w -h |
awk ' {
name = $1;
terminal = $2;
idle = $4;
localpath = "/usr/user/"

cmd = sprintf(localpath"getparms %s",name)
cmd | getline parameters
close(cmd)
split(parameters,parms," ")
killtime = parms[1]
warntime = parms[2]

split(idle,idleparts,"d")

if ( idleparts[2] != "" ) {
hour = idleparts[1] * 24
idle = hour":00"
}

split(idle,idletime,":")

if ( idletime[2] == "" )
{
hour = 0
minute = idletime[1]
}
else {
hour = idletime[1]
minute = idletime[2]
}
idletotal = hour * 60 + minute

if ( killtime > 0)
{
if ( idletotal >= killtime) {
message = sprintf("killing you, idle for %d minutes",idletotal);
cmd=sprintf(localpath"wruser %s %s",terminal,message);
cmd | getline pid
close cmd
system("kill -9 " pid )
system("echo tn: killed " name " at `date`  >> /usr/tmp/logging")
}
else {
if (idletotal >= warntime) {
message = sprintf("Warning !!!  spotted idle for %d minutes",idletotal)
cmd=sprintf(localpath"wruser %s %s",terminal,message);
cmd | getline pid





close cmd
}
}
}

} '