Skip to content

Commit

Permalink
dpinger: only monitor for existing entries of enabled interfaces
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fichtner committed Apr 26, 2019
1 parent 139ef13 commit d8e17d7
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions src/etc/inc/plugins.inc.d/dpinger.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d8e17d7

Please sign in to comment.