From ca487ed7328c9301d954da2926b8dcb1fe76e134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20R=C3=B6hl?= <mail@fabian-roehl.de> Date: Fri, 18 Sep 2020 08:20:29 +0200 Subject: [PATCH] #7735 API-Event StateChange & CheckResult: Added acknowledgement and downtime_depth --- doc/12-icinga2-api.md | 36 ++++++++++++++++++++---------------- lib/icinga/apievents.cpp | 6 ++++++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/doc/12-icinga2-api.md b/doc/12-icinga2-api.md index de12880ba..61697ee54 100644 --- a/doc/12-icinga2-api.md +++ b/doc/12-icinga2-api.md @@ -1585,25 +1585,29 @@ Example for all downtime events: #### <a id="icinga2-api-event-streams-type-checkresult"></a> Event Stream Type: CheckResult - Name | Type | Description - --------------|---------------|-------------------------- - type | String | Event type `CheckResult`. - timestamp | Timestamp | Unix timestamp when the event happened. - host | String | [Host](09-object-types.md#objecttype-host) name. - service | String | [Service](09-object-types.md#objecttype-service) name. Optional if this is a host check result. - check\_result | CheckResult | Serialized [CheckResult](08-advanced-topics.md#advanced-value-types-checkresult) value type. + Name | Type | Description + -----------------|---------------|-------------------------- + type | String | Event type `CheckResult`. + timestamp | Timestamp | Unix timestamp when the event happened. + host | String | [Host](09-object-types.md#objecttype-host) name. + service | String | [Service](09-object-types.md#objecttype-service) name. Optional if this is a host check result. + check\_result | CheckResult | Serialized [CheckResult](08-advanced-topics.md#advanced-value-types-checkresult) value type. + downtime\_depth | Number | Amount of active downtimes on the checkable. + acknowledgement | Boolean | Whether the object is acknowledged. #### <a id="icinga2-api-event-streams-type-statechange"></a> Event Stream Type: StateChange - Name | Type | Description - --------------|---------------|-------------------------- - type | String | Event type `StateChange`. - timestamp | Timestamp | Unix timestamp when the event happened. - host | String | [Host](09-object-types.md#objecttype-host) name. - service | String | [Service](09-object-types.md#objecttype-service) name. Optional if this is a host state change. - state | Number | [Host](09-object-types.md#objecttype-host) or [service](09-object-types.md#objecttype-service) state. - state\_type | Number | [Host](09-object-types.md#objecttype-host) or [service](09-object-types.md#objecttype-service) state type. - check\_result | CheckResult | Serialized [CheckResult](08-advanced-topics.md#advanced-value-types-checkresult) value type. + Name | Type | Description + -----------------|---------------|-------------------------- + type | String | Event type `StateChange`. + timestamp | Timestamp | Unix timestamp when the event happened. + host | String | [Host](09-object-types.md#objecttype-host) name. + service | String | [Service](09-object-types.md#objecttype-service) name. Optional if this is a host state change. + state | Number | [Host](09-object-types.md#objecttype-host) or [service](09-object-types.md#objecttype-service) state. + state\_type | Number | [Host](09-object-types.md#objecttype-host) or [service](09-object-types.md#objecttype-service) state type. + check\_result | CheckResult | Serialized [CheckResult](08-advanced-topics.md#advanced-value-types-checkresult) value type. + downtime\_depth | Number | Amount of active downtimes on the checkable. + acknowledgement | Boolean | Whether the object is acknowledged. #### <a id="icinga2-api-event-streams-type-notification"></a> Event Stream Type: Notification diff --git a/lib/icinga/apievents.cpp b/lib/icinga/apievents.cpp index 375ffe2fd..203c2b5b5 100644 --- a/lib/icinga/apievents.cpp +++ b/lib/icinga/apievents.cpp @@ -56,6 +56,9 @@ void ApiEvents::CheckResultHandler(const Checkable::Ptr& checkable, const CheckR result->Set("check_result", Serialize(cr)); + result->Set("downtime_depth", checkable->GetDowntimeDepth()); + result->Set("acknowledgement", checkable->IsAcknowledged()); + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); } @@ -89,6 +92,9 @@ void ApiEvents::StateChangeHandler(const Checkable::Ptr& checkable, const CheckR result->Set("state_type", checkable->GetStateType()); result->Set("check_result", Serialize(cr)); + result->Set("downtime_depth", checkable->GetDowntimeDepth()); + result->Set("acknowledgement", checkable->IsAcknowledged()); + for (const EventQueue::Ptr& queue : queues) { queue->ProcessEvent(result); }