Integration with Zabbix

Zabbix is a versatile monitoring tool. The system monitors the dynamics of servers and network equipment, quickly responds to emergency situations and warns of possible problems with the load. Zabbix is able to collect statistics in the specified work environment and act in certain cases in a given way.

 

Advantages of integrating the viber mailing service SMS Club with the Zabbix system

Combining the SMS Club and Zabbix mailing service is a simple and affordable way to notify users via SMS. Integration with the SMS service for business will allow you to:

  • promptly notify users of problems and events;
  • implement mass SMS mailings;
  • create customize your own message templates;
  • set up automatic mailings at a specified time;
  • track the status of notifications at any time;
  • get statistics through simple queries;
  • change alpha name;
  • perform in-depth data analysis.

 

How to connect SMS mailings to Zabbix system

Before integrating the mailing service into viber, check the call string for external ALERT scripts. If the line is not commented out, perform this operation using the path – /etc/zabbix/zabbix_server.conf.

AlertScriptsPath=/usr/lib/zabbix/alertscripts AlertScriptsPath is used by default, but you can specify any directory provided that there is access to the Zabbix system user.

 

In the notification scripts directory, add two script files:

  • smsclub.sh (intercepting data from zabbix and passing it to the SMS sending script);
  • sms_send.php (php script for sending messages via gate.smsclub.mobi).

 

Scripts necessary for integration – look at the end of the article;)

For the service to work correctly, configure the monitoring system on the web interface of the Zabbix server:

Menu Administration —> Notification Method —> Create Notification Method button

 

The system will offer a form that must be filled out as follows:

1. Name - of your choice (in the example - smsclub)
2. Type - script
3. Script name - smsclub.sh (Important! Name = script name)
4. Script parameters (the field is active in version 3) — add the following parameters on a new line each:
{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}
5. Enabled - check the checkbox.

To save the entered data, click Add.

An example of filling out a form:


The next step is to add users to receive notifications. To do this, on the Administration menu, select Users and add a name.
An example of setting up user data (in our case, smsclub).

On the Notifications tab, configure the required type of notifications. Click Add and fill in the fields:

  • Type – smsclub
  • Send – enter your phone number
  • When it is active, set the time that is convenient for you to send SMS, where 1-7 is the day of the week, 00:00-24:00 is the time
  • Use if important — check the checkbox with triggers that are important for executing the SMS distribution script
  • Enabled – check the checkbox.

 

Confirm the entered data with the Add button.


Congratulations! SMS alerts are configured and activated.

 

Overview of viber mailing scripts:

  • smsclub.sh (alpha name must be coordinated with www.smsclub.mobi)

Script code, where SenderID is an example of the alpha name of the sender

#!/bin/bash
to=$1
subject=SenderID
body=$3
/usr/bin/php /usr/lib/zabbix/alertscripts/sms_send.php --to="$to" --body="$body" --subj="$subject";

WARNING: smsclub.sh script – must have permission to execute the file chmod +x /usr/lib/zabbix/alertscripts/smsclub.sh

 

  • sms_send.php (server must have php extension with curl support)
<?php
/**
* This example demonstrates how to send single sms via JSON API
*

* @url smsclub.mobi
* @author SMS CLUB
*/
$arg1 = $argv[1];
$arg2 = $argv[2];
$token = 'My Token';
$url = 'https://im.smsclub.mobi/sms/send';
$data = json_encode([
'phone' => ['Phonenumber'],
'message' => $arg1. " ". $arg2,
'src_addr' => 'Shop Zakaz' // Ваше альфа-имя
]);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $data,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $token,
'Content-Type: application/json'
]
]);
$result = curl_exec($ch);
echo $result;
curl_close($ch);

 

Zabbix implements the script like this:

sms_send.php {ALERT.SUBJECT} {ALERT.MESSAGE}

 

The two arguments provided must be passed in order to send a notification to the field:

'message' => $arg1. " ". $arg2,

 

If you have 3 arguments, edit this line.

Connecting the Viber SMS Club service is easy and fast. If you have any questions, please contact Support SMS Club. Our experts will help you deal with any situation.

IMPORTANT! Full and effective SMS sending requires a working account on the website smsclub.mobi.

 

Details about Zabbix

TOP