Fix for redmine ticket #1993. Allow saving multiple dynamic entries.

Make sure that return_gateways_status() also returns all gateways that have monitoring disabled as up.
This commit is contained in:
smos 2011-11-27 18:56:24 +01:00
parent af6f42c11c
commit f328ad12e0
2 changed files with 26 additions and 12 deletions

View File

@ -267,6 +267,32 @@ function return_gateways_status($byname = false) {
$status[$target]['status'] = trim($info[8]);
}
/* tack on any gateways that have monitoring disabled */
$gateways_arr = return_gateways_array();
foreach($gateways_arr as $gwitem) {
if(isset($gwitem['monitor_disable'])) {
if(!is_ipaddr($gwitem['monitorip'])) {
$realif = $gwitem['interface'];
$tgtip = get_interface_gateway($realif);
$srcip = find_interface_ip($realif);
} else {
$tgtip = $gwitem['monitorip'];
$srcip = find_interface_ip($realif);
}
if($byname == true)
$target = $gwitem['name'];
else
$target = $tgtip;
$status[$target]['monitorip'] = $tgtip;
$status[$target]['srcip'] = $srcip;
$status[$target]['name'] = $gwitem['name'];
$status[$target]['lastcheck'] = date('r');
$status[$target]['delay'] = "0.0ms";
$status[$target]['loss'] = "0.0%";
$status[$target]['status'] = "none";
}
}
return($status);
}

View File

@ -197,18 +197,6 @@ if ($_POST) {
}
if (!$input_errors) {
if (!($_POST['weight'] > 1 || $_POST['latencylow'] || $_POST['latencyhigh'] ||
$_POST['losslow'] || $_POST['losshigh'] || $_POST['down'] ||
$_POST['defaultgw'] || is_ipaddr($_POST['monitor']) || is_ipaddr($_POST['gateway']))) {
/* Delete from config if gw is dynamic and user is not saving any additional gateway data that system doesn't know */
if (isset($id) && $a_gateway_item[$id])
unset($a_gateway_item[$id]);
write_config();
header("Location: system_gateways.php");
exit;
}
$reloadif = "";
$gateway = array();