https://oapi.dingtalk.com/robot/send?access_token=02f6ba03e133beb0e62499a6e7550b64f03a1120e47c4922a2db80f981834697
cd /usr/lib/zabbix/alertscripts
cat dingding.py
---------------------------------------------------------------------------------------------
import sys,requests
import os,json
def send_msg(url, remiders, msg):
headers = {'Content-Type': 'application/json; charset=utf-8'}
data = {
"msgtype": "text",
"at": {
"atMobiles": remiders,
"isAtAll": False,
},
"text": {
"content": msg,
}
}
r = requests.post(url, data=json.dumps(data), headers=headers)
return r.text
if __name__ == '__main__':
msg = sys.argv[1]
remiders = []
#url = '钉钉地址'
print(send_msg(url, remiders, msg))
----------------------------------------------------------------------------------------------------------------------------