From 84d09876b4f49f930e09e2e987edfa4abae8017a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 5 Jan 2022 12:47:54 +0100 Subject: [PATCH] Icinga DB: ensure is_reachable and severity don't miss updates refs #9143 --- lib/icingadb/icingadb-objects.cpp | 13 +++++++++++++ lib/icingadb/icingadb.hpp | 1 + 2 files changed, 14 insertions(+) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 6957d94cb..0dd810071 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -84,6 +84,10 @@ void IcingaDB::ConfigStaticInitialize() AcknowledgementClearedHandler(checkable, removedBy, changeTime); }); + Checkable::OnReachabilityChanged.connect([](const Checkable::Ptr&, const CheckResult::Ptr&, std::set children, const MessageOrigin::Ptr&) { + IcingaDB::ReachabilityChangeHandler(children); + }); + /* triggered on create, update and delete objects */ ConfigObject::OnActiveChanged.connect([](const ConfigObject::Ptr& object, const Value&) { IcingaDB::VersionChangedHandler(object); @@ -2599,6 +2603,15 @@ void IcingaDB::StateChangeHandler(const ConfigObject::Ptr& object, const CheckRe } } +void IcingaDB::ReachabilityChangeHandler(const std::set& children) +{ + for (const IcingaDB::Ptr& rw : ConfigType::GetObjectsByType()) { + for (auto& checkable : children) { + rw->UpdateState(checkable, StateUpdate::Full); + } + } +} + void IcingaDB::VersionChangedHandler(const ConfigObject::Ptr& object) { Type::Ptr type = object->GetReflectionType(); diff --git a/lib/icingadb/icingadb.hpp b/lib/icingadb/icingadb.hpp index 0ea003a34..91e0bb45e 100644 --- a/lib/icingadb/icingadb.hpp +++ b/lib/icingadb/icingadb.hpp @@ -136,6 +136,7 @@ private: static String GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj); static bool PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& attributes, Dictionary::Ptr& checkSums); + static void ReachabilityChangeHandler(const std::set& children); static void StateChangeHandler(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type); static void VersionChangedHandler(const ConfigObject::Ptr& object); static void DowntimeStartedHandler(const Downtime::Ptr& downtime);