利用let计数监控web服务状态
#监控服务状态
ServerMonitor () {
#服务状态监控
timeout=10
fails=0
success=0
while true
 do
     /usr/bin/wget --timeout=$timeout --tries=1 http://192.168.1.1.101/ -q -O /dev/null
      if [ $? -ne 0 ]
        then
          let fails=fails+1
          success=0
      else
             fails=0
             let success=1
      fi
      if [ $success -ge 1 ]
           then
                   exit 0
      fi
      if [ $fails -ge 2 ]
           then
                    Critical="应用服务出现故障,请处理!"
    echo $Critical | mutt -s "服务down" shnne@shnne.com
   exit
      fi
done
}
点评
还没有点评哦!