wgcloud下载
1.新建/home/testmsg.sh文件,此处目录和文件名称是为测试方便,自己可以根据实际场景自定义,内容如下
#!/bin/sh content=${@:1} content=${content//\<font color=\'red\'\>/} content=${content//\<\/font\>\<\/br\>/} echo "warn content is : $content" webhook='https://oapi.dingtalk.com/robot/send?access_token=34XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' function SendMsgToDingding() { curl $webhook -H 'Content-Type: application/json' -d " { 'msgtype': 'text', 'text': { 'content': '告警信息:$1' }, 'at': { 'isAtAll': true } }" } SendMsgToDingding $content
测试过程中,记得将xxxxxxxx替换为真实access_token。
sh /home/testmsg.sh 测试钉钉告警3.在/server/config/application.yml里,修改配置项
#告警脚本文件,可以为空,参考:/server/template/sendMsg.sh warnScript: /home/testmsg.sh4.好了,重启server,这样就可以在钉钉收到告警消息了