天天看點

shell+飛信實作網站監控

網站頁面比較多,我針對每個二級域名的專區提取了一個url進行監控。如果這個url挂了 那麼就會報警。

#!/bin/bash

#cleck url

#2010-04-06

for D in $(cat /root/mo/web/d.txt)

do

echo $D

curl -I --connect-timeout 5 $D 2>/dev/null |grep 200 2>&1 >/dev/null

R=$?

if [ $R == 0 ]

then

echo "$D is UP!"

# /wwwroot/baojing/fetion --mobile=159569xxxx --pwd=254605 --to=159569xxxx --msg-utf8="$D is UP!"

else

/root/mo/sms/fetion --mobile=159569xxxx --pwd=254605 --to=159569xxxx --msg-utf8="$D is DOWN!"

fi

# exit $R

done

注釋:

for D in $(cat /root/mo/web/d.txt) 這裡d.txt裡的需要被檢測的url位址

然後vi /etc/hosts 裡添加每個ip和域名的對應關系。

把這個腳本放到crontab裡每分鐘執行一次。

本文轉自 liang3391 51CTO部落格,原文連結:http://blog.51cto.com/liang3391/456564