in metric/system/cgroup/cgv1/cpu.go [100:129]
func cpuStat(path string, cpu *CPUSubsystem) error {
f, err := os.Open(filepath.Join(path, "cpu.stat"))
if err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
defer f.Close()
sc := bufio.NewScanner(f)
for sc.Scan() {
t, v, err := cgcommon.ParseCgroupParamKeyValue(sc.Text())
if err != nil {
return err
}
switch t {
case "nr_periods":
cpu.Stats.Periods = v
case "nr_throttled":
cpu.Stats.Throttled.Periods = v
case "throttled_time":
cpu.Stats.Throttled.Us = v
}
}
return sc.Err()
}