Zabbix is a free monitoring system for tracking statuses of various services of a computer network, servers and network equipment. This system has got a possibility to adjust different ways to notify a user: e-mail, SMS, Jabber, Ez Texting, user scripts. These ways to notify a user are delivery channels in use to send notifications and alerts from Zabbix. According to the fact that Zabbix supports user scripts, it is possible to use devices NetPing SMS, UniPing server solution v4/SMS or NetPing 8/PWR-220 v4/SMS as an SMS gateway to send SMS notifications about events in the monitoring system Zabbix as one of the notification methods. As a result, organising this method of SMS notifications can significantly save funds due to using alternate services for sending SMS notifications, available on the Internet.
Requirements
To implement a functionality described above, there is a need to have the following:
- a gateway for sending and receiving SMS commands UniPing server solution v4/SMS with an inserted SIM card, or a device for remote controlling power supply sockets NetPing 8/PWR-220 v4/SMS with an installed SIM card;
- a prepared script for sending random SMS notifications about the events in the monitoring system Zabbix;
- a configured monitoring system Zabbix (in this example Zabbix is
installed at the OS CentOS 6.5);
To get an information about configuring a monitoring system Zabbix, kindly see the official documentation
To send SMS notifications as an example (i.e. using the devices NetPing SMS, UniPing server solution v4/SMS or NetPing 8/PWR-220 v4/SMS that are used as an SMS gateway), there is a need to perform only a part of a basic configuration (configure network parameters for accessing the network) of the devices NetPing SMS, UniPing server solution v4/SMS or NetPing 8/PWR-220 v4/SMS and install the working SIM card with a positive balance to a slot of a built-in GSM modem. It is possible to read about a basic and auxiliary configuration of devices in the next documentation:
- NetPing SMS - DKSF 707.3 IU firmware description;
- UniPing server solution v4/SMS - DKSF 71.6 IU firmware description;
- NetPing 8/PWR-220 v4/SMS - DKSF 48.4 IU firmware description
Implementing Sending SMS Notifications from the Zabbix Monitoring System of the Version 2.2
Configuring Zabbix 2.2 Server
To have a possibility to use user scripts, there is a need to implement a light configuration of a Zabbix server. Doing a light configuration means to specify a parameter «AlertScriptsPath» in a configuration file «/etc/zabbix/zabbix_server.conf». This parameter determines a directory, where a script for SMS notifications will be saved.
To edit a configuration file, there is a need to go to a directory with a file and open it in a text editor:
Add a directory for a parameter «AlertScriptsPath»:
After a parameter is changed, save the settings in the configuration file and restart the service «services-zabbix» (a service is restarted by the user root):
The script for sending SMS notification needs to be placed into the directory specified in the parameter «AlertScriptsPath», and permissions must be defined to perform the script (permissions are specified by the user root):
Ready script file can be downloaded from here: sendsms.sh
Parameters that are necessary to be changed when using a script in the own monitoring system Zabbix:
visor29 – is a user name for authorisation on
a NetPing device.ping29 – is a password for authorisation on
a NetPing device.
192.168.0.29 – is a current IP
address of a NetPing device.
Configuring SMS Notifications in a Web Interface of Zabbix 2.2
Get authorized as an administrator into a web interface of the monitoring system Zabbix.
There is a need to create a new notification method to implement sending SMS notifications. To do that, go to the tab «Administration», select the menu item «Media types» and click the button «Create media type»:
In the window for setting a new notification method indicate parameters similar to represented ones at the screenshot below and save them by clicking the button «Save»:
Name is a name for a notification method.
Type is a type of a notification method. The next types are available: «Email», «Script», «SMS», «Jabber», «Ez Texting». There is a need to choose a type «Script».
Script name is a name for a script file to send SMS notifications, which is located by the path: «/usr/lib/zabbix/alertscripts».
Enabled is a check-box for activating this notification method.
After creating a new notification method «Sendsms», it will appear in the table of all configured notifications in Zabbix:
Now a user or a group of users in Zabbix needs to link a created notification method. In the example below you will see a process of configuring for a user Admin. To do this, go to the tab «Administration», select a menu item «Users» and click a link «Users» in a row of a group of Zabbix administrators in the table «User groups»:
Choose a user Admin in a group «Zabbix administrators»:
Go to the tab «Media» and click the button «Add» to link a new notification method:
In the window «New media» fill in parameters similar to the ones shown in the screenshot below and save them by clicking the button «Save»
where:
Type is a parameter for choosing notification
methods, created before in the monitoring system Zabbix (a tab «Administration», a menu
item «Media types»). As an example, select «Sendsms».
Send to is a phone number for sending SMS notifications.When
active is time for triggering a notification method.Use
if severity is an importance of a trigger. Checkboxes
determine, for which importance of a trigger the notification will
work. In the example, all
checkboxes are checked for a better visualisation of the parameter.
Status is a parameter for enabling or
disabling a notification.
In the window for setting parameters of a user Admin, a created notification for sending SMS notifications «Sendsms» will appear at the tab «Media». Afterwards, there is a need to click the button «Save» to save all settings:
Now there is a need to configure an action, as a result of which, an SMS notification will be sent to an administrator of the monitoring system Zabbix. Let's suppose that an administrator needs to receive an SMS notification about an availability of the device for remote controlling a power supply NetPing 2/PWR-220 v4/SMS. I.e. when a device stops responding to ICMP requests, an SMS notification is sent about this device being unavailable. When a device starts responding to ICMP requests, an SMS notification is sent again indicating this device being available now.
To implement such algorithm of SMS notifications, there is a need to go to the tab «Configurations», select a menu item «Actions» and click the button «Create action» to create a necessary action, which will implement sending SMS notifications:
In the configuration window for actions, fill in parameters similar to the ones indicated at the screenshot below:
where:
Name is a unique name of the action.
Default subject is a default subject of a
message. A subject can contain macros.
It is not used in the SMS notification.
Default message is a default message. A
message can contain macros.
Recovery message if a checkbox is
checked, Zabbix will send a notification about recovery
when the issue is solved. Notifications will be sent only to
those ones, who received some messages about the issue before.
Recovery subject is
a subject of a notification on default recovery. A subject can
contain macros.
It is not used in this SMS notification.
Recovery message is a message about
recovery. A message can contain macros.
Enabled is
a checkbox for enabling the action.
Therefore,
this action will be sending SMS notifications with the
text «{HOSTNAME}:
ping is {STATUS}»,
when a device NetPing
2/PWR-220 v2/SMS is lost and then becomes available
again.
where:
{HOSTNAME} is a unique name of a device
in Zabbix.
{STATUS} is a current status of a device
in Zabbix.
Now there is a need to specify a condition, within which an action will be triggered. Conditions are specified at the tab «Conditions». On default, a system already has two conditions: «А» and «В». For an example, let's add a condition «С», which determines a specific node in the network. If unavailable, SMS notifications will be sent. To do this, choose a parameter «Host», condition «=» from a dropdown list in a row «New condition» and enter a unique name of a device «NetPing 2PWR-220v2SMS», added to Zabbix (a device NetPing 2/PWR-220 v2/SMS was previously added into Zabbix and configured to check availability via a network). Afterwards click the link «Аdd»:
As a result of the configuration, the third condition «С» will appear:
The last step of the configuration is to choose a notification method for this action. A notification method is configured at the tab «Operations» when clicking the link «New»:
In the window, represented at the screenshot below, choose a notification method «Sendsms» from a dropdown menu «Send only to». Afterwards click the button «Save» to save configuration:
At the tab «Operations» the operation «Send message to users: Admin (Zabbix Administrator) via Sendsms» will appear, which initiates starting a script for sending SMS notifications for a configured action. It is necessary to save all settings for the action «Ping_status» by clicking the button «Save»:
Eventually, a created action «Ping_status» will appear at the page «Actions» with a status «Enabled», which will initiate sending SMS notifications when necessary conditions are fulfilled:
Implementing Sending SMS Notifications from the Zabbix Monitoring System of the Version 3.4
In August 2017, a new version of Zabbix, 3.4, was issued. The new version is somewhat different from Zabbix of the version 2.2. Let's examine a configuration of sending SMS notifications from new version of Zabbix. In our example, we use Zabbix of the version 3.4.8 that is installed on CentOS Linux release 7.4.1708 (Core).
Configuring a Zabbix 3.4 Server
The first step of a configuration is preparing a Zabbix server. There is a need to locate script for sending SMS notifications on a server. The script can be downloaded here and located in the directory /usr/lib/zabbix/alertscripts/ or created manually. Let's create a script file using the next command:
mcedit /usr/lib/zabbix/alertscripts/sendsms.sh
And write the text of a script for sending SMS on a script language Bash:
#!/bin/bash
curl --user visor:ping --data "[$1] $3" http://192.168.1.204/sendsms.cgi?utf8
where:
visor – is a username for authorization on
a NetPing device.
ping – is a password for authorization on
a NetPing device.
192.168.1.204 – is a current IP address of
a NetPing device.
[$1] – is a variable to which a destination
phone number for a notification is sent. Square brackets are a
must!
$3 – is a variable to which a text of an SMS
notification is sent.
Save and make a file executable using the next command:
Now, edit a configuration file of a Zabbix server:
In a configuration file of a Zabbix server, the next parameter must be uncommented/specified:
After changing a configuration of a Zabbix server, it must be restarted to apply these changes. To do this, execute the next command:
Configuring SMS Notifications in a Web Interface of Zabbix 3.4
Then, let's go to a web interface of a Zabbix server and continue configuring. In a web interface of Zabbix, let's create a new notification type (Administration → Media Types) with the next parameters:
where:
Name – is a name of a notification
type. In our example, the name is «NetPing SMS»;Type – is a notification type. The
next types are available: «Email», «Script», «SMS», «Jabber», «Ez
Texting». It is
necessary to choose a type «Script»;
Script name –
is a name of a script file for sending SMS notifications
that is located on the next path: «/usr/lib/zabbix/alertscripts». In our example, it is
«sendsms.sh»;
Script parameters – is
script parameters, i.e. specify parameters the same as
in the example. A parameter {ALERT.SENDTO}
is sent to a variable $1 of the script sendsms.sh. A parameter
{ALERT.MESSAGE} is sent to a variable $3 of the script sendsms.sh;
Enabled – is a checkbox for
activating this notification type.
Then, continue to the settings of a user Admin (Administration → Users) and add a new notification type on the tab «Media». Click the link «Add», and in a pop-up window «Media» that appears, specify the parameters as in the example below:
where:
Type –
is a parameter for choosing a notification type, created before
in a Zabbix monitoring system (Administration → Media
Types). In our case, we select a notification type from the list
- a notification type «NetPing SMS»;.
Send to –
is a destination number to which SMS notifications will be
sent. A destination number is specified in the international
format, starting from «+7»;When active – is a time of triggering of
this notification. A configuration can be left default;Use if severity – is an significance of a
trigger, checkboxes determine at which significance of a
trigger this notification will operate. In the example, all
checkboxes are checked for increasing a visuality of the
parameter.
Enabled – is a parameter for enabling
and disabling this notification.
Save the changes by clicking the buttons «Add» and «Update».
Then we go to creating the action which execution triggers sending our SMS notifications. In the article we will examine sending SMS notifications when changing a logic level of an IO line at NetPing devices, connected to the monitoring. It is possible to plug any sensors of a dry contact type to IO lines of NetPing devices in the «input» mode:
Go to the section «Configuration → Action» and click the button «Create Action»:
In a window that opens, on the «Action» tab, fill in the fields as in our example. Here, we need to sort out triggers that will cause sending SMS notifications when operating.
where:
Name –
is a unique name of the action. In out example it is
«IO_line_status»;
Type of calculation – is a type of a
logic rule for triggers.
In our example, «Or»
(logic OR), the action is executed when
one of triggers operated;Conditions –
are conditions, within which the action will be triggered.
Names of triggers that will cause sending SMS notification
when operating must contain phrases «Level:FRONT» and «Level:DECAY»;
New condition – is a field for
creating a new action. Adding rules is confirmed by clicking
the link «Add» in the field «New condition»;
Enabled –
is a parameter for switching on and switching off the
action.
Then, go to the tab «Operations» and specify the text of an SMS notification that will be sent when a trigger that is described at the tab «Action» operates.
where:
Default operation step duration – is a duration of a one
step of the operation. For
example, a step duration of one hour means that if the
first operation in this action is executed, then the
next operation will be started in an hour.
In our example, the operation of sending a notification
is the only one, therefore it is possible to leave a
default value.
Default
subject – is a default subject. A subject
cannot contain macros.
In this SMS notification it is not used.
Default message – is a default message.
A message can contain macros. In
this field, we write a text of an SMS notification that
will be received by the administrator of a monitoring system
when a logic level is changed on the IO lines of a NetPing device.
In the field «Operations», we click the link «New», and fill in an opened form of an action description as in our example. Add a user «Admin» in the field «Sent to Users». In the field «Send only to», choose a notification type «NetPing SMS» from the list. Confirm the changes by clicking the link «Add» (1):
Confirm creating a new action by clicking the button «Add» (2).
Now, when a logic level of an IO line of a NetPing device that is connected to the monitoring system is changed, Zabbix, network administrator, will receive such SMS notifications:
On the screenshot below, you can see a common view of a Dashboard with executed triggers for changing a logic level of IO lines. In the table «Actions», we may see it because the action is connected to trigger, and the action was successfully executed.
In this article, the simplest examples of configuring notifications are shown. Zabbix monitoring helps to configure complex solutions with complicated conditions of triggering actions. More detailed information about this can be read in the official Zabbix documentation.