2017-02-23 02:03:55 +00:00
|
|
|
package metrics
|
2017-01-20 12:41:26 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
2017-02-23 02:24:26 +00:00
|
|
|
|
|
|
|
"github.com/bcicen/ctop/logging"
|
2017-01-20 12:41:26 +00:00
|
|
|
)
|
|
|
|
|
2017-02-23 02:24:26 +00:00
|
|
|
var log = logging.Init()
|
|
|
|
|
2017-01-20 12:41:26 +00:00
|
|
|
type Metrics struct {
|
|
|
|
CPUUtil int
|
|
|
|
NetTx int64
|
|
|
|
NetRx int64
|
|
|
|
MemLimit int64
|
|
|
|
MemPercent int
|
|
|
|
MemUsage int64
|
|
|
|
}
|
|
|
|
|
2017-02-28 23:23:24 +00:00
|
|
|
func NewMetrics() Metrics {
|
|
|
|
return Metrics{
|
2017-03-07 00:02:40 +00:00
|
|
|
CPUUtil: -1,
|
|
|
|
NetTx: -1,
|
|
|
|
NetRx: -1,
|
|
|
|
MemUsage: -1,
|
|
|
|
MemPercent: -1,
|
2017-02-28 23:23:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-20 12:41:26 +00:00
|
|
|
type Collector interface {
|
|
|
|
Stream() chan Metrics
|
2017-02-02 07:09:43 +00:00
|
|
|
Running() bool
|
|
|
|
Start()
|
2017-01-20 12:41:26 +00:00
|
|
|
Stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
func round(num float64) int {
|
|
|
|
return int(num + math.Copysign(0.5, num))
|
|
|
|
}
|