Requirements: In the Zabbix server configuration SMS Alarm, when the service failure to reach the alert level is sent by SMS to inform the operator, in order to timely processing.
First, Zabbix server-side configuration SMS Script
My SMS script placement is/etc/zabbix/alertscripts, which must be released in the/etc/zabbix/zabbix_server.conf config file alertscriptspath=/etc/zabbix/ Alertscripts
Enter/etc/zabbix/alertscripts directory, create SMS alarm script sendsms.sh, content into the following:
#!/bin/log file for bash# script logfile="/var/log/zabbix/sms.log":>"$LOGFILE"exec1>"$LOGFILE"exec2>&1Mobile_number=$1# Mobile Number Message_utf8=$3# SMS Content xxd="/usr/bin/xxd"CURL="/usr/bin/curl"TIMEOUT=5# SMS content to be URL-encoded processing, in addition to the following method, you can also use Curl--data-The urlencode option is implemented. Message_encode=$ (Echo"$MESSAGE _utf8"| ${XXD}-ps | Sed's/\ (.. \)/%\1/g'| Tr-d'\ n') # SMS API interface username and secret key account="jinrgcxxx"PASS="Jinr1234xxxooxx"URL="Http://222.73.117.158/msg/httpbatchsendsm?account=${account}&pswd=${pass}&mobile=${mobile_number} &msg=${message_encode}&needstatus=true"# Send ItSet-X${curl}-S--connect-timeout ${timeout}"${url}"
Then execute the following command to set the script and log file permissions:
touch/tmp//tmp//etc/zabbix/alertscripts/+x/etc/zabbix/alertscripts/sendsms.sh
Manual test Script:
"" " Dear customer, your order has been shipped out of the library, is in the delivery, please be patient. "
The first parameter of the script is the mobile number, the second parameter is not used, the line is empty, and the third parameter is the text message content.
After the script executes, the return value is viewed into the log file/tmp/sms.log, and if the greater than 0 represents a successful send, less than 0 send fails.
second, in the Zabbix Web interface Configuration alarm mode (Media types)
Reference Document: http://www.sxt.cn/u/756/blog/3198
ZABBIX3 Configuring SMS Alarms