[Contents] [Prev] [Next] [End]


Chapter 5. LSF Shell Programming


LSF provides a set of tools (lstools) that allow users to write load sharing shell scripts. This set of tools perform the LSF API services at the command line level.

The most commonly used tools include lsrun, lsgrun, lsplace, lsload, lsrcp, lshosts, lseligible, lsid, and lsinfo.

This chapter briefly describes how to use the lstools commands to write load sharing shell programs.

All shell examples are written in the Bourne shell (/bin/sh). The techniques in this chapter also apply to higher level languages such as Perl and TCL.

Wrapper Scripts

The most common load sharing shell scripts are simple wrappers around third party binaries. The shell script turns an ordinary application into a load sharing application with no changes to the third party code. For example, this script starts up FrameMaker on a host that has the frame resource:

#! /bin/sh
exec lsrun -R "frame" maker

The Simple Shell Example

In this section is a simple load sharing shell, written as a Bourne shell (/bin/sh) script. The simple shell loops reading lines of input from the keyboard. Each line is checked to see if the command entered is eligible for remote execution. If so, it is executed remotely using lsrun. Otherwise the command is executed on the local host.

#! /bin/sh
while echo Input command: ; read command
do
if [ "$command" ]; then
    # put the command into the positional parameters $1, $2 etc. so you
    # can get the command name ($1, the first argument in the command)
    set $command
    # lseligible returns true if command is eligible for remote execution
    if resourcereq=`lseligible -q $1`
    then
        lsrun  -v  -R  "$resourcereq"  $command
    else
        $command
    fi
fi
done

The lseligible -q command is used to determine whether the given task is eligible for remote execution or not. It displays the resource requirement for the command and exits with status 0 if the command can be run remotely. lseligible exits with a non-zero status if the command should be run on the local host.

Changing the Placement Algorithm

If you do not like the default placement decision made by lsrun, you can also make your own placement decision by getting the load information with lsload and choosing the host based on your own policy. For example, you could use an awk or perl script to process the load information and sort the hosts based on your own criteria.


[Contents] [Prev] [Next] [End]

doc@platform.com

Copyright © 1994-1997 Platform Computing Corporation.
All rights reserved.