Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

92.2. web ui

http://localhost/zabbix/

user: admin

passwd: zabbix

92.2.1. 警告脚本

下面实现一个通过短信网关发送短信的警告脚本

首先查询 AlertScriptsPath,这是放置脚本的路径

# grep AlertScriptsPath /etc/zabbix/zabbix_server.conf | grep -v ^#
AlertScriptsPath=/usr/lib/zabbix/alertscripts
			
			

创建脚本文件/usr/lib/zabbix/alertscripts/sms.sh

			

vim /usr/lib/zabbix/alertscripts/sms.sh

#!/bin/bash
########################################
# Author:      	Neo Chen <netkiller@msn.com>
# Website:     	http://www.netkiller.cn/
# Description: 	zabbix alert script
# Notes:		https://github.com/oscm/zabbix
# Date:        	2016-11-24
########################################
TIMEOUT=10
MOBILE=$1
MSG="$2 - $3"
########################################
LOGFILE="/tmp/sms.log"
:>"$LOGFILE"
exec 1>"$LOGFILE"
exec 2>&1

CURL="curl -s --connect-timeout ${TIMEOUT}"
URL="http://xxx.xxx.xxx.xxx/sms.php?to=${MOBILE}&msg=${MSG}"

set -x
${CURL} "${URL}"
			
			

测试

# chmod +x /usr/lib/zabbix/alertscripts/sms.sh
# /usr/lib/zabbix/alertscripts/sms.sh 13013668890 Test Helloworld  
			

进入 WEB UI 配置媒体类型,Administration/Media types/Create media type

向脚本传递三个参数

{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}