您的位置:首页 > 运维架构 > Shell

Linux Shell编程实战---使用shell实现钉钉告警

2017-09-13 11:58 399 查看
1、告警脚本
#!/bin/bash
#script_name:alert_to_DingDing.sh
#author weixiaoxin write by 2017-09-13

function SendMessageToDingding(){
url="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxoooooooooo"
UA="Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"

res=`curl -XPOST -s -L -H "Content-Type:application/json" -H "charset:utf-8" $url -d "
{
\"msgtype\": \"text\",
\"text\": {
\"content\": \"$1\n$2\"
}
}"`

echo $res

}

subject="Test"
body="XXX业务发生异常,请及时处理"
SendMessageToDingding $subject $body


2、告警结果



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux