zabbix3.4自定义触发器(4)

 

 
 
 
钉钉告警
1.服务端准备脚本
[root@zabbix-server alertscripts]# pwd
/usr/lib/zabbix/alertscripts
 
[root@zabbix-server alertscripts]# cat dingding.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import json
import sys
import os
headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url="https://oapi.dingtalk.com/robot/send?access_token=e88e9b306874d7edd8606a570c6a62770924e59113f9bcab5f90bf9024ba1216"
def msg(text):
    json_text= {
     "msgtype": "text",
     "text": {
         "content": text
     },
     "at": {
         "atMobiles": [
             "186..." #需要@群里谁
         ],
         "isAtAll": True #是否全部@,True为是,False为否
     }
    }
    print requests.post(api_url,json.dumps(json_text),headers=headers).content
if __name__ == '__main__':
    text = sys.argv[1]
 


posted @ 2019-11-16 11:13  地铁昌平线  阅读(206)  评论(0编辑  收藏  举报