Hardware SMS Gateway for OpenNMS

  • Published In: Tutorial
  • Created Date: 2018-12-19
  • Hits: 3205

Logically, this article is a continuation of the article "Example of Monitoring a Server Room on a Basis of OpenNMS and NetPing Devices". Within this article, a feature of configuring SMS notifications from OpenNMS using NetPing SMS (SMS gateway for OpenNMS) will be regarded. 

When network engineers and administrators work, they often need to receive notifications in any time seven days a week. What communication means can be more suitable for this than SMS? Using external SMS services critically depends on the Internet connection, but what to do if there is a need to receive notifications about Internet connection failure? USB GSM modems could solve this issue but their operation stability and often level of support are not the best. There are very few modems that can boast working 24/7 without external maintenance (manual checking, scripts or other means). In addition, it must be connected to a server or a PC for operation. In turn, this server or PC will work as an SMS gateway, which is not the simplest and not the most reliable scheme. A proper solution in this situation would be the use of NetPing SMS. It is a standalone device that is connected to the Ethernet network and working as an SMS gateway for any monitoring system, service, or any other system. In addition, it has no disadvantages described above because it works independently as it does not need an Internet connection and a computer for the operation, and the 24/7 operation is implied.

This article suggests that you have already installed and configured the OpenNMS monitoring system and it works correctly. A configuring process of Open NMS monitoring system has been described before.

Configuring NetPing SMS Gateway for the Operation with the Monitoring System OpenNMS

The first and the most important step of the configuration is a network configuration and access restriction configuration, which is also minimally sufficient. To do this, go to the page "SETUP" (1) of a web-interface:

Network configuration (2):

  • IP address of a device - 192.168.0.218 (according to a network configuration);
  • Subnet mask - 255.255.255.0 (according to a network configuration);
  • Gateway - 192.168.0.1 (according to a network configuration, but not obligatory when OpenNMS and NetPing SMS are in the same subnet, in this case, they do not need a gateway);
  • DNS server - 8.8.8.8 (DNS is not needed for this solution as soon as a device will not address external services);
  • HTTP server port - 80 (on default, the script uses URL-encoded commands in this solution when it addresses a web server of a device);
  • SNMP agent port - 161 (on default)

Access Restriction (3):

  • Username - visor (on default, the script will address a device using a pair login/password of a web interface);
  • Password - ping (on default, the script will address a device using a pair login/password of a web interface);
  • Community read and write - SWITCH (on default, it is irrelevant for this solution);
  • IP access filter and IP access subnet - 192.168.0.49, 255.255.255.255 (it is highly recommended to configure it for specific needs with the aim to restrict access of the third-party individuals to sending SMS notifications);

More detailed information about a basic configuration is given in the official documentation.

Configuring NetPing SMS

In addition, for proper operation of a built-in GSM modem for sending SMS notifications, make sure that the antenna is plugged to NetPing SMS and a signal strength is acceptable (a signal strength 50% and lower is highly undesirable). TO check the signal strength, there is a need to go to the page "GSM SETUP" (1), click the button "Request Status" (2) in the section "GSM Status", and in some time, a current signal strength will appear (3).

Configuring NetPing SMS

Adding a Notification Method Using NetPing SMS Gateway to the OpenNMS Monitoring System

To configure SMS notifications from OpenNMS through the NetPing SMS gateway, the first thing to do is to indicate how the monitoring system will communicate with the gateway. To do this, there is a need to add a notification method, using which OpenNMS will call an independent script and send parameters to it. Let's start with the script:

Create a file in the location that is convenient for you, for example:

touch /etc/opennms/scripts/sendsms.sh

Make it executable:

chmod +x /etc/opennms/scripts/sendsms.sh

And insert the next content:

#!/bin/bash

curl --user visor:ping --data "[$1] $2" http://192.168.0.218/sendsms.cgi?utf8

The script uses the feature of sending SMS notifications using URL-encoded commands. More information about the methods of sending SMS can be read in the documentation.

When writing own script, it is important to keep the order of input variables: a first variable is a phone number, the second one is the text. This is the exact order of sending arguments to the script that is used in the notification method described below.

And, let's install a package that is necessary for the operation:

apt-get install curl

Then, there is a need to add a notification method. To do this, add the next section in the end of the file /etc/opennms/notificationCommands.xml:

<command binary="true">

   <name>SendSMS</name>

   <execute>/etc/opennms/scripts/sendsms.sh</execute>

   <comment>Send sms</comment>

   <argument streamed="false">

      <switch>-wphone</switch>

   </argument>

   <argument streamed="false">

      <switch>-tm</switch>

   </argument>

</command>

When calling this notification method, the system substitute variables in order as follows: "-wphone" (phone number that is indicated in user settings in contacts as a work phone) and "-tm" (text from the field "Text Message" of the notification parameter that will be discussed in more detailed below,for inserting the text  "Short Message" use "-nm"). More information about commands and parameters can be found in the official documentation.

And, let's associate this command with a delivery way. To do this, add the next section to the file /etc/opennms/destinationPaths.xml:

<path name="SMS-Admin">

   <target>

      <name>Admin</name>

      <command>SendSMS</command>

   </target>

</path>

More information about configuring notifications for OpenNMS is described in the official documentation. At this point, the work in the console is over, and it is possible to switch to a web interface.

Examples of Configuring Notifications on Certain Events in OpenNMS Using NetPing SMS Gateway

To configure SMS notifications for certain events, there is a need to go to the administering interface of OpenNMS. To do this, go to Configure OpenNMS (1) → Configure Notifications (2):

OpenNMS configuring notifications

Then to Configure Event Notifications:

OpenNMS configuring events for notifications

And see the next view:

OpenNMS event list for notifications

Example 1. SMS notification on receiving SNMP TRAP notification about changing a logic level of an IO line on the example of UniPing server solution v3/SMS

To add a new notification about the event, click "Add New Event Notification":

OpenNMS adding an event for notification

Then, there is a need to choose the event. 

In the article "Example of Monitoring a Server Room on a Basis of OpenNMS and NetPing Devices", during importing the MIB file, a system offered us to create a list of events on the basis of this file. This list contained a configuration of all SNMP TRAP notifications described in the MIB file. The event file was named after the MIB file, and located at the next path /etc/opennms/events/DKSF-70-6-X-X-1.events.xml (default name; if you changed the name when creating the default event configuration, it influenced UEI only; more information on the configuration file structure can be found in the official documentation).

For your conveniency, let's use the search option (1). Among the events that are found, select the incoming SNMP TRAP on IO line (2) and move next (3).

OpenNMS configuring notifications via SNMP Trap IO line

The next configuration menu item offers to set a node (host) filter for processing events. Within this article, we will not discuss this, and leave this on default (process from everything) and move next. If there is a need to do a fine tuning, it is better to address the official documentation.

OpenNMS node filter for notifications about receiving SNMP Trap IO line

Now we see main notification parameters as follows:

  1. Enter a notification name - npIoTrap notification;
  2. Its description - Io Trap from NetPing;
  3. Notification path that was added by us before, in the console - SMS-Admin;
  4. Specify the notification text (supports inserting values from the event that triggered this notification);
  5. Memo on possible values;
  6. Finish - complete configuration.

OpenNMS details of notification about SNMP Trap IO line

Then, we get back to the list of all notifications. Our newly created one is among them too.

OpenNMS event list for notifications

Example 2. SMS notification on the unavailability of any service of any node

In the default notification list, there is already a notification on the event "nodeLostService", therefore there is no need to create a new one. Let's edit the existing one. To do this, click "Edit".

OpenNMS editing an event

We will see steps for choosing the event and a filter, we skip the step, leaving everything as it is, and go to the notification parameters at once. Select a notification path "SMS-Admin" (1) - and complete the configuration (2).

OpenNMS changing notification method about an event

At this point, SMS notificaitons are configured. When specified events take place (in addition, restoring the service operation from the example № 2), we will receive the notifications of the next view:

Incoming SMS messages from OpenNMS via NetPing SMS

NetPing SMS is not the only device that can work as an SMS gateway for the monitoring systems. Using UniPing server solution v4/SMS and NetPing 8/PWR-220 v4/SMS, it is also possible to send notifications using external scripts. More information about this can be read in the documentation for UniPing server solution v4/SMS and NetPing 8/PWR-220 v4/SMS.

Conclusion

For a full-fledged monitoring of crucial systems, it is vitally important to use all available notification methods for accidents. SMS notifications are one of the priorities because they are not dependent on the infrastructure status of the enterprise, and mobile phones have become an integral part of the daily life long ago, and are at hand even during off hours, which allows receiving notifications instantly and act correspondingly.


comments powered by Disqus