dpinger: only monitor for existing entries of enabled interfaces

I have a little beef with the new code: the System: Gateways: Single
page listing should always list existing config.xml gateways, but it
does not.  So it looks like a gateway was deleted when in fact it is
being hidden.  This is definitely a visibility departure from the
previous code.
This commit is contained in:
Franco Fichtner 2019-04-26 18:03:53 +02:00
parent 139ef1334f
commit d8e17d7737

View File

@ -30,39 +30,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
function dpinger_enabled()
{
global $config;
$gwcount = 0;
if (isset($config['gateways']['gateway_item'])) {
foreach ($config['gateways']['gateway_item'] as $gwkey => $gateway) {
if (!isset($gateway['monitor_disable']) || $gateway['monitor_disable'] == '0') {
$gwcount += 1;
}
}
}
if ($gwcount == 0) {
return false;
}
return true;
}
function dpinger_services()
{
global $config;
$services = array();
if (!dpinger_enabled()) {
if (!isset($config['gateways']['gateway_item'])) {
return $services;
}
foreach ($config['gateways']['gateway_item'] as $gateway) {
if (isset($gateway['monitor_disable'])) {
if (isset($gateway['monitor_disable']) && $gateway['monitor_disable'] != '0') {
continue;
}
if (empty($config['interfaces'][$gateway['interface']]['enable'])) {
continue;
}