Files
moby/daemon/stats_collector.go
Derek McGowan f74e5d48b3 Create github.com/moby/moby/v2 module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-31 10:13:29 -07:00

27 lines
729 B
Go

package daemon
import (
"runtime"
"time"
"github.com/moby/moby/v2/daemon/stats"
"github.com/moby/moby/v2/pkg/meminfo"
)
// 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 := meminfo.Read()
if err == nil && meminfo.MemTotal > 0 {
daemon.machineMemory = uint64(meminfo.MemTotal)
}
}
s := stats.NewCollector(daemon, interval)
go s.Run()
return s
}