#!/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=e580dbc9d992b790f86136601d95582630afb345ebbf55b373ef5e2fdc92dd6b"
def msg(text):
json_text= {
"msgtype": "text",
"at": {
"atMobiles": [
"all"
],
"isAtAll": False
},
"text": {
"content": text
}
}
print requests.post(api_url,json.dumps(json_text),headers=headers).content
if __name__ == '__main__':
text = sys.argv[1]
msg(text)
指定api_url,需要在釘釘群主中添加機器人,然后將Webhook地址復制過來
如果想指定@某人的話,格式為:
"atMobiles": [
"130xxxxxxxx",
"135xxxxxxxx"
],
其次,在zabbix設置報警媒介時,需要添加這么一個參數
{ALERT.MESSAGE}

