diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:08:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:08:18 +0000 |
commit | 5da14042f70711ea5cf66e034699730335462f66 (patch) | |
tree | 0f6354ccac934ed87a2d555f45be4c831cf92f4a /src/go/collectors/go.d.plugin/modules/windows/collect_cpu.go | |
parent | Releasing debian version 1.44.3-2. (diff) | |
download | netdata-5da14042f70711ea5cf66e034699730335462f66.tar.xz netdata-5da14042f70711ea5cf66e034699730335462f66.zip |
Merging upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/windows/collect_cpu.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/windows/collect_cpu.go | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/windows/collect_cpu.go b/src/go/collectors/go.d.plugin/modules/windows/collect_cpu.go new file mode 100644 index 000000000..fc1412e3d --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/windows/collect_cpu.go @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package windows + +import ( + "github.com/netdata/netdata/go/go.d.plugin/pkg/prometheus" +) + +const ( + metricCPUTimeTotal = "windows_cpu_time_total" + metricCPUInterruptsTotal = "windows_cpu_interrupts_total" + metricCPUDPCsTotal = "windows_cpu_dpcs_total" + metricCPUCStateTotal = "windows_cpu_cstate_seconds_total" +) + +func (w *Windows) collectCPU(mx map[string]int64, pms prometheus.Series) { + if !w.cache.collection[collectorCPU] { + w.cache.collection[collectorCPU] = true + w.addCPUCharts() + } + + seen := make(map[string]bool) + for _, pm := range pms.FindByName(metricCPUTimeTotal) { + core := pm.Labels.Get("core") + mode := pm.Labels.Get("mode") + if core == "" || mode == "" { + continue + } + + seen[core] = true + mx["cpu_"+mode+"_time"] += int64(pm.Value * precision) + mx["cpu_core_"+core+"_"+mode+"_time"] += int64(pm.Value * precision) + } + + for _, pm := range pms.FindByName(metricCPUInterruptsTotal) { + core := pm.Labels.Get("core") + if core == "" { + continue + } + + seen[core] = true + mx["cpu_core_"+core+"_interrupts"] += int64(pm.Value) + } + + for _, pm := range pms.FindByName(metricCPUDPCsTotal) { + core := pm.Labels.Get("core") + if core == "" { + continue + } + + seen[core] = true + mx["cpu_core_"+core+"_dpcs"] += int64(pm.Value) + } + + for _, pm := range pms.FindByName(metricCPUCStateTotal) { + core := pm.Labels.Get("core") + state := pm.Labels.Get("state") + if core == "" || state == "" { + continue + } + + seen[core] = true + mx["cpu_core_"+core+"_cstate_"+state] += int64(pm.Value * precision) + } + + for core := range seen { + if !w.cache.cores[core] { + w.cache.cores[core] = true + w.addCPUCoreCharts(core) + } + } + for core := range w.cache.cores { + if !seen[core] { + delete(w.cache.cores, core) + w.removeCPUCoreCharts(core) + } + } +} |