2016-09-07 23:08:51 +00:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
2017-01-04 17:01:59 +00:00
|
|
|
"runtime"
|
2016-09-07 23:08:51 +00:00
|
|
|
"time"
|
|
|
|
|
2017-01-04 17:01:59 +00:00
|
|
|
"github.com/docker/docker/daemon/stats"
|
|
|
|
"github.com/docker/docker/pkg/system"
|
2016-09-07 23:08:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// newStatsCollector returns a new statsCollector that collections
|
|
|
|
// stats for a registered container at the specified interval.
|
|
|
|
// The collector allows non-running containers to be added
|
|
|
|
// and will start processing stats when they are started.
|
2017-01-04 17:01:59 +00:00
|
|
|
func (daemon *Daemon) newStatsCollector(interval time.Duration) *stats.Collector {
|
|
|
|
// FIXME(vdemeester) move this elsewhere
|
|
|
|
if runtime.GOOS == "linux" {
|
|
|
|
meminfo, err := system.ReadMemInfo()
|
|
|
|
if err == nil && meminfo.MemTotal > 0 {
|
|
|
|
daemon.machineMemory = uint64(meminfo.MemTotal)
|
2016-09-07 23:08:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-04 17:01:59 +00:00
|
|
|
s := stats.NewCollector(daemon, interval)
|
|
|
|
go s.Run()
|
|
|
|
return s
|
2016-09-07 23:08:51 +00:00
|
|
|
}
|