From: Michael Friedrich Date: Fri, 31 Jul 2015 14:19:58 +0000 (+0200) Subject: Fix cluster check w/ immediate parent and child zone endpoints X-Git-Tag: v2.4.0~448 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7e8d8afc93b41b5f5bd7ac469a98b9cc5e42b1a;p=icinga2 Fix cluster check w/ immediate parent and child zone endpoints fixes #9262 --- diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index a982e1135..84b89ad7f 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -841,16 +841,27 @@ std::pair ApiListener::GetStatus(void) Array::Ptr not_connected_endpoints = new Array(); Array::Ptr connected_endpoints = new Array(); - BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjectsByType()) { - if (endpoint->GetName() == GetIdentity()) + Zone::Ptr my_zone = Zone::GetLocalZone(); + + BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType()) { + /* only check endpoints in a) the same zone b) our parent zone c) immediate child zones */ + if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent()) { + Log(LogDebug, "ApiListener") + << "Not checking connection to Zone '" << zone->GetName() << "' because it's not in the same zone, a parent or a child zone."; continue; + } - count_endpoints++; + BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) { + if (endpoint->GetName() == GetIdentity()) + continue; - if (!endpoint->IsConnected()) - not_connected_endpoints->Add(endpoint->GetName()); - else - connected_endpoints->Add(endpoint->GetName()); + count_endpoints++; + + if (!endpoint->IsConnected()) + not_connected_endpoints->Add(endpoint->GetName()); + else + connected_endpoints->Add(endpoint->GetName()); + } } status->Set("num_endpoints", count_endpoints);