#!/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