Icinga DB: make acknowledgement 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
This commit is contained in:
Julian Brost 2022-01-12 16:21:57 +01:00
parent f63268b0dd
commit 855e342b63
1 changed files with 6 additions and 8 deletions

View File

@ -84,14 +84,6 @@ 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);
});
/* triggered on create, update and delete objects */
ConfigObject::OnActiveChanged.connect([](const ConfigObject::Ptr& object, const Value&) {
IcingaDB::VersionChangedHandler(object);
@ -2187,6 +2179,9 @@ void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const Str
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
/* Update checkable state as is_acknowledged may have changed. */
UpdateState(checkable, StateUpdate::Full);
std::vector<String> xAdd ({
"XADD", "icinga:history:stream:acknowledgement", "*",
"environment_id", m_EnvironmentId,
@ -2241,6 +2236,9 @@ void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
/* Update checkable state as is_acknowledged may have changed. */
UpdateState(checkable, StateUpdate::Full);
std::vector<String> xAdd ({
"XADD", "icinga:history:stream:acknowledgement", "*",
"environment_id", m_EnvironmentId,