新建testmsg.sh文件,内容如下
1 2 #!/bin/sh 3 content=${@:1} 4 content=${content//\<font color=\‘red\‘\>/} 5 content=${content//\<\/font\>\<\/br\>/} 6 7 echo "warn content is : $content" 8 9 webhook=‘https://oapi.dingtalk.com/robot/send?access_token=34XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX‘ 10 11 function SendMsgToDingding() { 12 curl $webhook -H ‘Content-Type: application/json‘ -d " 13 { 14 ‘msgtype‘: ‘text‘, 15 ‘text‘: { 16 ‘content‘: ‘告警信息:$1‘ 17 }, 18 ‘at‘: { 19 ‘isAtAll‘: true 20 } 21 }" 22 } 23 24 SendMsgToDingding $content
测试过程中,将xxxxxxxx替换为真实access_token。
然后在/server/config/application.yml里,修改配置项
#告警脚本文件,可以为空,参考:/server/template/sendMsg.sh
warnScript: /home/testmsg.sh
好了,这样就可以在钉钉收到告警消息了
原文:https://www.cnblogs.com/wanghouhou/p/13957336.html