refactor collectors into subpackage

This commit is contained in:
Bradley Cicenas
2017-06-12 14:12:03 +00:00
parent 671c944272
commit 1be452d7c0
9 changed files with 50 additions and 45 deletions

View File

@@ -0,0 +1,21 @@
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)
}