Added options for fping to retry and timeout

This commit is contained in:
laf
2014-10-16 21:52:35 +01:00
parent 4a19553e31
commit d8904d866c
2 changed files with 29 additions and 20 deletions
+9 -2
View File
@@ -463,13 +463,20 @@ function isPingable($hostname,$device_id = FALSE)
{
global $config;
$status = shell_exec($config['fping'] . " -e $hostname 2>/dev/null");
$fping_params = '';
if(is_numeric($config['fping_options']['retries']) || $config['fping_options']['retries'] > 1) {
$fping_params .= ' -r ' . $config['fping_options']['retries'];
}
if(is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) {
$fping_params .= ' -t ' . $config['fping_options']['timeout'];
}
$status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null");
$response = array();
if (strstr($status, "alive"))
{
$response['result'] = TRUE;
} else {
$status = shell_exec($config['fping6'] . " -e $hostname 2>/dev/null");
$status = shell_exec($config['fping6'] . "$fping_params -e $hostname 2>/dev/null");
if (strstr($status, "alive"))
{
$response['result'] = TRUE;