diff --git a/collectors/cpustatMetric.go b/collectors/cpustatMetric.go index bd6ec2f..2b1756f 100644 --- a/collectors/cpustatMetric.go +++ b/collectors/cpustatMetric.go @@ -119,12 +119,21 @@ func (m *CpustatCollector) parseStatLine(linefields []string, tags map[string]st } } + sum := float64(0) for name, value := range values { + sum += value y, err := lp.New(name, tags, m.meta, map[string]interface{}{"value": value * 100}, now) if err == nil { output <- y } } + if v, ok := values["cpu_idle"]; ok { + sum -= v + y, err := lp.New("cpu_used", tags, m.meta, map[string]interface{}{"value": sum * 100}, now) + if err == nil { + output <- y + } + } } func (m *CpustatCollector) Read(interval time.Duration, output chan lp.CCMetric) { diff --git a/collectors/cpustatMetric.md b/collectors/cpustatMetric.md index 8963536..d160410 100644 --- a/collectors/cpustatMetric.md +++ b/collectors/cpustatMetric.md @@ -23,3 +23,4 @@ Metrics: * `cpu_steal` * `cpu_guest` * `cpu_guest_nice` +* `cpu_used` = `cpu_* - cpu_idle` \ No newline at end of file