Linux自动检测网站心跳通知shell脚本

#!/bin/bash
LIST=("http://xxxx.com")
NAME=("评价系统getwindowList接口")
for ((i=0;i<${#LIST[@]};i++))
do
HTTP_CODE=`curl -o /dev/null -s -w "%{http_code}" "${LIST[$i]}"`
if [ $HTTP_CODE != '200' ];then
TIME=$(date "+%Y-%m-%d %H:%M:%S")
#发送微信公众号
curl 'http://xxxxx.com' \
   -H 'Content-Type: application/json' \
   -d "{
        \"content\":\"${NAME[$i]}${LIST[$i]}\"
     }"

#发送钉钉
curl 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxx' \
   -H 'Content-Type: application/json' \
   -d "{\"msgtype\": \"markdown\",
        \"markdown\": {
             \"title\":\"监控到系统无法正常访问\",
             \"text\": \"### 监测到系统无法正常访问 \\n
                 - 名称: ${NAME[$i]}
                 - 网站: [${LIST[$i]}](${LIST[$i]})
                 - 时间: ${TIME} \"
         },
        "isAtAll": true
     }"

fi
done

评论

暂无评论