Opsview Knowledge Center

SMS Module

Learn how to install Opsview Monitor SMS module

Please see the sub-sections for information on the installation, configuration and testing of the SMS module - which allows for the sending of SMS messages via a GSM modem.


In order to use the SMS notification module, the 'SMS gateway' must be installed first. This software consists of four utilities, which are run from command shell:

  • submit_sms - submits SMS messages onto the queuing system
  • device_admin - an administrative front end to the device configuration
  • message_admin - an administrative front end to the message queues
  • check_smsgateway - a Nagios plugin to report status of system.

and one daemon:

  • smsqueued - handles queuing of messages and status of devices.

Currently the following GSM devices are known to work with this software:

  • Maestro GSM Modem [more info ] \x{00E2}\x{0086}\x{0090} recommended by Opsview.
  • Nokia mobile phone with serial adaptor
  • Sony Ericsson mobile phone with serial adaptor
  • Siemens MC35i
  • Wavecom FastTrack

SMS Gateway software uses extended Hayes AT command set.

In order to use the SMS notification module, the 'SMS gateway' must be installed first. This consists of a single package which needs to be installed on the Opsview Monitor Master/Slave servers.

Note: The SMS gateway relies on MySQL as a dependency; this is not an issue for the master server however for the slave servers the packages 'mysql' and 'mysql-client' need to be installed first. Also, the 'nagios' user must be added to a suitable group to access the serial devices. You can check which group this is by checking the permissions on the devices, as in the below example:

[root@server]# ls -la /dev/ttyS*
crw--w---- 1 root tty     4, 64 Apr 28 14:54 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Apr 28 14:54 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Apr 28 14:54 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Apr 28 14:54 /dev/ttyS3

In this specific case, the 'nagios' user must be a member of the 'dialout' group for devices ttyS1 to 3, but group 'tty' for ttyS0.

To install the opsview-smsgateway package, run the automated module installation method via the command:

curl -L [https://install.opsview.com](https://install.opsview.com) | sudo bash -s -- -m

Alternatively, install the 'opsview-smsgateway' package using your package manger of choice (apt or yum, depending on your operating system).


Once installed, the SMS gateway needs to be configured. To do this, run the commands below from the directory '/opt/opsview/smsgateway', as a User with root privileges.

First, install the databases required by the SMS gateway:


Alternatively, if you wish to install the database remotely please use the postinstall_root.pl command with the following options:

./installer/postinstall_root.pl -h $REMOTE_DATABASE_HOSTNAME -P$REMOTE_DATABASE_PORT -p$PASSWORD_FOR_SMSGATEWAY #Password is optional as postinstall will generate one if not provided

Secondly, with root privileges, run the following commands from within the /opt/opsview/smsgateway/bin directory) to create the database:

./rc.smsgateway db_install

If the root MySQL account has a password set or you want to install on a remote database (be aware of the security implications of using this), , use:

./rc.smsgateway -p <password> db_install

The Database should be installed locally or remotely depending upon the commands ran.

Once the databases are installed, you should next set the correct GSM device options by editing altinity.pl (within the /opt/opsview/smsgateway/bin directory):

$d->name("Primary");# Name of device - Primary, Secondary,etc.
$d->port("/dev/ttyS0");# Communication port to which GSM modem is attached (/dev/ttyUSB0 for USB)

Next, 'apply' the configuration for the GSM device. Note: This MUST be run before any 'device_admin' commands:

./altinity.pl# Enter the PIN for SIM card if required

Next, test the GSM devices using the below commands:

./device_admin test Primary    #To test device works
./device_admin show Primary    #To list configured devices

Finally, we can register the new daemon with the Opsview Watchdog and start the service - do this by running the following (a user with root privileges)

/opt/opsview/watchdog/bin/opsview-monit reload

You can now test that it is all working using the scripts below. These scripts live within the /opt/opsview/smsgateway/bin directory and should be executed as a User with root privileges:

./check_smsgateway    #Nagios plugin to return status of queue daemon
./submit_sms -n <number> -t <text message>    #To send a test message

To check the GSM devices are functioning correctly, run:

/opt/opsview/smsgateway/bin/device_admin test Primary


Message queues can be examined with the 'message_admin' command. Use this command to list any failed messages, i.e.:

/opt/opsview/smsgateway/bin/message_admin status
/opt/opsview/smsgateway/bin/message_admin list failed
/opt/opsview/smsgateway/bin/message_admin show <message id>
/opt/opsview/smsgateway/bin/message_admin reset <message id> queued

If there are significant numbers of messages to reset, the following is available (i.e. if the daemon fails and there are lots of messages that should not be sent when the daemon is restarted):

/opt/opsview/smsgateway/bin/message_admin mass_reset queued sent

Logs are stored within /var/opt/opsview/smsgateway. There are three main logs:

  • modem.log - logging from modem use
  • smsqueued.log - general logging from the smsqueued daemon
  • smsqueued.err - error logging from the smsqueued daemon

In the event of a failure, check the log files. If a CME or CMS error number is present, check the following page for what it may mean: http://www.smssolutions.net/tutorials/gsm/gsmerrorcodes/

Note, some error messages are automatically dealt with, such as

CMS ERROR: 38 (network out of order) - can be an incorrect phone number, or a number that cannot be sent an SMS message.THe message is failed and the next one in the queue is actioned.

If there is a modem failure then some diagnostic tests are run (and results logged) and the modems reset.

Device Primary in use - cannot get_device_info

Perform the following steps:

cd /opt/opsview/smsgateway/bin/
./device_admin reset Primary

Rerun the test to prove the reset has worked.

SMS gateway is down

Perform the following steps to retest the gateway, if successful it will be brought back up and queued messages resent:

/etc/init.d/smsqueued stop
/opt/opsview/smsgateway/bin/device_admin test Primary
/etc/init.d/smsqueued start

Rerun the test to prove the reset has worked.

Querying the Modem Directly

Sometimes it can be useful to send commands directly to the modem to troubleshoot connection issues. To do so you need a terminal emulator, for example minicom. Configure minicom to connect to the modem's serial device, and connect. You can now issue the following commands to check the modem status:

Turn on enhanced error reporting: AT+CMEE=1
Confirm it's on: AT+CMEE?
Check which network we're associated with: AT+COPS?
List all available networks: AT+COPS=?
Check our registration status: AT+CREG?
send a text message to +441234: AT+CMGS="+441234" message.^Z

If a command succeeds the device will print 'OK' as well as return any data if requested, otherwise it will report 'ERROR'. If you turn on extended error message handling, you will get code when an error is generated. A list of these errors can be found at: http://www.smssolutions.net/tutorials/gsm/gsmerrorcodes/

opsview-smsqueued cant open modem.log

If you see the following error when trying to start opsview-smsqueued:

$ /etc/init.d/opsview-smsqueued start
Could not open /var/opt/opsview/smsgateway/modem.log to start logging at /opt/opsview/smsgateway/bin/../perl/lib/Device/Modem/Log/File.pm line 49

Then it is likely that the ownership of the log is incorrect EG root:root -

$ cd /var/opt/opsview/smsgateway
$ ls -l
-rw-r--r-- 1 root root 75 Nov 19 15:34 modem.log

This can be caused by trying to start the opsview-smsqueued process as the root User instead of the nagios user.

To remedy this delete the modem.log currently owned by root:root

Then start the opsview-smsqueued process as the nagios user -

$ su - nagios
$ /etc/init.d/opsview-smsqueued <start | status | stop | restart>
You should then see that the log has been recreated with the correct ownership - 
$ cd /var/opt/opsview/smsgateway
$ ls -l
-rw-r--r-- 1 nagios nagios    0 2012-11-19 16:57 modem.log

SMS Module

Learn how to install Opsview Monitor SMS module