mirror of https://github.com/Icinga/icinga2.git
Connect IcingaDB::StateChangeHandler to Checkable::OnAcknowledgementSet instead of calling it in IcingaDB#SendEvent()
This commit is contained in:
parent
efa548fbdf
commit
867481de7c
|
@ -68,6 +68,9 @@ void IcingaDB::ConfigStaticInitialize()
|
|||
AcknowledgementClearedHandler(checkable, removedBy, changeTime);
|
||||
});
|
||||
|
||||
Checkable::OnAcknowledgementSet.connect([](const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, bool, bool persistent, double changeTime, double expiry, const MessageOrigin::Ptr&) {
|
||||
IcingaDB::StateChangeHandler(checkable);
|
||||
});
|
||||
/* triggered when acknowledged host/service goes back to ok and when the acknowledgement gets deleted */
|
||||
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const String&, double, const MessageOrigin::Ptr&) {
|
||||
IcingaDB::StateChangeHandler(checkable);
|
||||
|
|
|
@ -203,23 +203,6 @@ void IcingaDB::SendEvent(const Dictionary::Ptr& event)
|
|||
checkable = Host::GetByName(event->Get("host"));
|
||||
event->Set("host_id", GetObjectIdentifier(checkable));
|
||||
}
|
||||
|
||||
if (type == "AcknowledgementSet") {
|
||||
Timestamp entry = 0;
|
||||
Comment::Ptr AckComment;
|
||||
|
||||
for (const Comment::Ptr& c : checkable->GetComments()) {
|
||||
if (c->GetEntryType() == CommentAcknowledgement) {
|
||||
if (c->GetEntryTime() > entry) {
|
||||
entry = c->GetEntryTime();
|
||||
AckComment = c;
|
||||
StateChangeHandler(checkable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event->Set("comment_id", GetObjectIdentifier(AckComment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue