diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2024-02-13 06:56:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-13 06:56:20 -0500 |
commit | 3a29b66132f561c910d827e8c7ae82997f7c1f30 (patch) | |
tree | a9306156631b6b188de8877f7c1dbdbe8b067804 /src/go/collectors/go.d.plugin/modules/windows/collect_collector.go | |
parent | 57eec3da0e51baa400037ccc4b547cb839ab6ffa (diff) |
Include Go plugin sources in main repository. (#16997)
* Include Go plugin sources in main repository.
* Fix CI issues.
* Rename source tree.
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/windows/collect_collector.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/windows/collect_collector.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/windows/collect_collector.go b/src/go/collectors/go.d.plugin/modules/windows/collect_collector.go new file mode 100644 index 0000000000..1faf7d703e --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/windows/collect_collector.go @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package windows + +import ( + "github.com/netdata/go.d.plugin/pkg/prometheus" +) + +const ( + metricCollectorDuration = "windows_exporter_collector_duration_seconds" + metricCollectorSuccess = "windows_exporter_collector_success" +) + +func (w *Windows) collectCollector(mx map[string]int64, pms prometheus.Series) { + seen := make(map[string]bool) + px := "collector_" + for _, pm := range pms.FindByName(metricCollectorDuration) { + if name := pm.Labels.Get("collector"); name != "" { + seen[name] = true + mx[px+name+"_duration"] = int64(pm.Value * precision) + } + } + for _, pm := range pms.FindByName(metricCollectorSuccess) { + if name := pm.Labels.Get("collector"); name != "" { + seen[name] = true + if pm.Value == 1 { + mx[px+name+"_status_success"], mx[px+name+"_status_fail"] = 1, 0 + } else { + mx[px+name+"_status_success"], mx[px+name+"_status_fail"] = 0, 1 + } + } + } + + for name := range seen { + if !w.cache.collectors[name] { + w.cache.collectors[name] = true + w.addCollectorCharts(name) + } + } + for name := range w.cache.collectors { + if !seen[name] { + delete(w.cache.collectors, name) + w.removeCollectorCharts(name) + } + } +} |