diff --git a/cmd/agent/gui/views/templates/collectorStatus.tmpl b/cmd/agent/gui/views/templates/collectorStatus.tmpl index 0d067b62ec13e..3c48e023d9f63 100644 --- a/cmd/agent/gui/views/templates/collectorStatus.tmpl +++ b/cmd/agent/gui/views/templates/collectorStatus.tmpl @@ -40,10 +40,10 @@ Average Execution Time : {{humanizeDuration .AverageExecutionTime "ms"}}
Last Execution Date : {{formatUnixTime .UpdateTimestamp}}
Last Successful Execution Date : {{ if .LastSuccessDate }}{{formatUnixTime .LastSuccessDate}}{{ else }}Never{{ end }}
- {{- if index $.Stats.inventories .CheckID }} + {{- if index $.Stats.checkMetadata .CheckID }} Metadata:
- {{- range $k, $v := index $.Stats.inventories .CheckID }} + {{- range $k, $v := index $.Stats.checkMetadata .CheckID }} {{ $k }}: {{ $v }}
{{- end }}
diff --git a/pkg/status/collector/collector.go b/pkg/status/collector/collector.go index 9bd607334465b..275c6eaf7c237 100644 --- a/pkg/status/collector/collector.go +++ b/pkg/status/collector/collector.go @@ -85,7 +85,7 @@ func GetStatus() map[string]interface{} { } } } - stats["inventories"] = checkMetadata + stats["checkMetadata"] = checkMetadata if data, ok := inventoriesStats["agent_metadata"]; ok { stats["agent_metadata"] = data } else { diff --git a/pkg/status/render.go b/pkg/status/render.go index b58fd4345a3ae..7cbb3766120c4 100644 --- a/pkg/status/render.go +++ b/pkg/status/render.go @@ -36,11 +36,7 @@ func FormatStatus(data []byte) (string, error) { } else { log.Warn("The Forwarder status format is invalid. Some parts of the `Forwarder` section may be missing.") } - runnerStats := stats["runnerStats"] - pyLoaderStats := stats["pyLoaderStats"] - pythonInit := stats["pythonInit"] - autoConfigStats := stats["autoConfigStats"] - checkSchedulerStats := stats["checkSchedulerStats"] + aggregatorStats := stats["aggregatorStats"] s, err := checkstats.TranslateEventPlatformEventTypes(aggregatorStats) if err != nil { @@ -52,7 +48,6 @@ func FormatStatus(data []byte) (string, error) { logsStats := stats["logsStats"] dcaStats := stats["clusterAgentStatus"] endpointsInfos := stats["endpointsInfos"] - inventoriesStats := stats["inventories"] systemProbeStats := stats["systemProbeStats"] processAgentStatus := stats["processAgentStatus"] snmpTrapsStats := stats["snmpTrapsStats"] @@ -63,7 +58,7 @@ func FormatStatus(data []byte) (string, error) { var b = new(bytes.Buffer) headerFunc := func() error { return RenderStatusTemplate(b, "/header.tmpl", stats) } checkStatsFunc := func() error { - return renderChecksStats(b, runnerStats, pyLoaderStats, pythonInit, autoConfigStats, checkSchedulerStats, inventoriesStats, "") + return RenderStatusTemplate(b, "/collector.tmpl", stats) } jmxFetchFunc := func() error { return RenderStatusTemplate(b, "/jmxfetch.tmpl", stats) } forwarderFunc := func() error { return RenderStatusTemplate(b, "/forwarder.tmpl", forwarderStats) } @@ -146,9 +141,11 @@ func FormatDCAStatus(data []byte) (string, error) { } forwarderStats := stats["forwarderStats"] - runnerStats := stats["runnerStats"] - autoConfigStats := stats["autoConfigStats"] - checkSchedulerStats := stats["checkSchedulerStats"] + + stats["pyLoaderStats"] = nil + stats["pythonInit"] = nil + stats["checkMetadata"] = nil + endpointsInfos := stats["endpointsInfos"] logsStats := stats["logsStats"] orchestratorStats := stats["orchestrator"] @@ -160,7 +157,7 @@ func FormatDCAStatus(data []byte) (string, error) { if err := RenderStatusTemplate(b, "/header.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderChecksStats(b, runnerStats, nil, nil, autoConfigStats, checkSchedulerStats, nil, ""); err != nil { + if err := renderChecksStats(b, stats); err != nil { errs = append(errs, err) } if err := RenderStatusTemplate(b, "/forwarder.tmpl", forwarderStats); err != nil { @@ -271,16 +268,8 @@ func FormatMetadataMapCLI(data []byte) (string, error) { return b.String(), nil } -func renderChecksStats(w io.Writer, runnerStats, pyLoaderStats, pythonInit, autoConfigStats, checkSchedulerStats, inventoriesStats interface{}, onlyCheck string) error { - checkStats := make(map[string]interface{}) - checkStats["RunnerStats"] = runnerStats - checkStats["pyLoaderStats"] = pyLoaderStats - checkStats["pythonInit"] = pythonInit - checkStats["AutoConfigStats"] = autoConfigStats - checkStats["CheckSchedulerStats"] = checkSchedulerStats - checkStats["OnlyCheck"] = onlyCheck - checkStats["CheckMetadata"] = inventoriesStats - return RenderStatusTemplate(w, "/collector.tmpl", checkStats) +func renderChecksStats(w io.Writer, stats map[string]interface{}) error { + return RenderStatusTemplate(w, "/collector.tmpl", stats) } func renderCheckStats(data []byte, checkName string) (string, error) { @@ -288,15 +277,10 @@ func renderCheckStats(data []byte, checkName string) (string, error) { if renderError != "" || err != nil { return renderError, err } - runnerStats := stats["runnerStats"] - pyLoaderStats := stats["pyLoaderStats"] - pythonInit := stats["pythonInit"] - autoConfigStats := stats["autoConfigStats"] - checkSchedulerStats := stats["checkSchedulerStats"] - inventoriesStats := stats["inventories"] + var b = new(bytes.Buffer) var errs []error - if err := renderChecksStats(b, runnerStats, pyLoaderStats, pythonInit, autoConfigStats, checkSchedulerStats, inventoriesStats, checkName); err != nil { + if err := RenderStatusTemplate(b, "/collector.tmpl", stats); err != nil { errs = append(errs, err) } if err := renderErrors(b, errs); err != nil { diff --git a/pkg/status/templates/collector.tmpl b/pkg/status/templates/collector.tmpl index 056b2f49323d5..d7a7f58537cb0 100644 --- a/pkg/status/templates/collector.tmpl +++ b/pkg/status/templates/collector.tmpl @@ -18,7 +18,7 @@ Collector Running Checks ============== -{{- with .RunnerStats }} +{{- with .runnerStats }} {{- if and (not .Runs) (not .Checks)}} No checks have run yet {{end -}} @@ -93,7 +93,7 @@ Collector {{- end }} {{- end }} -{{- with .AutoConfigStats }} +{{- with .autoConfigStats }} {{- if .ConfigErrors}} Config Errors ============== @@ -105,7 +105,7 @@ Collector {{- end}} {{- end }} -{{- with .CheckSchedulerStats }} +{{- with .checkSchedulerStats }} {{- if .LoaderErrors}} Loading Errors ==============