Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
Cap overalPct at 100% to avoid wrong values (#21)
Browse files Browse the repository at this point in the history
* Cap overalPct at 100% to avoid wrong values
  • Loading branch information
marc921 authored Jul 24, 2017
1 parent a1c15a9 commit 60b0047
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions checks/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ func calculatePct(deltaProc, deltaTime, numCPU float64) float32 {
// on a 2-CPU-core system would be reported as 50% instead of 100%.
overalPct := (deltaProc / deltaTime) * 100

// Sometimes we get values that don't make sense, so we clamp to 100%
if overalPct > 100 {
overalPct = 100
}

// In order to emulate top we multiply utilization by # of CPUs so a busy loop would be 100%.
return float32(overalPct * numCPU)
}

0 comments on commit 60b0047

Please sign in to comment.