SMS Notifications

From OpenNMS
Jump to: navigation, search

Creating SMS Notifications with a GSM Modem

This system is based on OpenNMS 1.3.5, though I believe should work with any version of 1.3.*. We had it installed on Suse 10.2, though again the underlying operating system shouldn't matter. A nice thing about the components we use is that it allows us to use SMS messages to acknowledge notifications sent from the OpenNMS system by setting it up to process incoming SMS messages.

The components used are as follows:


  • Siemens MC35i GSM Modem stater kit

This is a GSM/GPRS dual band modem for Europe so it'd be GSM-900 and GSM-1800

  • SIM Card from a provider


  • Stefan Frings SMS Server Tools

This software package is available at SMS Server Tools, where he also has some very easy to follow simple tutorials on how to compile, install, setup and run the sms daemon.


SMS Server Tools

I'll assume that you followed the guides on the SMS Server Tools website for compiling and installing the software. Our configuration file /etc/smsd.conf is as follows:

devices = GSM1
logfile = /var/log/smsd.log
loglevel = 7
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
stats = /var/smstools/stats
stats_interval = 3600
eventhandler = /usr/local/sbin/smsevent

device = /dev/ttyS0
incoming = yes
memory_start = 1
mode = new
baudrate = 19200
rtscts = yes
report = no
#pin = 1111

As you can see, you can have multiple GSM modems. We are only using one. All the necessary queues are in /var/spool/sms/ and we have a script at /usr/local/sbin/smsevent which the eventhandler calls whenever the modem receives an incoming SMS message for the sms daemon to process, detailed below.

The modem interface is RS-232, so some fields in the configuration contained in the section [GSM1] contains values for communicating with it. The device=/dev/ttyS0 and even the baudrate=19200 may differ depending on the Operating System and hardware of your server, and whether you use RS-232 or USB.

We accept incoming messages with incoming=yes and as we did not have our SIM card PIN protected we have commented out the field 'pin'.

Start the sms daemon and test sending an SMS message using the instructions on the SMS Server Tool's site.


Here's what we need to configure in the OpenNMS file notificationCommands.xml:

<command binary="true">
      <comment>Class for sending GSM SMS notifications</comment>
      <argument streamed="false">
      <argument streamed="false">

We are using the numerical pin field in the User Accounts file $OPENNMS_HOME/etc/users.xml to store the mobile number and the text message field in $OPENNMS_HOME/etc/notifications.xml for the notification details.

The program /usr/local/bin/sendsms takes a mobile number and message body on the commandline as parameters, i.e. sendsms <mobile#> "text message", so this is all you need.

Next is just an example of how we use the smsgw class we set up in notificationCommands.xml in the destinationPaths.xml file

<path name="SMS-L1" initial-delay="1s">
        <target interval="0s">
            <name xmlns="">l1-support</name>
            <autoNotify xmlns="">auto</autoNotify>
            <command xmlns="">javaEmail</command>
        <escalate delay="30s">
            <target interval="0m">
                <name xmlns="">DaySupportDesk</name>
                <autoNotify xmlns="">auto</autoNotify>
                <command xmlns="">smsgw</command>
        <escalate delay="5m">
            <target interval="0m">
                <name xmlns="">NightSupportDesk</name>
                <autoNotify xmlns="">auto</autoNotify>
                <command xmlns="">smsgw</command>

Nice Tricks

We also can send back sms messages with the notification id as the message body to acknowledge notifications and stop any escalations. This is a bash script referenced under the eventhandler attribute in smsd.conf above. In our case at /usr/local/sbin/smsevent

# This section is for OpenNMS SMS Notification Acknowledgements

if [ "$1" = "RECEIVED" ]; then
        mobileNum=`head -n 1 $2 | awk '{print $2}'`
        notifyId=`tail -n 1 $2 | awk '{print $1}'`
        sudo -u postgres psql -U opennms -c "update notifications set
respondtime=now(),answeredby=$mobileNum where notifyid=$notifyId;"

We're taking any SMS that has being received and extracting two data fields from it. The sending mobile number and the notification id. We're then running an sql statement to update the relevent notifications row with a timestamp (as this sets the notification to acknowledged) in respondtime, and answered by as the senders mobile for record purposes.

Just to give the above script a bit more meaning, the following is and example of the contents of a message file in the incoming queue in SMS Server Tools. (I've hidden the sending mobile number).

From_SMSC: 353876xxxxxx
Sent: 07-11-08 12:33:29
Received: 07-11-08 12:34:32
Subject: GSM1
Alphabet: ISO
UDH: false


What else would be nice?

  • I'd like a phone that's a bit easier to extract a number from an SMS message to reply with that number as the text body. The older Nokias used to be able to do that, but with the latest one's it's a gymnastic feat. Any suggestions welcome?
  • I would like it if my script could parse the users.xml file and extract the users name from the xml based on the mobile number, to populate the answered by field in the notifications table, but I'm afraid I not yet up to the task. I was messing around with Java and Xerces. Does anyone have an idea for this?

Creating SMS Notifications with a SMSEagle

Here we describe how to setup OpenNMS with SMSEagle for sms notifications.

SMSEagle Setup

  • Create a new user for this script in OpenNMS.

OpenNMS Setup

  • Create a User

Click the Admin link in the menu bar, go to Configure Users, Groups and On-Call Roles, and then click Configure Users. Then, click the Add New User link, and enter a username and password in the form, then click OK. Next, fill out the relevant user information. Finally, click Finish down at the bottom of the form.


  • Destination Paths

To receive a notification, your user or a group that your user is in needs to be a part of a destination path. A destination path helps OpenNMS determine who is eligible to receive a particular notification, depending on user name, groups, duty schedules, and other rules. Go to the Admin page, click Configure Notifications in the Operations section, then Configure Destination Paths, then click the New Path button. Give it a name, like SMS, then click Edit. Add your new user by selecting it, then click Next >>>.


On the next page, leave the defaults (javaEmail and on) and click Next >>> again. Finally, click Finish and you should see your new tutorial path in the Existing Paths section.

  • Event Notifications

Go to the Admin page, click Configure Notifications in the Operations section, then Configure Event Notifications. In here you 'll see a list of events which are configured for notifications, some of which are turned off. You can create a new event notification by clicking the Add New Event Notification> button near the top. Click the Add New Event Notification button at the top of the Event Notifications page. From Events choose OpenNMS-defined internal event: an authentication failure has occurred in WebUI.


Then click Next >>>.

On the next page, you can build a rule for matching a set of IP addresses and/or services. In this case, we're just matching an internal OpenNMS event, so we'll continue on and click Skip results validation >>>. Finally, you can configure the information used to send the notification. Fill in the following values:

Name authenticationFailed

Choose A Path Tutorial

Text Message The OpenNMS Web UI had a failed login attempt, by user '%parm[user]%', from IP address %parm[ip]% (Exception message: %parm[exceptionMessage]%)

Short Message Authentication failed by user %parm[user]% (Notice #%noticeid%)

Email Subject Authentication Failed (Notice #%noticeid%)

And then click Finish.

You should now see your notification event in the list, but it will be disabled. Set the radio button to On to enable it, and you should be ready to send a notification.


  • Configure Email

Unless you have an SMTP server running on your OpenNMS host, you will need to configure mail before notifications will work. Mail configuration for notifications is in the $OPENNMS_HOME/etc/ file. In most cases, you should only have to change a few lines to point it at your mail server:

# This is the e-mail address that OpenNMS puts in the "From" field:

Also, if your mail server requires authentication for sending, see the section under "These properties define the Mail authentication." and edit them as appropriate for your environment.

  • Enable Notifications

By default, OpenNMS ships with notifications disabled, so you don't get them accidentally as you're just setting things up. The last thing you need to do once you have things configured as you like is to enable notifications. In the main OpenNMS Admin page, there is a radio selector labeled, Notification Status. Change it to On and click update.


SMSEagle as SMTP Server (optional)

For sending e-mail messages you can use SMTP server installed on the SMSEagle device. Then the configuration of SMTP server is as follows:
SMTP host: IP address of your device
SMTP port: 25
Authentication: SMSEagle SMTP server doesn't require authentication
Encryption: none
SMTP server on the SMSEagle device will accept messages addressed for it only. The other messages will be rejected.