IcingaDB: update service state on Host#problem change

refs #7673
This commit is contained in:
Alexander A. Klimov 2019-12-03 16:51:34 +01:00
parent bb9b70d466
commit 798c56b809
4 changed files with 22 additions and 1 deletions

View File

@ -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;

View File

@ -13,6 +13,8 @@ using namespace icinga;
REGISTER_TYPE(Service);
boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, const MessageOrigin::Ptr&)> Service::OnHostProblemChanged;
String ServiceNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
{
Service::Ptr service = dynamic_pointer_cast<Service>(context);

View File

@ -44,6 +44,8 @@ public:
static void EvaluateApplyRules(const Host::Ptr& host);
static boost::signals2::signal<void (const Service::Ptr&, const CheckResult::Ptr&, const MessageOrigin::Ptr&)> OnHostProblemChanged;
protected:
void OnAllConfigLoaded() override;
void CreateChildObjects(const Type::Ptr& childType) override;

View File

@ -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()