SMS Module - optional module
Learn how to install Opsview Monitor SMS module
The SMS module will not be available for use with 6.0-TP (Technical Preview), but will be included in the 6.0-GA (General Availability) release
Overview
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.
Installation
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 ] - 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' package must be installed first. This needs to be installed on the Opsview Monitor Orchestrator or Collector 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 'opsview' 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 'opsview' 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 | sudo bash -s -- -m
Alternatively, install the opsview-smsgateway
package using your package manger of choice (apt or yum, depending on your operating system). Note, if you install via packages, the daemon will not run correctly until the database has been created.
Configuration
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:
cd /opt/opsview/smsgateway
./installer/postinstall_root.pl
Alternatively, if you wish to install the database remotely please use the postinstall_root.pl command with the following options (Password is optional as the script will generate one if not provided):
./installer/postinstall_root.pl -h $REMOTE_DATABASE_HOSTNAME -P$REMOTE_DATABASE_PORT -p$PASSWORD_FOR_SMSGATEWAY
Secondly, with root privileges, run the following commands from within the /opt/opsview/smsgateway directory) to create the database:
./bin/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:
./bin/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:
./bin/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 (with 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
Testing/Troubleshooting
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 /opt/opsview/smsgateway/var. 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)
This 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:
/opt/opsview/watchdog/bin/opsview-monit stop opsview-smsgateway
/opt/opsview/smsgateway/bin/device_admin test Primary
/opt/opsview/watchdog/bin/opsview-monit start opsview-smsgateway
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 cannot open modem.log
If you see the following error when trying to start opsview-smsqueued:
$ /opt/opsview/watchdog/bin/opsview-monit start opsview-smsgateway
Could not open /opt/opsview/smsgateway/var/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:
$ ls -l /opt/opsview/smsgateway/var
-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 opsview user.
To remedy this delete the modem.log currently owned by root:root, then start the opsview-smsqueued process as the nagios user:
$ rm /opt/opsview/smsgateway/var/modem.log
$ /opt/opsview/watchdog/bin/opsview-monit start opsview-smsgateway
You should then see that the log has been recreated with the correct ownership:
$ ls -l /opt/opsview/smsgateway/var
-rw-r--r-- 1 opsview opsview 0 2012-11-19 16:57 modem.log
Upgrading from Previous Versions
If you are upgrading from a version of Opsview prior to 6.0, the ownership of files and the locations of configuration files has changed so you need to manually copy across any configuration.
|Old Location|New Location|
| --- | --- |
|/etc/opt/opsview/smsgateway/smsqueued.conf|/opt/opsview/smsgateway/etc/smsqueued.conf|
|/etc/opt/opsview/smsgateway/smtp2smsd.conf|/opt/opsview/smsgateway/etc/smtp2smsd.conf|
Also, check that the opsview user has the appropriate group permissions to read the serial devices.
Updated almost 4 years ago