Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

16.2. web ui

http://localhost/zabbix/

user: admin

passwd: zabbix

16.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}