Zabbix通过腾讯云实现短信告警

1、先申请腾讯云账号

参考:https://jingyan.baidu.com/article/2c8c281d8e768e0008252ae0.html

2、如果选择的是个人认证,在创建签名时可以选择公众号或小程序,若没有公众号则可自行创建

公众号创建参考:https://jingyan.baidu.com/article/f25ef254a6b2bc482c1b82bb.html

3、短信模版申请(注意个人模版单个变量不能超过12个字符)

模版样例:

4、短信告警

参考:

https://cloud.tencent.com/document/product/382/11672

5、准备报警脚本

[root@localhost ~]# more /etc/zabbix/alertscripts/send1.py 
#!/usr/bin/env python
#coding:utf-8
#告警信息
from qcloudsms_py import SmsMultiSender
from qcloudsms_py.httpclient import HTTPError
import sys
import json

appid = xxxxxxxxx
appkey = "xxxxxxxxx"
#告警信息模版ID
template_id = xxxxxx

phone_number = [sys.argv[2]]
msender = SmsMultiSender(appid, appkey)

list1=[sys.argv[1]]

list2=list1.pop()
list4=list2.strip(';').split(';')


params = []
for i in list4:
    j=i.strip(':').split(':',1)
    new_list=j
    params.append(str(j[1]))

try:
    result = msender.send_with_param(86,phone_number,template_id,params)
except HTTPError as e:
    print(e)
except Exception as e:
    print(e)

print result

6、zabbix配置

 

 

猜你喜欢

转载自blog.csdn.net/abel_dwh/article/details/81669371
今日推荐