Hi Thierry,

Thierry Dumont schrieb am 30. Sep 2010 um 14:20:25 CEST:
> The idea is that we only need some sort of very simple load balancing: 

I use such a simple load balancing via get_hosts since years.

In my lts.conf I have a (self created) variable:
OTS_SERVERS      = ots-v1 ots-v2 ots-v3
Additionally you have to remove any LDM_SERVER entries.

Then I have this get_hosts script at /opt/ltsp/i386/usr/lib/ltsp/:

==============================================================================
#!/bin/bash
##############################################################################
# $Id: get_hosts,v 1.1 2008-08-05 10:49:55 heli Exp $
##############################################################################

LOGFILE=/tmp/ots-serverlist
echo `date` >$LOGFILE
LIST=""

# Load query on all servers
for i in $OTS_SERVERS; do
    LOAD=`nc $i 9571|grep rating|cut -d: -f2`
    if test $LOAD; then
        # add to the list
        LIST="$LIST$LOAD $i\n"
    fi
done

# Now LIST contains the list of servers sorted by load
LIST=`echo -e $LIST | sort -nr`
echo $LIST >>$LOGFILE

# Check if the 1st items have the same load. If so, randomly choose one.
OLDIFS=$IFS
IFS="
"
BESTLIST=( )
I=0
for LINE in $LIST ;do
    LOAD=`echo $LINE|cut -f 1 -d " "`
    if [ "$OLDLOAD" -a "$LOAD" != "$OLDLOAD" ] ;then
        break
    fi
    BESTLIST[$I]="$LINE"
    OLDLOAD=$LOAD
    I=$((I+1))
done
RAND=$(( $RANDOM % $I ))
# print the choosen host
echo ${BESTLIST[$RAND]} | cut -f 2 -d " "

# and again into the file:
echo The very best: >>$LOGFILE
echo ${BESTLIST[$RAND]} | cut -f 2 -d " " >>$LOGFILE

exit 0
==============================================================================

Save it as /opt/ltsp/i386/usr/lib/ltsp/get_hosts and chmod it 755.

Enjoy
Helmut

-- 
-------------------------------------------------------------------------
Helmut Lichtenberg  <[email protected]>  Tel.: 05034/871-128
Institut für Nutztiergenetik (FLI)         31535 Neustadt         Germany
-------------------------------------------------------------------------

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_____________________________________________________________________
Ltsp-discuss mailing list.   To un-subscribe, or change prefs, goto:
      https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
For additional LTSP help,   try #ltsp channel on irc.freenode.net

Reply via email to