#!/bin/bash
. /etc/init.d/functions
url_list=(
http://192.168.0.201
http://www.baidu.com
http://xxx.elearningch.com
http://www.sina.com
)
wait(){
echo -n "it will start three seconed later"
for ((i=0;i<3;i++))
do
echo -n "."; sleep 1
done
echo
}
#wait
check_url(){
for ((i=0;i<${#url_list[@]};i++))
do
judge=($(curl -I -s --connect-timeout 2 ${url_list[$i]} | head -1|
tr "\r" "\n"))
if [[ "${judge[1]}" == '200' && "${judge[2]}" == 'OK' ]];then
action "${url_list[$i]} is success" /bin/true
else
action "${url_list[$i]} is failer" /bin/false
fi
done
}
check_url
~