value check to avoid zero division error.

pull/26/head
Shirou WAKAYAMA 10 years ago
parent 7be5e618bc
commit 6adc13e592

@ -57,6 +57,9 @@ func CPUPercent(interval time.Duration, percpu bool) ([]float32, error) {
if t2Busy <= t1Busy {
return 0
}
if t2All <= t1All {
return 1
}
return (t2Busy - t1Busy) / (t2All - t1All) * 100
}

Loading…
Cancel
Save