Tracking Interactive Idle Time

This note explains how to set up Grid Engine to track interactive idle time for desktop workstations. This is useful if you want to use desktop workstations only when the owner is not using it. If the owner returns and moves the mouse, the queue on this host is suspended along with the jobs currently running. When the system is again idle for 5 minutes (or any other amount of time), the jobs on the host will be resumed.

It is necessary to first add the resource to the host complex:

name   shortcut   type   value      relop   requestable   consumable   default
iidle ii DOUBLE infinity <= NO NO 0

If you need more information on how to do this, see the appnote Attaching A Resource To A Host in Grid Engine.

Then, you need to have a script (load sensor) to keep track of the current idle time on each host. A sample script is included below. Also, look in the Grid Engine distribution under $SGE_ROOT/util/resources/loadsensors for some other examples.

In the main qmon window, click on "Cluster Configuration". Highlight either "global", or only certain hosts for this to run on, then click on "Modify". On the "General Settings" tab, add the path and name of the load sensor program to the load sensor box. Once OK is pressed, the load sensor will be automatically started on each host. This may take several minutes.

Finally, you need to configure the queue(s) to suspend a queue when the idle time is below 5 minutes (or any length of time) and unsuspend it when it is above. In the main qmon window, click on "Queue Configuration". Highlight a queue running on the desktop workstation and click on "Modify". On the "Load/Suspend Thresholds" tab, under the "Suspend Thresholds" table, click on the "Load" title heading and you will see the "Select an Item" popup window. Choose the idle time resource, (eg, iidle) and click OK. In the "Value" column, enter the thresholds time in hr:min:sec format (eg, five minutes would be 0:5:0). Press Return

The right side of the "Queue Configuration: Modify" window shows the additional paramters "Suspend interval" and "Jobs suspended per interval". Typically, for this kind of setup, you would set the "Jobs suspended per interval" equal to the number of slots in the queue, and the "Suspend interval" equal to some fraction of the Suspend Threshold, eg,1 minute for a 5 or 10 minute Suspend Threshold. NOTE: make sure this is not lower than the "Load Report Time" interval (Qmon --> Cluster Configuration). When you are finished, click OK for the "Queue Configuration: Modify" window.

Now, all jobs running in that queue will get suspended if the mouse or keyboard on the desktop workstation is moved, and will get unsuspended after the mouse and keyboard have been idle for 5 minutes (plus a margin of time equal to the Suspend Interval).


# (c) 2000 Sun Microsystems, Inc
# report interactive inactivity in seconds for SOLARIS 2.X

# invariant values

while [ $end = false ]; do

   # ---------------------------------------- 
   # wait for an input
   read input
   if [ $? != 0 ]; then
   if [ "$input" = "quit" ]; then

   # "filestat -atime" returns time of last access of given file
   # in seconds since 1/1/1970
   kbdtime=`$SGE_ROOT/utilbin/$ARC/filestat -atime /dev/kbd`
   mousetime=`$SGE_ROOT/utilbin/$ARC/filestat -atime /dev/mouse`   

   # "now" returns current time in seconds since 1/1/1970

   if [ "$kbdtime" -gt "$mousetime" ]; then
      idletime=`expr "$now" - "$kbdtime"`
      idletime=`expr "$now" - "$mousetime"`

   echo "begin"
   echo "$myhost:iidle:$idletime"
   echo "end"