shell+飞信实现网站监控
生活随笔
收集整理的這篇文章主要介紹了
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和域名的對應關系。
#!/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
總結
以上是生活随笔為你收集整理的shell+飞信实现网站监控的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux下巧妙使用邮件服务器之post
- 下一篇: (转载)把syslog接收的远程日志从/