1 Star 0 Fork 0

罗兴/zabbix-报警介质

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dingding.py 2.16 KB
一键复制 编辑 原始数据 按行查看 历史
罗兴 提交于 2023-08-19 08:10 . Initial commit
#!/usr/bin/python3
# _*_coding:utf-8 _*_
import json
import requests
import sys
def send_msg(url, msg):
headers = {'Content-Type': 'application/json; charset=utf-8'}
data = {
"at": {
"isAtAll": "true",
"atUserIds": ["user001", "user002"],
"atMobiles": ["15xxx", "18xxx"]
},
# 链接消息
"link": {
"messageUrl": "1",
"picUrl": "1",
"text": "1",
"title": "1"
},
# markdown消息
"markdown": {
"text": "1",
"title": "1"
},
# feedCard消息
"feedCard": {
"links": {
"picURL": "1",
"messageURL": "1",
"title": "1"
}
},
# 文本消息
"text": {
"content": msg
},
"msgtype": "text",
# actionCard消息
"actionCard": {
"hideAvatar": "1",
"btnOrientation": "1",
"singleTitle": "1",
"btns": [{
"actionURL": "1",
"title": "1"
}],
"text": "1",
"singleURL": "1",
"title": "1"
}
}
r = requests.post(url, data=json.dumps(data), headers=headers)
print("ok")
return r.text
if __name__ == '__main__':
# msg = "zabbix告警"
msg = "告警" + sys.argv[1] + "\n" + sys.argv[2]
token = "7ef7db65342f433a321b3a1fa1b50077102530dcc079aa421505952d5ba13248%27" # 改成自己的token
# 钉钉机器人的url连接
url = f'https://oapi.dingtalk.com/robot/send?access_token={token}'
print(send_msg(url, msg))...
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Rohin1/zabbix-test.git
git@gitee.com:Rohin1/zabbix-test.git
Rohin1
zabbix-test
zabbix-报警介质
master

搜索帮助