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、告警结果


wKioL1m4rKXzgVVUAAAZiJaWDXE732.png-wh_50