From efa548fbdf45d0839dd84f71a403f0c51c7f7401 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 4 Mar 2020 11:18:16 +0100 Subject: [PATCH] Connect IcingaDB::UpdateState to Checkable::OnNewCheckResult instead of calling it in IcingaDB#SendEvent() --- lib/icingadb/icingadb-objects.cpp | 2 ++ lib/icingadb/icingadb.cpp | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index e31988837..abd8610b0 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -102,6 +102,7 @@ void IcingaDB::ConfigStaticInitialize() Checkable::OnNewCheckResult.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr&, const MessageOrigin::Ptr&) { IcingaDB::NewCheckResultHandler(checkable); }); + Checkable::OnNextCheckChanged.connect([](const Checkable::Ptr& checkable, const Value&) { IcingaDB::NextCheckChangedHandler(checkable); }); @@ -2044,6 +2045,7 @@ void IcingaDB::FlappingChangeHandler(const Checkable::Ptr& checkable, double cha void IcingaDB::NewCheckResultHandler(const Checkable::Ptr& checkable) { for (auto& rw : ConfigType::GetObjectsByType()) { + rw->UpdateState(checkable); rw->SendNextUpdate(checkable); } } diff --git a/lib/icingadb/icingadb.cpp b/lib/icingadb/icingadb.cpp index 96ddcb3fb..069eda601 100644 --- a/lib/icingadb/icingadb.cpp +++ b/lib/icingadb/icingadb.cpp @@ -193,19 +193,6 @@ void IcingaDB::SendEvent(const Dictionary::Ptr& event) String type = event->Get("type"); - if (type == "CheckResult") { - Checkable::Ptr checkable; - - if (event->Contains("service")) { - checkable = Service::GetByNamePair(event->Get("host"), event->Get("service")); - } else { - checkable = Host::GetByName(event->Get("host")); - } - - // Update State for icingaweb - m_WorkQueue.Enqueue([this, checkable]() { UpdateState(checkable); }); - } - if (type.Contains("Acknowledgement")) { Checkable::Ptr checkable;