shell脚本检测站点端口正常访问

#!/bin/bash
urls=( "www.test1.com" "www.test2.com" "www.test3.com" "www.test4.com")
    for i in ${urls[@]}
        do
                http_code=$(curl -I -s $i -w %{http_code})
                if [ "${http_code:9:3}" -ne "200" ]; then
                        echo "website $i 80port was closed,please check it !" | mail  -s "test's server  $i alarm"     [email protected]
                fi
        done

你可能感兴趣的:(shell)