reg/vendor/github.com/docker/docker-ce/components/engine/daemon/stats_collector.go
Jess Frazelle 8e5eba8735
switch to dep
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
2017-12-11 14:50:55 -05:00

27 lines
736 B
Go

package daemon
import (
"runtime"
"time"
"github.com/docker/docker/daemon/stats"
"github.com/docker/docker/pkg/system"
)
// 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.
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)
}
}
s := stats.NewCollector(daemon, interval)
go s.Run()
return s
}