func cpuStat()

in cgroup/cpu.go [75:104]


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 := parseCgroupParamKeyValue(sc.Text())
		if err != nil {
			return err
		}
		switch t {
		case "nr_periods":
			cpu.Stats.Periods = v

		case "nr_throttled":
			cpu.Stats.ThrottledPeriods = v

		case "throttled_time":
			cpu.Stats.ThrottledTimeNanos = v
		}
	}

	return sc.Err()
}