Hello,

I've made some modification to the LoadBalancing Script to suit my needs.
Bellow is the sample script for 2 GSM Modems and 2 Queues.

#!/bin/bash

# Settings for this script:
STATSDIR=/var/spool/sms/stats
MODEMS=( modem1 modem2 )
QUEUES=( Q1 Q2 )

# ---------------------------------------------------------------------------------------

NUMBER_OF_MODEMS=${#MODEMS[@]}
NUMBER_OF_QUEUES=${#QUEUES[@]}
if [ $NUMBER_OF_MODEMS -ne $NUMBER_OF_QUEUES ]; then
  echo "ERROR: Number of queues does not match number of modems."
  exit 1 # Message is rejected.
fi

read_counter()
{
  local RESULT=0
  local FILE=$STATSDIR/$1.counter
  local COUNTER=0

  if [[ -e $FILE ]]
  then
    COUNTER=`formail -zx $1: < $FILE`
    if [ "$COUNTER" != "" ]; then
      RESULT=$COUNTER
    fi
  fi

  return $RESULT
}


# If there is Queue (or Provider) defined, load balancing is ignored:
QUEUE=`formail -zx Queue: < $1`
if [ -z "$QUEUE" ]; then
  QUEUE=`formail -zx Provider: < $1`
  if [ -z "$QUEUE" ]; then
 
    FILEID="$1"
    MSG_ID=${FILEID##*.}

    rem=$(( $MSG_ID % 2 ))
 
    if [ $rem -eq 0 ]
    then
#     echo "Sending through Q2"
     QUEUE='Q2'
    else
#     echo "Sending through Q1"
     QUEUE='Q1'
    fi

    TMPFILE=`mktemp /tmp/smsd_XXXXXX`
    cp $1 $TMPFILE
    formail -f -I "Queue: $QUEUE" < $TMPFILE > $1
    unlink $TMPFILE
  fi
fi
exit 0
 
'bash' Syntax Highlight powered by GeSHi


Basically it reads the name of the file created by playsms and if the number is odd/even and it selects the proper Queue.
Example:
1. Playsms saves the file : /var/spool/sms/outgoing/out.0.1.4435
2. The script reads la last part: 4435
3. Selects the proper Queue for delivery

This is better, for me, because loadbalancing is done before actually sending one single sms. This is useful when you want to send sms messages from file or to large GROUP.

You can modify the script for more than 2 Queues.

Any feedback is appreciated. :)

Best regards,
George