ctop/connector/collector/main.go

22 lines
320 B
Go
Raw Normal View History

2017-06-12 14:12:03 +00:00
package collector
import (
"math"
"github.com/bcicen/ctop/logging"
)
var log = logging.Init()
func round(num float64) int {
return int(num + math.Copysign(0.5, num))
}
// return rounded percentage
func percent(val float64, total float64) int {
if total <= 0 {
return 0
}
return round((val / total) * 100)
}