#!/bin/bash
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
# 釘釘機器人的Webhook地址
WEBHOOK_URL="https://oapi.dingtalk.com/robot/send?access_token=4c5c408430622642e08d413036187ae82c8ae20a7d81b2d4a8fd418d8259b4e9"
# 告警訊息內容
MESSAGE="告警資訊:\n$1"
# 傳送告警訊息到釘釘機器人
curl -H "Content-Type: application/json" -d "
{
\"msgtype\": \"text\",
\"text\": {
\"content\": \"$MESSAGE\"
}
}" $WEBHOOK_URL
#執行示例: sh dingding.sh "`echo -e "$date-應用程序監控:\n伺服器資訊:$IP\ntest程序異常,請緊急處理"`"