首先安装
- pip 进行安装
pip install DingtalkChatbot
案例
- 源代码
#!/usr/bin/python
# -*- coding:utf-8 -*-
from dingtalkchatbot.chatbot import DingtalkChatbot
def SendMsg(Msg):
# WebHook地址
webhook = "https://oapi.dingtalk.com/robot/send?access_token=acf237191e252cb24ca33d92dde7f5e45b37b8bb771b2aeb5d5d1ebf8addd"
# 初始化机器人小丁
xiaoCCOD = DingtalkChatbot(webhook)
# Text消息@所有人,添加CCOD关键字否则无法告警
xiaoCCOD.send_text(msg="CCOD:" + Msg, is_at_all=True)
if __name__ == "__main__":
pass
-
测试验证
image.png -
钉钉告警信息
image.png
网友评论