@@ -85,13 +85,16 @@ type CheckResult struct {
85
85
//
86
86
// NOTE:
87
87
// - An empty Service field indicates a host downtime.
88
+ // - If a downtime was added by a ScheduledDowntime object, ConfigOwner is set to the name of that object and can
89
+ // only be cancelled by its owner. Otherwise, it is empty and indicates user-created downtimes (via API or/and UI).
88
90
//
89
91
// https://icinga.com/docs/icinga-2/latest/doc/09-object-types/#objecttype-downtime
90
92
type Downtime struct {
91
- Host string `json:"host_name"`
92
- Service string `json:"service_name"`
93
- Author string `json:"author"`
94
- Comment string `json:"comment"`
93
+ Host string `json:"host_name"`
94
+ Service string `json:"service_name"`
95
+ Author string `json:"author"`
96
+ Comment string `json:"comment"`
97
+ ConfigOwner string `json:"config_owner"`
95
98
96
99
// RemoveTime is used to indicate whether a downtime was ended automatically or cancelled prematurely by a user.
97
100
// It is set to zero time for the former case, otherwise to the timestamp at which time has been cancelled.
@@ -133,6 +136,7 @@ type HostServiceRuntimeAttributes struct {
133
136
LastStateChange UnixFloat `json:"last_state_change"`
134
137
DowntimeDepth int `json:"downtime_depth"`
135
138
Acknowledgement int `json:"acknowledgement"`
139
+ IsFlapping bool `json:"flapping"`
136
140
AcknowledgementLastChange UnixFloat `json:"acknowledgement_last_change"`
137
141
}
138
142
@@ -179,40 +183,32 @@ type StateChange struct {
179
183
CheckResult CheckResult `json:"check_result"`
180
184
DowntimeDepth int `json:"downtime_depth"`
181
185
Acknowledgement bool `json:"acknowledgement"`
186
+
187
+ // There is no such json key in the Icinga 2 API streams for state change events, so exclude it.
188
+ // This is going to be set/unset manually within this icinga2 package.
189
+ IsFlapping bool `json:"-"`
182
190
}
183
191
184
- // AcknowledgementSet represents the Icinga 2 API Event Stream AcknowledgementSet response for acknowledgements set on hosts/services.
192
+ // Acknowledgement represents the Icinga 2 API Event Stream AcknowledgementSet or AcknowledgementCleared
193
+ // response for acknowledgements set/cleared on/from hosts/services.
185
194
//
186
195
// NOTE:
187
196
// - An empty Service field indicates a host acknowledgement.
188
197
// - State might be StateHost{Up,Down} for hosts or StateService{Ok,Warning,Critical,Unknown} for services.
189
198
// - StateType might be StateTypeSoft or StateTypeHard.
199
+ // - EventType is either set to typeAcknowledgementSet or typeAcknowledgementCleared
190
200
//
191
201
// https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#event-stream-type-acknowledgementset
192
- type AcknowledgementSet struct {
202
+ // https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#event-stream-type-acknowledgementcleared
203
+ type Acknowledgement struct {
193
204
Timestamp UnixFloat `json:"timestamp"`
194
205
Host string `json:"host"`
195
206
Service string `json:"service"`
196
207
State int `json:"state"`
197
208
StateType int `json:"state_type"`
198
209
Author string `json:"author"`
199
210
Comment string `json:"comment"`
200
- }
201
-
202
- // AcknowledgementCleared represents the Icinga 2 API Event Stream AcknowledgementCleared response for acknowledgements cleared on hosts/services.
203
- //
204
- // NOTE:
205
- // - An empty Service field indicates a host acknowledgement.
206
- // - State might be StateHost{Up,Down} for hosts or StateService{Ok,Warning,Critical,Unknown} for services.
207
- // - StateType might be StateTypeSoft or StateTypeHard.
208
- //
209
- // https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#event-stream-type-acknowledgementcleared
210
- type AcknowledgementCleared struct {
211
- Timestamp UnixFloat `json:"timestamp"`
212
- Host string `json:"host"`
213
- Service string `json:"service"`
214
- State int `json:"state"`
215
- StateType int `json:"state_type"`
211
+ EventType string `json:"type"`
216
212
}
217
213
218
214
// CommentAdded represents the Icinga 2 API Event Stream CommentAdded response for added host/service comments.
@@ -267,13 +263,21 @@ type DowntimeTriggered struct {
267
263
//
268
264
// NOTE:
269
265
// - An empty Service field indicates a host being in flapping state.
266
+ // - State includes the current state of the Checkable at the point in time at which it enters or exits the flapping state.
267
+ // - CurrentFlapping indicates the current flapping value of a Checkable in percent.
268
+ // - ThresholdLow is the low/min flapping threshold value set by the user (CurrentFlapping < ThresholdLow = flapping end).
269
+ // - ThresholdHigh is the high/max flapping threshold value set by the user (CurrentFlapping > ThresholdHigh = flapping start).
270
270
//
271
271
// https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#event-stream-type-flapping
272
272
type Flapping struct {
273
- Timestamp UnixFloat `json:"timestamp"`
274
- Host string `json:"host"`
275
- Service string `json:"service"`
276
- IsFlapping bool `json:"is_flapping"`
273
+ Timestamp UnixFloat `json:"timestamp"`
274
+ Host string `json:"host"`
275
+ Service string `json:"service"`
276
+ IsFlapping bool `json:"is_flapping"`
277
+ State int `json:"state"`
278
+ CurrentFlapping int `json:"current_flapping"`
279
+ ThresholdLow int `json:"threshold_low"`
280
+ ThresholdHigh int `json:"threshold_high"`
277
281
}
278
282
279
283
// CheckableCreatedDeleted represents the Icinga 2 API stream Checkable created/deleted response.
@@ -339,10 +343,8 @@ func UnmarshalEventStreamResponse(bytes []byte) (any, error) {
339
343
switch responseType {
340
344
case typeStateChange :
341
345
resp = new (StateChange )
342
- case typeAcknowledgementSet :
343
- resp = new (AcknowledgementSet )
344
- case typeAcknowledgementCleared :
345
- resp = new (AcknowledgementCleared )
346
+ case typeAcknowledgementSet , typeAcknowledgementCleared :
347
+ resp = new (Acknowledgement )
346
348
case typeCommentAdded :
347
349
resp = new (CommentAdded )
348
350
case typeCommentRemoved :
0 commit comments