diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 8443fdc7f..42d563ea6 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -248,7 +248,20 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig SetCheckAttempt(attempt); ServiceState new_state = cr->GetState(); - SetStateRaw(new_state); + + if (service) { + SetStateRaw(new_state); + } else { + bool wasProblem = GetProblem(); + + SetStateRaw(new_state); + + if (GetProblem() != wasProblem) { + for (auto& service : host->GetServices()) { + Service::OnHostProblemChanged(service, cr, origin); + } + } + } bool stateChange; diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index ec80aa6dc..9d3495667 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -13,6 +13,8 @@ using namespace icinga; REGISTER_TYPE(Service); +boost::signals2::signal Service::OnHostProblemChanged; + String ServiceNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const { Service::Ptr service = dynamic_pointer_cast(context); diff --git a/lib/icinga/service.hpp b/lib/icinga/service.hpp index 0e6e4d8d3..493f261e2 100644 --- a/lib/icinga/service.hpp +++ b/lib/icinga/service.hpp @@ -44,6 +44,8 @@ public: static void EvaluateApplyRules(const Host::Ptr& host); + static boost::signals2::signal OnHostProblemChanged; + protected: void OnAllConfigLoaded() override; void CreateChildObjects(const Type::Ptr& childType) override; diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 77d058f29..386983f09 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -94,6 +94,10 @@ void IcingaDB::ConfigStaticInitialize() Checkable::OnNewCheckResult.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr&, const MessageOrigin::Ptr&) { IcingaDB::NewCheckResultHandler(checkable); }); + + Service::OnHostProblemChanged.connect([](const Service::Ptr& service, const CheckResult::Ptr&, const MessageOrigin::Ptr&) { + IcingaDB::StateChangeHandler(service); + }); } void IcingaDB::UpdateAllConfigObjects()