Closed hweidner closed 6 months ago
thanks, i reworked the type assertions completely in d852c14f8b28b74b5b11e1908e5534fa3eca4bb3. At least it should not crash with the next update.
LMD v2.2.0 still crashes in peer.go:2295 with an index out of bounds error when displaying the Checkmk "Alert statistics" view.
The following patch fixes this:
diff --git a/pkg/lmd/peer.go b/pkg/lmd/peer.go
index b3668fc..882b261 100644
--- a/pkg/lmd/peer.go
+++ b/pkg/lmd/peer.go
@@ -2292,7 +2292,9 @@ func (p *Peer) PassThroughQuery(ctx context.Context, res *Response, passthroughR
if len(result) > 0 {
for i := range result[0] {
val := interface2float64(result[0][i])
- res.Request.StatsResult.Stats[""][i].ApplyValue(val, int(val))
+ if len(res.Request.StatsResult.Stats[""]) > i {
+ res.Request.StatsResult.Stats[""][i].ApplyValue(val, int(val))
+ }
}
}
}
i see, i guess that's because the number of actual columns is different than the number of requested columns with stats queries.
should be fine now.
Setup
Checkmk Enterprise 2.1 Central Site -> LMD -> 8 Checkmk Enterprise 2.1 Remote Sites
Problem
When displaying the "Alert statistics" view in the CMK Central Site, the LMD panics and terminates with "interface conversion: interface {} is string, not float64".
Analysis
The erroneous code is the type assertion
result[0][i].(float64)
in lmd/peer.go:2210. When safeguarding this line by using a conditional type assertion, an index out of bound error appears in the following line.With the following patch, the CMK view still does not display sensible contents, but the LMD crash can be avoided: