mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
36 lines
534 B
Go
36 lines
534 B
Go
package collector
|
|
|
|
import (
|
|
"math"
|
|
|
|
"github.com/bcicen/ctop/logging"
|
|
"github.com/bcicen/ctop/models"
|
|
)
|
|
|
|
var log = logging.Init()
|
|
|
|
type LogCollector interface {
|
|
Stream() chan models.Log
|
|
Stop()
|
|
}
|
|
|
|
type Collector interface {
|
|
Stream() chan models.Metrics
|
|
Logs() LogCollector
|
|
Running() bool
|
|
Start()
|
|
Stop()
|
|
}
|
|
|
|
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)
|
|
}
|