Skip to content

Commit

Permalink
fix: Fail isPingable if fping errors (#7426)
Browse files Browse the repository at this point in the history
  • Loading branch information
f0o authored and laf committed Oct 15, 2017
1 parent 62867a6 commit 1998845
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions includes/functions.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 1998845

Please sign in to comment.