Skip to content

Commit

Permalink
inventories: expvar could not be published if the feature is disabled (
Browse files Browse the repository at this point in the history
…#4529)

The expvar is also not published immediately at startup, it was also
a bug if the status was called early in the Agent startup.
  • Loading branch information
remeh authored Nov 29, 2019
1 parent 94e41a6 commit 4b6b2e5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,12 @@ func expvarStats(stats map[string]interface{}) (map[string]interface{}, error) {
stats["ntpOffset"], err = strconv.ParseFloat(expvar.Get("ntpOffset").String(), 64)
}

inventoriesStatsJSON := []byte(expvar.Get("inventories").String())
inventoriesStats := make(map[string]interface{})
json.Unmarshal(inventoriesStatsJSON, &inventoriesStats)
inventories := expvar.Get("inventories")
var inventoriesStats map[string]interface{}
if inventories != nil {
inventoriesStatsJSON := []byte(inventories.String())
json.Unmarshal(inventoriesStatsJSON, &inventoriesStats)
}

checkMetadata := map[string]map[string]string{}
if data, ok := inventoriesStats["check_metadata"]; ok {
Expand Down

0 comments on commit 4b6b2e5

Please sign in to comment.