vmware: refactor collector (#1727)

This commit is contained in:
Jan-Otto Kröpke
2024-11-12 23:16:22 +01:00
committed by GitHub
parent eeb7955f5e
commit b53f18bcc6
6 changed files with 228 additions and 209 deletions

View File

@@ -4,6 +4,8 @@ import "github.com/prometheus/client_golang/prometheus"
const EmptyInstance = "------"
var TotalInstance = []string{"_Total"}
type CounterValues struct {
Type prometheus.ValueType
FirstValue float64

View File

@@ -166,10 +166,12 @@ func (c *Collector) Collect() (map[string]map[string]perftypes.CounterValues, er
metricType = prometheus.GaugeValue
}
_, isTotalCounterRequests := c.counters["_Total"]
for _, item := range items {
if item.RawValue.CStatus == PdhCstatusValidData || item.RawValue.CStatus == PdhCstatusNewData {
instanceName := windows.UTF16PtrToString(item.SzName)
if strings.HasSuffix(instanceName, "_Total") {
if strings.HasSuffix(instanceName, "_Total") && !isTotalCounterRequests {
continue
}