Added regex to determine if packet loss is 0%
Accepts: 0 0.0 0.00 0.000 0,0 0,00 0,000
This commit is contained in:
parent
59f434ca4c
commit
500860daf3
|
@ -190,7 +190,9 @@ class StatusUpdater
|
|||
$txt = exec($pingCommand . " -c" . $max_runs . " " . $serverIp . " 2>&1", $output);
|
||||
|
||||
// Check if output is PING and if 0,0% of packages are lost, otherwise fail.
|
||||
if (substr($output[0], 0, 4) == 'PING' && strpos($output[count($output) - 2], '0.0% packet loss')) {
|
||||
preg_match('/([0][,.]?0{0,3})(% packet loss)$/', $output[count($output) - 2], $output_package_loss);
|
||||
|
||||
if (substr($output[0], 0, 4) == 'PING' && count($output_package_loss) !== 0) {
|
||||
// Gets avg from 'round-trip min/avg/max/stddev = 7.109/7.109/7.109/0.000 ms'
|
||||
preg_match_all("/(\d+\.\d+)/", $output[count($output) - 1], $result);
|
||||
$result = floatval($result[0][1]);
|
||||
|
|
Loading…
Reference in New Issue