一 zabbix 钉钉告警
1 在zabbix服务端,新建告警脚本
find / -name alertscripts
vim /usr/local/zabbix/share/zabbix/alertscripts/dingding.py
#!/usr/bin/env python
#coding:utf-8
import requests,json,sys,os,datetime
webhook="https://oapi.dingtalk.com/robot/send?access_token=fxxx" #说明:这里改为自己创建的机器人的webhook的值
user=sys.argv[1]
text=sys.argv[3]
data={
"msgtype": "text",
"text": {
"content": text
},
"at": {
"atMobiles": [
user
],
"isAtAll": False
}
}
headers = {'Content-Type': 'application/json'}
x=requests.post(url=webhook,data=json.dumps(data),headers=headers)
if os.path.exists("/tmp/dingding.log&