钉钉机器人通知
#!/bin/bash
webhook='https://oapi.dingtalk.com/robot/send?access_token=34XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
GX='更新服务'
host=`hostname -I | awk '{print $1}'`
ZT=$1
function SendMsgToDingding() {
curl $webhook -H 'Content-Type: application/json' -d "
{
'msgtype': 'text',
'text': {
'content': '$GX\n操作服务器:IP$host 状态是否成功:$ZT\n'
},
'at': {
'isAtAll': false
}
}"
}
SendMsgToDingding
curl 'https://oapi.dingtalk.com/robot/send?access_token=addasdxxxx' -H "Content-Type:application/json" -d "{\"msgtype\": \"text\",
\"text\": {
\"content\": \"服务器异常a,请快速处理下\"
},
\"at\": {
\"atMobiles\": [
\"183xxx50xx\",
],
\"isAtAll\": false
}
}"
遇到的问题
{"errcode":300001,"errmsg":"message param title is null "}
需要添加 增加at参数
自定义机器人开发:https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq
shell 操作钉钉机器人实现告警提醒: https://www.cnblogs.com/xuliuzai/p/11469039.html