@@ -130,6 +130,31 @@ func (client *Client) queryObjectsApiDirect(ctx context.Context, objType, objNam
130
130
map [string ]string {"Accept" : "application/json" })
131
131
}
132
132
133
+ // fetchIcingaAppStatus retrieves the global state of the IcingaApplication type via the /v1/status endpoint.
134
+ func (client * Client ) fetchIcingaAppStatus (ctx context.Context ) (* IcingaAppStatus , error ) {
135
+ response , err := client .queryObjectsApi (
136
+ ctx ,
137
+ []string {"/v1/status/IcingaApplication/" },
138
+ http .MethodGet ,
139
+ nil ,
140
+ map [string ]string {"Accept" : "application/json" })
141
+ if err != nil {
142
+ return nil , err
143
+ }
144
+
145
+ defer func () {
146
+ _ , _ = io .Copy (io .Discard , response )
147
+ _ = response .Close ()
148
+ }()
149
+
150
+ status := new (IcingaAppStatus )
151
+ if err := json .NewDecoder (response ).Decode (status ); err != nil {
152
+ return nil , err
153
+ }
154
+
155
+ return status , nil
156
+ }
157
+
133
158
// queryObjectsApiQuery sends a query to the Icinga 2 API /v1/objects to receive data of the given objType.
134
159
func (client * Client ) queryObjectsApiQuery (ctx context.Context , objType string , query map [string ]any ) (io.ReadCloser , error ) {
135
160
reqBody , err := json .Marshal (query )
@@ -260,6 +285,11 @@ func (client *Client) checkMissedChanges(ctx context.Context, objType string, ca
260
285
}
261
286
262
287
attrs := objQueriesResult .Attrs
288
+ checkableIsMuted , err := isMuted (ctx , client , & objQueriesResult )
289
+ if err != nil {
290
+ return err
291
+ }
292
+
263
293
var fakeEv * event.Event
264
294
if attrs .Acknowledgement != AcknowledgementNone {
265
295
ackComment , err := client .fetchAcknowledgementComment (ctx , hostName , serviceName , attrs .AcknowledgementLastChange .Time ())
@@ -275,17 +305,17 @@ func (client *Client) checkMissedChanges(ctx context.Context, objType string, ca
275
305
if err != nil {
276
306
return fmt .Errorf ("failed to construct Event from Acknowledgement response, %w" , err )
277
307
}
278
- } else if isMuted ( & objQueriesResult ) {
308
+ } else if checkableIsMuted {
279
309
fakeEv , err = client .buildCommonEvent (ctx , hostName , serviceName )
280
310
if err != nil {
281
311
return fmt .Errorf ("failed to construct checkable fake mute event: %w" , err )
282
312
}
283
313
284
314
fakeEv .Type = event .TypeMute
285
- if attrs .IsFlapping {
286
- fakeEv .SetMute (true , "Checkable is flapping, but we missed the Icinga 2 FlappingStart event" )
287
- } else {
315
+ if attrs .DowntimeDepth != 0 {
288
316
fakeEv .SetMute (true , "Checkable is in downtime, but we missed the Icinga 2 DowntimeStart event" )
317
+ } else {
318
+ fakeEv .SetMute (true , "Checkable is flapping, but we missed the Icinga 2 FlappingStart event" )
289
319
}
290
320
} else {
291
321
// This could potentially produce numerous superfluous database (event table) entries if we generate such
0 commit comments