Configuring SMS notifications via the monitoring unit in Zabbix

To create such a notification, you need to create a specialized notification type (via an external script):

And make sure that this type is allowed:

Use a special script:
vutlan_sms_send

#!/bin/bash
# Script for sending SMS notifications via GSM-modem
 
HOSTIP=192.168.0.193
USERNAME=guest
PASSWORD=guest
TOPHONE=${1}
MESSAGE=${2}
  
# 1) hash
HASH=`echo -n ${PASSWORD} | openssl dgst -sha1 | awk '{print $NF}'`
# 2) autorisation
RESPONSE=`curl -s -d "querytype=auth&name=${USERNAME}&h=${HASH}" "${HOSTIP}/engine.htm"`
# 3) session key
KEY=`echo -n  ${RESPONSE} | awk -F"\"" '{print $4}'`
# 4) send SMS
curl -d "querytype=send_sms_message&k=${KEY}" --data-urlencode "to_phone=${TOPHONE}" --data-urlencode "message=${MESSAGE}" ${HOSTIP}/engine.htm > /dev/null 2>&1

The input parameters of the script $ {1}, $ {2}, and $ {3} in Zabbix are bound to the address of the recipient, the subject, and the text of the message, respectively.

The script file should be located in accordance with the parameter AlertScriptsPath(for example, /usr/lib/zabbix/alertscripts) in zabbix_server.conf and should have execution permissions for the Zabbix user (or installed in the configuration file)

Please note the escaping of the body symbols of the notification when sent through the MESSAGE variable in the attached script.

Next, add a new notification type for the user:

And set up:

As soon as the new type is added to the user and configured, you must add / modify the action that occurs when the event occurs in Configuration → Actions

In the Action settings, you must specify the name and condition of the occurrence (event filter):

In the Operations tab, you must specify fields for the subject and content of the message, and specify at least one action. The action contains the settings of the destination (user filter) and the settings of generated notifications (filter by notification type)

In this sample, when an incident occurs, a message will be sent to the Zabbix administrators group. To send SMS it is enough to use only one subject field (it will be sent to the script in $ {2}), therefore the event field is empty.

In the Recovery Operations tab, you must specify the fields for the subject, the content of the message, and so on. (Similar to Operations), which will be sent when the incident is fixed.

After creating the action, you need to make sure that the action is allowed.

 

For more detailed information please read: https://www.zabbix.com/documentation/3.2/manual/config/notifications/action