自动监控Web服务进程的shell脚本(2)

发表于:2013-01-04来源:ITEYE作者:gaozhonghui点击数: 标签:web测试
#status: 0,http down 1,http ok 2,http down but ping ok if nc -vv -z -w 2 $server_ip $server_port /dev/null 21;then status=1 else if nc -vv -z -w 3 $server_ip $server_port /dev/null 21;then status=1 el

  #status: 0,http down 1,http ok 2,http down but ping ok

  if nc -vv -z -w 2 $server_ip $server_port > /dev/null 2>&1;then

  status=1

  else

  if nc -vv -z -w 3 $server_ip $server_port > /dev/null 2>&1;then

  status=1

  else

  if ping -c 1 $server_ip > /dev/null 2>&1;then

  status=2

  else

  status=0

  fi

  fi

  fi

  if [ x$status != x"1" ];then

  PID=`function_getPID ${server_name}`

  if [ x$PID != x ];then

  function_jstackinfo ${server_name}

  function_restart ${server_name}

  else

  function_startup ${server_name}

  fi

  fi

  done

原文转自:http://www.ltesting.net