Installation and Configuration of Pandora FMS and SMS Gateway

Go back to Pandora FMS documentation index

We are working on the translation of the Pandora FMS documentation. Sorry for any inconvenience.

Installation and Configuration of Pandora FMS and SMS Gateway

About the GSM device

We are using an special device to send SMS through a serial port (usb). You can use a generic GSM module accesible using USB/Serial Cable, or a GSM Phone with a USB/Serial connector supported by your hardware, this is not really important. Device used here, is the MTX 65 v3. And could be adquired for about 100$ in several websites like:

As you can see in Youtube, it's a pretty small and compatible device, with several optional components, like a GSM antenna (very useful if your datacenter is underground, for example).

Using a GSM mobile phone is also a good option, currently most modern mobile phones are supported on linux.

Installing the Device

The first step is to install the hardware device. This device is composed of several parts:

  • Standard USB cable, with small connector and an end.
  • Power supply (in this sample is European 220v, if you live in USA, please be sure that power supply supports 110v).
  • SIM card.
  • Pandora FMS SMS gateway device.


Open the Pandora FMS SMS gateway device and put the SMS card inside.



Plug to network in the “power” input, plug the USB cable in the SMS Gateway device and connect the other end to the Pandora FMS server using a standard USB port.



When you connect the device to the server, wait a few seconds and run “dmesg” command from the command line, you should see something like this screenshot. This means device has been recognized by the kernel and it's ready to accept commands on a device, like /dev/ttyACM0

If you're here, the hardware setup is done. If not, please review all steps and be sure that:

  • Device is connected and led is blinking in a green color.
  • Device is connected to the USB port, both sides of wire, one side to the SMS device, and other side to the Pandora FMS server host.
  • Device has a SIM card inside, and it's placed properly.

Configure SMSTools to Use the New Device

This device is managed by a software package called SMSTools. You can install smstools using the package provided by your Linux Distribution or use RPM package provided by Artica (only for RPM distributions).

Debian / Ubuntu

In Debian/Ubuntu, you need to “customize” the sendsms script that will use Pandora FMS

First, install the package from APT repositories

$ sudo apt-get install smstools

And then, you need to use a provided sample script to send sms from command line, and “customize” it:

 cp /usr/share/doc/smstools/examples/scripts/sendsms /usr/bin
 chmod 750 /usr/bin/sendsms

Edit /usr/bin/sendsms and add the following line to the end of script:

chmod 666 $FILE

RPM based system (SUSE, Redhat)

Using our RPM is easier, just install it:

# rpm -i smstools*.rpm

Configure SMStools

Edit base configuration file:

# vi /etc/smsd.conf

Put this contents. If your dmesg output is not ttyACM0, use the tty device detected by your system.

# Example smsd.conf. Read the manual for a description

# Example smsd.conf. Read the manual for a description

devices = GSM1
logfile = /var/log/smsd.log
loglevel = 10

device = /dev/ttyACM0
incoming = no
pin = 2920

Use the PIN assigned to your SIM, in this example, PIN is “2920”.

Then, start manually smstools:

# /usr/bin/smstools start

Send an SMS test. BEWARE: Phone numbers must have full (int.) preffix. In this sample, +34 is Spanish preffix, and my phone number is 627934648:

$ sendsms 34627934648 "Pandora FMS rocks"

Wait a minute and watch your logs to check that everything is correct. You should receive the SMS in a few seconds. Depending on the network, the first SMS can timeout every 10-20 seconds, after that, wait. The next SMS should be almost immediate. SMSTools uses a queue to send messages, so you can send as many as you want, and they will be out as soon as your mobile network could manage.

To see the logs:

# cat /var/log/smsd.log
2009-11-12 11:30:12,2, smsd: Smsd v2.2.20 started.
2009-11-12 11:30:12,6, smsd: outgoing file checker has started.
2009-11-12 11:30:12,6, GSM1: Modem handler 0 has started.
2009-11-12 11:30:13,6, smsd: Moved file /var/spool/sms/outgoing/send_mNZxHa to /var/spool/sms/checked
2009-11-12 11:30:13,6, smsd: I have to send 1 short message for /var/spool/sms/checked/send_iUegPD
2009-11-12 11:30:13,6, GSM1: Sending SMS from  to 627934648
2009-11-12 11:30:13,6, GSM1: Checking if modem is ready
2009-11-12 11:30:13,7, GSM1: -> AT
2009-11-12 11:30:13,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:14,7, GSM1: <- AT
2009-11-12 11:30:14,6, GSM1: Checking if modem needs PIN
2009-11-12 11:30:14,7, GSM1: -> AT+CPIN?
2009-11-12 11:30:14,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:14,7, GSM1: <- AT+CPIN?
2009-11-12 11:30:14,5, GSM1: Modem needs PIN, entering PIN...
2009-11-12 11:30:14,7, GSM1: -> AT+CPIN="2920"
2009-11-12 11:30:14,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:15,7, GSM1: <- AT+CPIN="2920"
2009-11-12 11:30:15,7, GSM1: -> AT+CPIN?
2009-11-12 11:30:15,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:15,7, GSM1: <- AT+CPIN?
2009-11-12 11:30:15,6, GSM1: PIN Ready
2009-11-12 11:30:15,6, GSM1: Checking if Modem is registered to the network
2009-11-12 11:30:15,7, GSM1: -> AT+CREG?
2009-11-12 11:30:15,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:16,7, GSM1: <- AT+CREG?
+CREG: 0,2
2009-11-12 11:30:16,5, GSM1: Modem is not registered, waiting 10 sec. before retrying

2009-11-12 11:30:26,7, GSM1: -> AT+CREG?
2009-11-12 11:30:26,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:26,7, GSM1: <- AT+CREG?
+CREG: 0,5
2009-11-12 11:30:26,6, GSM1: Modem is registered to a roaming partner network
2009-11-12 11:30:26,6, GSM1: Selecting PDU mode
2009-11-12 11:30:26,7, GSM1: -> AT+CMGF=0
2009-11-12 11:30:26,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:26,7, GSM1: <- AT+CMGF=0
2009-11-12 11:30:26,7, GSM1: -> AT+CMGS=94
2009-11-12 11:30:26,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:27,7, GSM1: <- AT+CMGS=94
2009-11-12 11:30:27,7, GSM1: -> 001100099126974346F900F1FF5CC8373BCC0295E7F437A83C07D5DDA076D93D0FABCBA069730A2297417079BD2C0EBB406779789C0ECF41F0B71C44AF83C66FB7391D76EBC32C503B3C46BFE96516081E7693DFF230C8D89C82E4EFF17A0E�
2009-11-12 11:30:27,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:31,7, GSM1: <- 001100099126974346F900F1FF5CC8373BCC0295E7F437A83C07D5DDA076D93D0FABCBA069730A2297417079BD2C0EBB406779789C0ECF41F0B71C44AF83C66FB7391D76EBC32C503B3C46BFE96516081E7693DFF230C8D89C82E4EFF17A0E�
+CMGS: 0
2009-11-12 11:30:31,5, GSM1: SMS sent, To: 627934648
2009-11-12 11:30:31,6, smsd: Deleted file /var/spool/sms/checked/send_iUegPD
2009-11-12 11:30:32,6, smsd: I have to send 1 short message for /var/spool/sms/checked/send_mNZxHa
2009-11-12 11:30:32,6, GSM1: Sending SMS from  to 34627934648
2009-11-12 11:30:32,7, GSM1: -> AT+CMGS=29
2009-11-12 11:30:32,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:33,7, GSM1: <- AT+CMGS=29
2009-11-12 11:30:33,7, GSM1: -> 0011000B914326974346F900F1FF11D0B09BFC968741C6E614247F8FD773�
2009-11-12 11:30:33,7, GSM1: Command is sent, waiting for the answer
2009-11-12 11:30:36,7, GSM1: <- 0011000B914326974346F900F1FF11D0B09BFC968741C6E614247F8FD773�
+CMGS: 1
2009-11-12 11:30:36,5, GSM1: SMS sent, To: 34627934648
2009-11-12 11:30:36,6, smsd: Deleted file /var/spool/sms/checked/send_mNZxHa

Finally, some tasks to could do to ensure the operation for the future:

1. Set 1 to loglevel in /etc/smsd.conf to avoid a very big, non-necessary log file.

2. Be sure that smsd is set to start automatically when system restart (this means a link to /etc/init.d/sms to /etc/rc2.d/S90sms or /etc/rc.d/rc2.d/S90sms). If you have installed it from a package, probably they exist already in your system, just checkit.

Configure Pandora FMS Alert

This steps reproduce the basic steps to create SMS alerts in Pandora FMS 3.x

Create the command:

Create the action:

Associate the action to a module using a previous alert template. In this case, alert template will be fired when the module status would be CRITICAL.

//Gateway// to Send SMS using a generic hardware and Gnokii

This method describe an alternative way to send SMS instead using smstools, using gnokii. This was the “old” method proposed for pandora 1.x and 2.x and it's written here only to have a second option. smstools method provided above is preferred.

This section describes how to build a SMS sending gateway based in a sending queue. This way, it is possible to implement a SMS sending server, connected with a mobile and sending the SMS through the software of the Gnokii project, and different remote servers can send its messages in order the SMS sending server could process them. This allow that different Pandora FMS servers (or another machines that want to use the gateway) could send messages in a centralized way, without having to have a mobile for each server.

In first place, you should create an «sms» user in the machine where you want to install it in the SMS sending gateway. After this, create the directories home/sms y /home/sms/incoming. If you want to use the SMS sending gateway from another machines, you will need to make accessible the directory /home/sms/incoming for other servers through any file sending system or file systems partition:NFS, SMB, SSH (scp), TCP or Tentacle.

The SMS sending gateway mechanism is very easy: for each file that is at the directory /home/sms/incoming, an SMS will be processed, deleted and sent, with the file content. This file should have an specific format, which is detailed here:


SMS Gateway Implementation

You should create four scripts:

SMS: Script that sends the SMS using Gnokii through an USB data cable.This script is only in the system where the sending gateway is (the system that has the data cable connected to a GSM mobile).

SMS_GATEWAY: Script that process in a periodical way the entry directory (/home/sms/incoming), processing files that are waiting to be send. This script is only in the system that is used as sending gateway.

SMS_GATEWAY_LAUNCHER: launcherScript for the SMS_GATEWAY script(start and stop daemon). This script is only in the system that does the sending gateway.

COPY_SMS: copies an SMS using the scpcommand from a client system to a gateway system. Uses the TELEPHONE as first parameter, and the second as text to send (using ““for specifying each parameter).The script trust in the SSH automatic autentication and in the «sms» user for the transfer. In the local system you can remplace the «scp» for the «cp» command or use a system like Tentacle to transfer the file.


This is the script that sends SMS using Gnokii. You should have Gnokii well configured (using the file /etc/gnokii.confor similar). Probably should be the user root to could launch the script, or establish the SETUIDO in the gnokii binary.

if [ $# != 2 ]; then
echo "I need more parameters"
exit 1;
/bin/echo $1 | /usr/local/bin/gnokii --sendsms $2 
SMS Gateway

This is the gateway daemon script:



while [ 1 ]

        for a in `ls $INCOMING_DIR`
                if [ ! -z "$a" ]
                        NUMBER=`cat $INCOMING_DIR/$a | cut -d "|" -f 1`
                        MESSAGE=`cat $INCOMING_DIR/$a | cut -d "|" -f 2`
                        TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
                        echo "$TIMESTAMP Sending to $NUMBER the message $MESSAGE" >> $HOME_DIR/sms_gateway.log
                        $HOME_DIR/sms "$MESSAGE" "$NUMBER"
                        echo "$TIMESTAMP Deleting $a" >>  $HOME_DIR/sms_gateway.log
                        rm -Rf $INCOMING_DIR/$a
                        sleep 1
        sleep 5
SMS Gateway Launcher

This is the launching script form the sms_gateway:


# SMS Gateway, startup script
# Sancho Lerena, <[email protected]>
# Linux Version (generic)

# Configurable path and filenames

# Main script

if [ ! -d "$SMS_PID_DIR" ]
        echo "SMS Gateway cannot write it's PID file in $SMS_PID_DIR. Please create directory or assign appropiate perms"

if [ ! -f $SMS_GATEWAY_HOME/sms_gateway ]
        echo "SMS Gateway not found, please check setup and read manual"

case "$1" in
        if [ -f $SMS_PID ]
                CHECK_PID=`cat $SMS_PID`
                CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "sms_gateway" | wc -l`
                if [ $CHECK_PID_RESULT == 1 ]
                        echo "SMS Gateway is currently running on this machine with PID ($CHECK_PID). Aborting now..."

        nohup $SMS_GATEWAY_HOME/sms_gateway > /dev/null 2> /dev/null & 2> /dev/null > /dev/null
        sleep 1

        MYPID=`ps aux | grep "$SMS_GATEWAY_HOME/sms_gateway" | grep -v grep | tail -1 | awk '{ print $2 }'`
        if [ ! -z "$MYPID" ]
                echo $MYPID > $SMS_PID
                echo "SMS Gateway is now running with PID $MYPID"
                echo "Cannot start SMS Gateway. Aborted."
        cd "$OLD_PATH"
        if [ -f $SMS_PID ]
           echo "Stopping SMS Gateway"
           PID_2=`cat $SMS_PID`
           if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'sms_gateway' `" ]
               kill `cat $SMS_PID` 2> /dev/null > /dev/null
               echo "SMS Gateway is not executing with PID $PID_2, skip Killing step"
           rm -f $SMS_PID
          echo "SMS Gateway is not running, cannot stop it."
        $0 stop
        $0 start
        echo "Usage: sms_gateway {start|stop|restart}"
        exit 1

This small script creates a SMS sending file in a client machine and copies it to the SMS gateway using scp:


SERIAL=`date +"%j%M%s"`


echo $TEL\|$TEXT >> /tmp/$SERIAL
scp /tmp/$SERIAL [email protected]:/home/sms/incoming
rm -Rf /tmp/$SERIAL1

Go back to Pandora FMS documentation index