Send an SMS with OpenNMS

I thought I’d written this post years ago, but apparently I didn’t. Since my friend Salma asked about SMS notifications with OpenNMS I felt it was a good opportunity to document this process.

Of course, OpenNMS can’t send an SMS message without a little help. You’ll need some sort of modem that can actually connect to the network. We use one from the great folks at MultiTech.

Multitech Modem

It’s USB powered, so all you need to do is insert an active SIM card and plug it in. Here is the exact model:

Multitech Modem Back

and you can find more information on their products on their website.

For the SIM card, I just added a phone to my AT&T plan for a few dollars a month.

The next thing you’ll need is software to send the notices. I used smssend, which comes in RHEL/CentOS via the smstools package:

Name        : smstools
Arch        : x86_64
Version     : 3.1.15
Release     : 12.el7
Size        : 748 k
Repo        : installed
From repo   : epel
Summary     : Tools to send and receive short messages through GSM modems or mobile phones
URL         : http://smstools3.kekekasvi.com
License     : GPLv2+
Description : The SMS Server Tools are made to send and receive short messages through
            : GSM modems. It supports easy file interfaces and it can run external
            : programs for automatic actions.

This will install a daemon called smsd that is configured via /etc/smsd.conf. You’ll need to edit that file to set the path to your modem, in my case it’s /dev/ttyUSB0. Then start the daemon (via “service” or “systemctl”, etc.)

At this point you can test if it works by running:

smssend [number] "This is a test message"

Note that the number must include the country code, such as “+19195330160”.

Once you have that working, it is pretty easy to set up in OpenNMS. First, edit notificationCommands.xml and add the “smssend” command:

    <command binary="true">
        <name>sendSMS</name>
        <execute>/usr/bin/smssend</execute>
        <comment>Send an SMS</comment>
        <contact-type>mobilePhone</contact-type>
        <argument streamed="false">
            <switch>-mphone</switch>
        </argument>
        <argument streamed="true">
            <switch>-nm</switch>
        </argument>
    </command>

This configuration includes the full path to the “smssend” command, and I used the mobile phone “-mphone” field as well as the short message “-nm” field, which are the only two parameters required for the command.

At this point you’ll need to restart OpenNMS. It actually isn’t necessary to make this work, but it is needed to make the webUI know that the “sendSMS” command has been added.

The rest of the configuration can be done through the webUI. For every user you want to receive SMS messages, make sure that their mobile number (including country code) is configured on their user account page. Then you can just add “sendSMS” as a notification action on a destination path and it should just work.

2 thoughts on “Send an SMS with OpenNMS

Comments are closed.