Monitoring of the Micro-Climate and Sensors of "Dry-Contact" Type Using SMS-Notifications, Sent to Zabbix

  • Published In: Tutorial
  • Created Date: 2017-09-10
  • Hits: 238

Micro-climate monitoring of a server room and sensors of "dry contact" type can be performed for example using UniPing server solution v4/SMS. However, when the power supply is lost or the network fails, the device will not be able to send notifications to Zabbix monitoring system. To solve this problem, it is possible to send SMS notifications from sensors, connected to a UniPing server solution v4/SMS device. These notifications will be sent to NetPing SMS gateway to convert SMS to SNMP TRAP notifications with the following sending them to Zabbix monitoring system.


To implement a described solution, the next equipment will be required:

Operation Principle

The next monitoring principle is used:

  • A device for micro climate monitoring UniPing server solution v4/SMS sends SMS when there are certain issues;
  • This SMS is received by a NetPing SMS gateway that is located in the same segment of a local network with a Zabbix monitoring system;
  • SNMP TRAP is generated by the gateway NetPing SMS in Zabbix in a response to the received SMS notification;
  • Zabbix creates an event when receiving SNMP TRAP

Configuring UniPing server solution v4/SMS (Configuring SMS Notifications)

To configure SMS notificaitons about the change in temperature or humidity, there is a need to install a SIM card into a NetPing micro-climate monitoring device with the installed GSM-gateway (UniPing server solution v4/SMS). Also, there is a need to connect corresponding sensors to a device according to the instruction.

On the tab "SMS" of a device web interface, there is a need to indicate the number, where SMS should be sent. It is possible to indicate up to 4 phone numbers, therefore a notification can be sent to a system administrator in addition to sending it to an SMS gateway.

Configuring numbers for SMS notifications

After entering destination phone numbers, there is a need to click the button "Apply changes".

Now, let us configure SMS notifications when readings from sensors are changed. Let's take a temperature sensor for an example.

Go to the tab "Thermo Sensors".

Contents of the tab THERMO SENSORS

Specify a description of a sensor ("Memo" field) and set the thresholds of a temperature range, when crossing which there is a need to send an SMS notification. After changing the settings, there is a need to click the button "Apply changes".

To configure notifications, click the button "Setup" that is located at the bottom row of the table in a column that corresponds to a sensor.

Configuring notifications for a temperature sensor

Here, check check-boxes for events and an SMS receiver.

When the upper threshold of a normal range is exceeded, a micro-climate monitoring device will send SMS notificaitons to destination numbers, specified on the page "SMS" of a web interface.

The next variants of notifications are available:

  • temperature exceeded the upper threshold of the safe range that is specified on the tab "Thermo Sensors" of a web interface;
  • temperature is back to a safe range;
  • temperature dropped below the lower threshold of the safe range that is specified on the tab "Thermo Sensors" of a web interface;
  • a sensor failed;
  • a periodic report about a status of a sensor (a status, a temperature, if it corresponds to a norm). If sending a periodic report is configured (available for E-mail, SMS and SNMP Trap), then the time of sending a periodic report is specified on tabs "E-MAIL", "SMS" and "Setup".

Configuring SMS Gateway (Configuring sending SMS to SNMP TRAP)

In this section, we will configure an SMS gateway, so that it sends notifications received from UniPing server solution v4/SMS as SNMP TRAP to Zabbix. NetPing SMS will be used as an SMS gateway.

Open the page "SETUP" of a web interface and specify the address for sending SNMP TRAP to Zabbix and SNMP-community.

Configuring SNMP

Configuring Zabbix

Zabbix monitoring system can be deployed on a virtual machine the same as on a dedicated physical server that is connected to a local network or the Internet. If Zabbix works on a remote equipment in the Internet network and a router with the NAT and/or Firewall function is used, there is a need to allow incoming packets via UDP protocol (162 port) to Zabbix – to make it possible to receive SNMP TRAP from outside. The additional information can be found in the documents for a router or obtained from a network administrator. In this article, a simplified scheme will be examined, when a NetPing SMS device and a server with a the Zabbix monitoring system are located in the same local network.

A ready official virtual machine image on the basis of openSUSE 12.3 (x86_64) with a preinstalled Zabbix 2.2.2 system will be used as an example .

To access the system from a console and via ssh, there is a need to use the next default login: root and password: zabbix

Configuring the Firewall

To begin with, there is a need to configure a network packet filter (also known as firewall) embedded in openSUSE to be able to receive SNMP TRAP notificaitons. There is a need to edit the next line in the file /etc/sysconfig/SuSEfirewall2 to add 162 UDP port:


Then, there is a need to run a command to restart the firewall:

# /sbin/SuSEfirewall2

The additional information on configuring the firewall can be found in the document.

Net-SNMP Packet

Then, there is a need to go to configuring the system for receiving and processing incoming SNMP TRAP notifications. To receive and transfer them, Zabbix uses an already preinstalled packet of utilities Net-SNMP and the perl script

If there is no packet of Net-SNMP utilities, it needs to be installed. For the information on installing the additional software, it is recommended to consult a corresponding documentation of a used operating system. The next packets will be necessary:

  • «net-snmp-utils»;
  • «net-snmp-perl»;
  • «net-snmp»


The Perl script that is necessary for sending traps in Zabbix is available on the link in this article or in source codes of Zabbix. To get it, there is a need to download and extract the next archive:

# wget

# tar -zxvf zabbix-2.2.2.tar.gz

When this article was written, Zabbix 2.2 - 2.2.6 was the actual version of Zabbix

Then, copy the script and grant it permissions for execution:

# cp ./zabbix-2.2.1/misc/snmptrap/ /usr/local/bin

# chmod a+x /usr/local/bin/

Daemon snmptrapd and Zabbix trapper

The daemon snmptrapd from the set of utilities Net-SNMP is used to receive incoming SNMP TRAP notifications. Its configuration file /etc/snmp/snmptrapd.conf must look the next:

disableAuthorization yes

perl do "/usr/local/bin/"; 

Then, run the daemon snmptrapd and add it to startup:

# systemctl restart snmptrapd

# chkconfig snmptrapd on

Then, there is a need to activate the option of processing traps in a configuration file of a Zabbix server /etc/zabbix_server.conf:



The path to SNMPTrapperFile must coincide with the one specified in the script On default, it is /tmp/zabbix_traps.tmp

Restart Zabbix:

# systemctl restart zabbix_server

Therefore, when receiving an SNMP TRAP notification, a daemon snmptrapd will pass it for processing to the script, and the script will record data in the file /tmp/zabbix_traps.tmp. The daemon Zabbix constantly checks this file for changes and when the ones appear, it sends the data for processing.

Rotation of zabbix_traps.tmp

The rotation of the file /tmp/zabbix_traps.tmp may be configured when necessary to avoid overfilling of /tmp. To do this, there is a need to create the next directory:

# mkdir -p /var/log/zabbix_traps_archive

And file /etc/logrotate.d/zabbix_traps with the next content: 

/tmp/zabbix_traps.tmp {


    size 10M


    compresscmd /usr/bin/bzip2

    compressoptions -9



    dateformat -%Y%m%d


    maxage 365

    rotate 10


Archive copies of the file /tmp/zabbix_traps.tmp will be moved to the directory /var/log/zabbix_traps_archive when the size of 10 Mb is reached.

Customizing Zabbix Template

To use SNMP TRAP, we need to add support for them in the template (create "Item" and "Trigger"). To do this, create a new template or edit the existing one. It is performed in the configuration of templates (Configuration→Templates).

Creating a Zabbix template

There is a need to go to a new (or previously chosen) template and go to the tab "Items".

Switching to the tab Items

For each notification, there is a need to create a separate object of the Item type and the Trigger type. I will show the configuration on the example of the notification "Temperature is above safe range". Click the button "Create Item".

On the page of the new "Item", specify its name, type (SNMP trap), key, and information type (Log).

The field "key" must contain the text from the notification of the next type (snmptrap["TEXT_SMS"]) or snmptrap.failback, if there is a need to "trigger" at any SNMP TRAP.

Setting up a new Item

For example, when the threshold value is exceeded, UniPing server solution v4/SMS sends SMS with the next contents:

TEMP.SENSOR 5 "Server room" ABOVE SAFE RANGE (20 TO 40C), NOW 42C

Use "ABOVE SAFE RANGE" as a regular expression.

Switching to the tab Trigger

Now, create several triggers on the tab "Triggers" that correspond to these events: "above safe range", "in safe range" and "below safe range".

To do this, go to the tab "Triggers" and click the button "Create Trigger"

Configuring a trigger

In the field "Expression", add the similar text:

{<Template name>:<Item expression>.nodata(300)}=0

This trigger will reset the value to a default one after 300 seconds.

As a result, you are going to get the next set of triggers

An example of a set of triggers

Adding a Host

To add a NetPing SMS device, from which SNMP TRAP notifications will be received, there is a need to go to the section «Configuration» (1), subsection «Hosts» (2) and click the button «Create host»:

Adding a node to Zabbix

Specify a name, a host group and an IP address of a server.

Configuring a new node in Zabbix

Then, go to the tab "Templates" and indicate a template, where we have already added the Item and the Trigger.

At this point, the configuration is completed.

Let's handle the text triggering of a sensor: we will force the top threshold 5 degrees below the current one for UniPing server solution v4/SMS to choose to notify about exceeding the above threshold.

Then, let's set both top and bottom thresholds above the current temperature.

And finally, let's get back everything to normal.

Displaying the last 20 problems

In 5 minutes, the status of events will be changed from "Problem" to "OK", and these events will disappear from the list "last 20 problems".

comments powered by Disqus