SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Wed Apr 24, 2024 06:55
SMSTools3 Community » Help and support Bottom

[answered] Provider queue processing with several modems

  This topic is locked

Page:  1

Author Post
Member
Registered:
Sep 2010
Location: Braga, Portugal
Hi,

Consider a scenario where I have a provider queue with several modems attached to it.

If 10 sms enter the queue at the same time how are they processed? And if they enter at a rate of 1 per hour?

Are the messages send to the first declared modem on the queue and only try the next one if the first is down or busy?

Are they distributed fairly among the modems?

Can this by configured?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
rjlopes wrote
Consider a scenario where I have a provider queue with several modems attached to it.

If 10 sms enter the queue at the same time how are they processed? And if they enter at a rate of 1 per hour?

In Unix "at the same time" means that all files have the same timestamp, because the time resolution is one second. Oldest file is processed first, but with same timestamps files are selected by the alphabetic order of a name.

Each modem will try to get a file. When smsd is started, modem processes are searching for files almost simultaneously. Later, when some messages are sent and received, they are not searching exactly at the same time. In cannot be known, or defined, which modem will get the next message. The modem which will see the message first, will send it.

rjlopes wrote
Are the messages send to the first declared modem on the queue and only try the next one if the first is down or busy?

No. Any modem can pick up the message. If the first modem is busy, it does not search for files, but other modems will search (if not busy too).

rjlopes wrote
Are they distributed fairly among the modems?

Can this by configured?

There are no configuration options for this. When sending large number of messages with several modems, all modems will always have something to send. Also, usually the time of sending does matter, not the number of messages. Longer messages take more time, and in some cases there can be retries, or failures. Because of this, smsd does not even try to distribute messages "fairly".

If you need that the balance of each SIM is used evenly, you need to create an external "load balancing". This kind of a functionality can be done with a checkhandler. In the scripts directory of a package, there is a sample script load_balancing.sh. I include it here:

#!/bin/bash
# ---------------------------------------------------------------------------------------
# This example is for three modems, named GSM1, GSM2 and GSM3
# using queues Q1, Q2 and Q3.
# In the global part of smsd.conf, enable message counters:
# stats = /var/spool/sms/stats
# Use zero value for interval if statistics files are not used:
# stats_interval = 0
#
# Enable checkhandler (this script):
# checkhandler = /usr/local/bin/load_balancing.sh
#
# Define queues and providers:
# [queues]
# Q1 = /var/spool/sms/Q1
# Q2 = /var/spool/sms/Q2
# Q3 = /var/spool/sms/Q3
#
# [providers]
# Q1 = 0,1,2,3,4,5,6,7,8,9,s
# Q2 = 0,1,2,3,4,5,6,7,8,9,s
# Q3 = 0,1,2,3,4,5,6,7,8,9,s
#
# Add queue definition for each modem:
# [GSM1]
# queues = Q1
# etc...
# ---------------------------------------------------------------------------------------

STATSDIR=/var/spool/sms/stats

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

  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 [ "$QUEUE" = "" ]; then
  QUEUE=`formail -zx Provider: < $1`
  if [ "$QUEUE" = "" ]; then
    # Read current counters:
    read_counter GSM1
    COUNTER1=$?
    read_counter GSM2
    COUNTER2=$?
    read_counter GSM3
    COUNTER3=$?

    QUEUE=Q1
    COUNTER=$COUNTER1
    if [ $COUNTER2 -lt $COUNTER ]; then
      QUEUE=Q2
      COUNTER=$COUNTER2
    fi
    if [ $COUNTER3 -lt $COUNTER ]; then
      QUEUE=Q3
      COUNTER=$COUNTER3
    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


Member
Registered:
Sep 2010
Location: Braga, Portugal
Topic owner
Awesome.

Thank you very much

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
If you are planning to create some kind of "fairly distribution", check this topic too: Sample script for load balancing using the checkhandler. The new version of the script is easier to use, and easier to enhance with some "message limit" counters, if necessary.

  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.