| | |
| | | String pingCommand; |
| | | Runtime r = Runtime.getRuntime(); |
| | | String osName = System.getProperty("os.name"); |
| | | System.out.println( "osName:"+osName); |
| | | if (osName.contains("Windows")) { |
| | | pingCommand = "ping " + ipAddress + " -n " + count + " -w " + (timeOut * 1000); |
| | | } else { |
| | | pingCommand = "ping " + " -c " + count + " -w " + timeOut + " " + ipAddress; |
| | | pingCommand = "ping " + " -c " + count + " " + ipAddress; |
| | | } |
| | | Integer diffTimes = StaticKeys.OUT_TIME_MARK; |
| | | try { |
| | |
| | | //查找整数的正则 begin |
| | | String regInt = "(=\\d+ms)"; |
| | | Pattern patternInt = Pattern.compile(regInt); |
| | | |
| | | Matcher matcherInt = patternInt.matcher(line); |
| | | while (matcherInt.find()) { |
| | | String groupStr = matcherInt.group(1); |
| | |
| | | String regDouble = "(=\\d+.\\d+ms)"; |
| | | Pattern patternDouble = Pattern.compile(regDouble); |
| | | Matcher matcherDouble = patternDouble.matcher(line); |
| | | |
| | | while (matcherDouble.find()) { |
| | | String groupStr = matcherDouble.group(1); |
| | | logger.debug(line + "--------------" + groupStr); |