1package daemon // import "github.com/docker/docker/daemon"
2
3import (
4	"runtime"
5	"time"
6
7	"github.com/docker/docker/daemon/stats"
8	"github.com/docker/docker/pkg/system"
9)
10
11// newStatsCollector returns a new statsCollector that collections
12// stats for a registered container at the specified interval.
13// The collector allows non-running containers to be added
14// and will start processing stats when they are started.
15func (daemon *Daemon) newStatsCollector(interval time.Duration) *stats.Collector {
16	// FIXME(vdemeester) move this elsewhere
17	if runtime.GOOS == "linux" {
18		meminfo, err := system.ReadMemInfo()
19		if err == nil && meminfo.MemTotal > 0 {
20			daemon.machineMemory = uint64(meminfo.MemTotal)
21		}
22	}
23	s := stats.NewCollector(daemon, interval)
24	go s.Run()
25	return s
26}
27