#!/bin/bash
website=(
https://www.baidu.com
)
while :
do
for i in ${website[@]}
do
code=`curl --connect-timeout 10 -m 20 -sIL -w "%{http_code}\n" -o /dev/null $i`
TIME=`date +'%F %H:%M:%S %A %Z'`
if [ "$code" != 200 ];then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cf3b9149-06ad-4913-a7ee-************' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "text",
"text": {
"content": "站点 '"$i"' 网络返回码非200,http_code: '"$code"' , 时间: '"$TIME"'"
}
}'
fi
done
sleep 60
echo "start next request!"
date +'%F %H:%M:%S %A %Z'
done
网友评论