From b60d3e56652dd78105349a7b4bf674aeb3d6a7ea Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 12 Jan 2022 16:39:15 +0100 Subject: [PATCH] Icinga DB: make host problem change events update the state tables but not write state history StateChangeHandler() is the function used when the actual hard/soft state changes and thus also writes state history. This is not desired in this case, instead, a runtime update should be generated, therefore call UpdateState() instead. refs #9063 --- lib/icingadb/icingadb-objects.cpp | 9 ++++++++- lib/icingadb/icingadb.hpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 9f73f0cc9..0de6444e8 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -119,7 +119,7 @@ void IcingaDB::ConfigStaticInitialize() }); Service::OnHostProblemChanged.connect([](const Service::Ptr& service, const CheckResult::Ptr&, const MessageOrigin::Ptr&) { - IcingaDB::StateChangeHandler(service); + IcingaDB::HostProblemChangedHandler(service); }); Notification::OnUsersRawChangedWithOldValue.connect([](const Notification::Ptr& notification, const Value& oldValues, const Value& newValues) { @@ -2695,6 +2695,13 @@ void IcingaDB::NextCheckChangedHandler(const Checkable::Ptr& checkable) } } +void IcingaDB::HostProblemChangedHandler(const Service::Ptr& service) { + for (auto& rw : ConfigType::GetObjectsByType()) { + /* Host state changes affect is_handled and severity of services. */ + rw->UpdateState(service, StateUpdate::Full); + } +} + void IcingaDB::AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double changeTime, double expiry) { auto rws (ConfigType::GetObjectsByType()); diff --git a/lib/icingadb/icingadb.hpp b/lib/icingadb/icingadb.hpp index f0b62047f..5bbb99d04 100644 --- a/lib/icingadb/icingadb.hpp +++ b/lib/icingadb/icingadb.hpp @@ -152,6 +152,7 @@ private: static void FlappingChangeHandler(const Checkable::Ptr& checkable, double changeTime); static void NewCheckResultHandler(const Checkable::Ptr& checkable); static void NextCheckChangedHandler(const Checkable::Ptr& checkable); + static void HostProblemChangedHandler(const Service::Ptr& service); static void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool persistent, double changeTime, double expiry); static void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double changeTime); static void NotificationUsersChangedHandler(const Notification::Ptr& notification, const Array::Ptr& oldValues, const Array::Ptr& newValues);