fix win cpu usage stats issue
@@ -18,9 +18,10 @@ func (s *CPUStats) Collect() (datas []map[string]interface{}, err error) {
}
for _, cts := range times {
-
- // windows cpu time stat only for total
- if s.CollectCPUTime && isTotalCpuTimeStat(cts.CPU) {
+ // cpu time stats
+ // if s.TotalCPU == true CPUTimes() return cpu time count stats and only for cpu-total
+ if isTotalCpuTimeStat(cts.CPU) {
+ if s.CollectCPUTime {
// Add cpu time metrics
fieldsC := map[string]interface{}{
CpuTimeUser: cts.User,
@@ -36,8 +37,11 @@ func (s *CPUStats) Collect() (datas []map[string]interface{}, err error) {
CpuTimeCPU: cts.CPU,
}
datas = append(datas, fieldsC)
+ }
continue
}
+ // cpu usage stats
+ // if s.PerCPU == true CPUTimes() return cpu usage pct stats and for all cpu core
// merge "_Total" to "cpu_total"
if isTotalCpuUsageStat(cts.CPU) {
cts.CPU = MetricCPUTotalKey
