qqruser 发表于 2018-8-21 11:02:02

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

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


页: [1]
查看完整版本: Linux Shell编程实战---使用shell实现钉钉告警