您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
1、邮件报警
使用mutt工具,脚本:
echo "$3" | mutt -s "$2" $1
注:python脚本可参考:http://strongit.github.io/2016/05/01/zabbix-email/
2、短信报警
python脚本调用短信接口:
# -*- coding: utf-8 -*-""" send_sms_notify~~~~~~~~~~~~~~~ 调用短信网关接口发送告警短信。"""import sys import json import requests SMS_GATE_URL = '短信网关接口'def send_sms_notify(to, params): data = {'to': to,'type': 'warn_notify','params': params } headers = {'Content-Type': 'application/json'} requests.post(SMS_GATE_URL, data=json.dumps(data), headers=headers)if __name__ == '__main__':if not len(sys.argv) == 4: print 'Usage: python send_sms_notify.py "phone" "ip" "host" "msg"'sys.exit(-1) to = sys.argv[1] params = {'ip': sys.argv[2],'host': sys.argv[2],'msg': sys.argv[3] } send_sms_notify(to, params)
3、微信报警
git地址:https://github.com/strongit/WeiXin-Private-API php写的,亲测。
python脚本:
import sys import json import urllib2 import requests CorpID = "*******"Secret = "密钥"Access_token_url = "https://**api.weixin.qq.com/*******"req_token = urllib2.Request(Access_token_url) response = urllib2.urlopen(req_token) access_token = json.load(response)['access_token'] post_url = "https://**8api.weixin.qq.com/******"%access_token def send_wechat(msg): data = { "touser": "@all", "toparty": "2", "totag": " ", "msgtype": "text", "agentid": 1, "text": { "content": msg }, "safe":"0"} headers = {'Connection': 'keep-alive','Content-Type': 'application/json; charset=utf-8'} requests.post(post_url,data=json.dumps(data),headers=headers)if __name__ == '__main__':if not len(sys.argv) == 4: print "Usage: python wechat.py 'wechat_id' 'title' 'context'"sys.exit(-1) wechat = sys.argv[1] title = sys.argv[2] msg = sys.argv[3] send_wechat(msg)
4、电话报警
还未用到
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。