linux系统运维过程中,经常会遇到些问题,有时候问题会比较麻烦,此时shell脚本的优势就体现出来,本篇文章重点为大家讲解一下Linux中通过shell脚本监测网站状态。
其一
#!/bin/bashfunction usage(){
echo $"usage:$0 url"exit 1
}
function check_url() {
wget --spider -q -o /dev/null --tries=1 -T 5 $1if [ $? -eq 0 ]
thenecho "$1 is yes."exit 0
elseecho "$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/trueelse action "failure" /bin/falsefi其三
. /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/trueelse action "Failure of website access" /bin/falsefi其四
#!/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/trueelse action "Failure of website access" /bin/falsefi文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/209697.html<

