Sun N1 Grid Engine 6.1 Administration Guide

Example of a Load Sensor Script

The following example shows a load sensor. The load sensor is a Bourne shell script.

Example 3–2 Load Sensor – Bourne Shell Script


myhost=`uname -n`

while [ 1 ]; do
     # wait for input
     read input
     if [ $result != 0 ]; then
          exit 1
     if [ $input = quit ]; then
          exit 0
     #send users logged in
     logins=`who | cut -f1 -d" " | sort | uniq | wc -l | sed "s/^ *//"`
     echo begin
     echo "$myhost:logins:$logins"
     echo end

# we never get here

exit 0

Save this script to the file Assign executable permission to the file with the chmod command. To test the script interactively from the command line, type and repeatedly press the Return key.

As soon as the procedure works, you can install it for any execution host. To install the procedure, configure the load sensor path as the load_sensor parameter for the cluster configuration, global configuration, or the host-specific configuration. See Basic Cluster Configuration or the sge_conf(5) man page for more information.

The corresponding QMON window might look like the following figure:

Dialog box titled Cluster Settings. Shows General Settings
tab with Mailer, Xterm, and Load Sensor paths. Shows Ok and Cancel buttons.

The reported load parameter logins is usable as soon as a corresponding attribute is added to the complex. The required definition might look like the last table entry shown in the following figure.

Dialog box titled Complex Configuration. Shows definition
for logins resource attribute. Shows Add, Modify, Delete, Load, and Save buttons.