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

Method Stat

cgroup1/cpu.go:102–125  ·  view source on GitHub ↗
(path string, stats *v1.Metrics)

Source from the content-addressed store, hash-verified

100}
101
102func (c *cpuController) Stat(path string, stats *v1.Metrics) error {
103 f, err := os.Open(filepath.Join(c.Path(path), "cpu.stat"))
104 if err != nil {
105 return err
106 }
107 defer f.Close()
108 // get or create the cpu field because cpuacct can also set values on this struct
109 sc := bufio.NewScanner(f)
110 for sc.Scan() {
111 key, v, err := parseKV(sc.Text())
112 if err != nil {
113 return err
114 }
115 switch key {
116 case "nr_periods":
117 stats.CPU.Throttling.Periods = v
118 case "nr_throttled":
119 stats.CPU.Throttling.ThrottledPeriods = v
120 case "throttled_time":
121 stats.CPU.Throttling.ThrottledTime = v
122 }
123 }
124 return sc.Err()
125}

Callers

nothing calls this directly

Calls 2

PathMethod · 0.95
parseKVFunction · 0.70

Tested by

no test coverage detected