fix: Fail isPingable if fping errors (#7426)

This commit is contained in:
Daniel Preussker
2017-10-15 19:29:08 +00:00
committed by Neil Lathwood
parent 62867a6661
commit 1998845f06

View File

@ -604,7 +604,7 @@ function isPingable($hostname, $address_family = AF_INET, $attribs = array())
$fping_params .= ' -p ' . $config['fping_options']['millisec'];
}
$status = fping($hostname, $fping_params, $address_family);
if ($status['loss'] == 100) {
if ($status['exitcode'] > 0 || $status['loss'] == 100) {
$response['result'] = false;
} else {
$response['result'] = true;
@ -1365,6 +1365,7 @@ function fping($host, $params, $address_family = AF_INET)
$read .= fgets($pipes[1], 1024);
}
fclose($pipes[1]);
$proc_status = proc_get_status($process);
proc_close($process);
}
@ -1384,7 +1385,7 @@ function fping($host, $params, $address_family = AF_INET)
$min = set_numeric($min);
$max = set_numeric($max);
$avg = set_numeric($avg);
$response = array('xmt'=>$xmt,'rcv'=>$rcv,'loss'=>$loss,'min'=>$min,'max'=>$max,'avg'=>$avg);
$response = array('xmt'=>$xmt,'rcv'=>$rcv,'loss'=>$loss,'min'=>$min,'max'=>$max,'avg'=>$avg,'exitcode'=>$proc_status['exitcode']);
return $response;
}