Connect IcingaDB::UpdateState to Checkable::OnNewCheckResult instead of calling it in IcingaDB#SendEvent()

This commit is contained in:
Alexander A. Klimov 2020-03-04 11:18:16 +01:00
parent cef4c46ba8
commit efa548fbdf
2 changed files with 2 additions and 13 deletions

View File

@ -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<IcingaDB>()) {
rw->UpdateState(checkable);
rw->SendNextUpdate(checkable);
}
}

View File

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