diff --git a/plugins/system/cpu.go b/plugins/system/cpu.go index 081a8ac73..d0b80bcc8 100644 --- a/plugins/system/cpu.go +++ b/plugins/system/cpu.go @@ -78,10 +78,9 @@ func (s *CPUStats) Gather(acc plugins.Accumulator) error { continue } - usage_idle := 100 * (cts.Idle - lastCts.Idle) / totalDelta add(acc, "usage_user", 100*(cts.User-lastCts.User)/totalDelta, tags) add(acc, "usage_system", 100*(cts.System-lastCts.System)/totalDelta, tags) - add(acc, "usage_idle", usage_idle, tags) + add(acc, "usage_idle", 100*(cts.Idle-lastCts.Idle)/totalDelta, tags) add(acc, "usage_nice", 100*(cts.Nice-lastCts.Nice)/totalDelta, tags) add(acc, "usage_iowait", 100*(cts.Iowait-lastCts.Iowait)/totalDelta, tags) add(acc, "usage_irq", 100*(cts.Irq-lastCts.Irq)/totalDelta, tags) @@ -89,7 +88,6 @@ func (s *CPUStats) Gather(acc plugins.Accumulator) error { add(acc, "usage_steal", 100*(cts.Steal-lastCts.Steal)/totalDelta, tags) add(acc, "usage_guest", 100*(cts.Guest-lastCts.Guest)/totalDelta, tags) add(acc, "usage_guest_nice", 100*(cts.GuestNice-lastCts.GuestNice)/totalDelta, tags) - add(acc, "usage_busy", 100.0-usage_idle, tags) } diff --git a/plugins/system/system_test.go b/plugins/system/system_test.go index 62f2e264d..c16f2e27b 100644 --- a/plugins/system/system_test.go +++ b/plugins/system/system_test.go @@ -153,7 +153,7 @@ func TestSystemStats_GenerateStats(t *testing.T) { require.NoError(t, err) numCPUPoints = len(acc.Points) - (preCPUPoints + numCPUPoints) - expectedCPUPoints = 21 + expectedCPUPoints = 20 assert.Equal(t, numCPUPoints, expectedCPUPoints) assertContainsTaggedFloat(t, acc, "user", 11.4, 0, cputags) @@ -177,7 +177,6 @@ func TestSystemStats_GenerateStats(t *testing.T) { assertContainsTaggedFloat(t, acc, "usage_steal", 0.2301, 0.0005, cputags) assertContainsTaggedFloat(t, acc, "usage_guest", 4.8, 0.0005, cputags) assertContainsTaggedFloat(t, acc, "usage_guest_nice", 2.2, 0.0005, cputags) - assertContainsTaggedFloat(t, acc, "usage_busy", 21.2301, 0.0005, cputags) err = (&DiskStats{&mps}).Gather(&acc) require.NoError(t, err)