1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/stats_collector.go
Daniel Nephin 4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00

26 lines
780 B
Go

package daemon // import "github.com/docker/docker/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
}