新聞中心
這里有您想知道的互聯(lián)網營銷解決方案
Linux中通過shell腳本監(jiān)測網站狀態(tài)
linux系統(tǒng)運維過程中,經常會遇到些問題,有時候問題會比較麻煩,此時shell腳本的優(yōu)勢就體現(xiàn)出來,本篇文章重點為大家講解一下Linux中通過shell腳本監(jiān)測網站狀態(tài)。

其一
#!/bin/bash
function usage(){
echo $"usage:$0 url"
exit 1
}
function check_url() {
wget --spider -q -o /dev/null --tries=1 -T 5 $1
if [ $? -eq 0 ]
then
echo "$1 is yes."
exit 0
else
echo "$1 is fail."
exit 1
fi
}
其二
#!/bin/bash
. /etc/init.d/functions
num=`curl -I -m 5 -s -w "%{http_code}\n" -o /dev/null 192.168.100.141:8080`
if [ $num -eq 200 ]
then action "ok!" /bin/true
else action "failure" /bin/false
fi
其三
. /etc/init.d/functions
curl -s -o /dev/null 192.168.100.141:8080
if [ $? -eq 0 ]
then action "Web site access is normal" /bin/true
else action "Failure of website access" /bin/false
fi
其四
#!/bin/bash
. /etc/init.d/functions
wget --spider -T 5 -q -t 2 192.168.100.141:8080
if [ $? -eq 0 ]
then action "Web site access is normal" /bin/true
else action "Failure of website access" /bin/false
fi
分享名稱:Linux中通過shell腳本監(jiān)測網站狀態(tài)
URL網址:http://m.fisionsoft.com.cn/article/dhsecjj.html


咨詢
建站咨詢
