MCPcopy Create free account
hub / github.com/containerd/cgroups / readCPUStats

Function readCPUStats

cgroup2/manager.go:638–657  ·  view source on GitHub ↗
(cgroupPath string)

Source from the content-addressed store, hash-verified

636}
637
638func readCPUStats(cgroupPath string) (*stats.CPUStat, error) {
639 cpuStat := make(map[string]uint64)
640 if err := readKVStatsFile(cgroupPath, "cpu.stat", cpuStat); err != nil {
641 if os.IsNotExist(err) {
642 return &stats.CPUStat{}, nil
643 }
644 return nil, err
645 }
646 return &stats.CPUStat{
647 UsageUsec: cpuStat["usage_usec"],
648 UserUsec: cpuStat["user_usec"],
649 SystemUsec: cpuStat["system_usec"],
650 NrPeriods: cpuStat["nr_periods"],
651 NrThrottled: cpuStat["nr_throttled"],
652 ThrottledUsec: cpuStat["throttled_usec"],
653 NrBursts: cpuStat["nr_bursts"],
654 BurstUsec: cpuStat["burst_usec"],
655 PSI: getStatPSIFromFile(filepath.Join(cgroupPath, "cpu.pressure")),
656 }, nil
657}
658
659func readMemoryStats(cgroupPath string) (*stats.MemoryStat, error) {
660 memoryStat := make(map[string]uint64, 40)

Callers 1

StatFilteredMethod · 0.85

Calls 2

readKVStatsFileFunction · 0.85
getStatPSIFromFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…