需要添加这么一个参数

图片 1
#!/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}

图片 1