fix: windows_cpu_processor_utility_total is always 0 (#1966)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2025-04-05 22:20:07 +02:00
committed by GitHub
parent ef46cd1dbe
commit 9db4318ea9
4 changed files with 30 additions and 13 deletions

View File

@@ -122,6 +122,11 @@ func NewCollectorWithReflection(resultType CounterType, object string, instances
continue
}
secondValue := strings.HasSuffix(counterName, ",secondvalue")
if secondValue {
counterName = strings.TrimSuffix(counterName, ",secondvalue")
}
var counter Counter
if counter, ok = collector.counters[counterName]; !ok {
counter = Counter{
@@ -132,9 +137,7 @@ func NewCollectorWithReflection(resultType CounterType, object string, instances
}
}
if strings.HasSuffix(counterName, ",secondvalue") {
counterName = strings.TrimSuffix(counterName, ",secondvalue")
if secondValue {
counter.FieldIndexSecondValue = f.Index[0]
} else {
counter.FieldIndexValue = f.Index[0]
@@ -206,9 +209,6 @@ func NewCollectorWithReflection(resultType CounterType, object string, instances
}
counter.Type = counterInfo.DwType
counter.Desc = windows.UTF16PtrToString(counterInfo.SzExplainText)
counter.Desc = windows.UTF16PtrToString(counterInfo.SzExplainText)
if val, ok := SupportedCounterTypes[counter.Type]; ok {
counter.MetricType = val
} else {