- for {
- /*{
- c, _ := os.Open(cpuacct_usage)
- b, _ := ioutil.ReadAll(c)
- var next int64
- fmt.Sscanf(string(b), "%d", &next)
- if last_usage != 0 {
- stderr <- fmt.Sprintf("crunchstat: cpuacct.usage %v", (next-last_usage)/10000000)
- }
- //fmt.Printf("usage %d %d %d %d%%\n", last_usage, next, next-last_usage, (next-last_usage)/10000000)
- last_usage = next
- c.Close()
- }*/
- var cpus int64 = 0
- if cpuset_cpus != "" {
- c, _ := os.Open(cpuset_cpus)
- b, _ := ioutil.ReadAll(c)
- sp := strings.Split(string(b), ",")
- for _, v := range sp {
- var min, max int64
- n, _ := fmt.Sscanf(v, "%d-%d", &min, &max)
- if n == 2 {
- cpus += (max - min) + 1
- } else {
- cpus += 1
- }
- }
-
- if cpus != last_cpucount {
- stderr <- fmt.Sprintf("crunchstat: cpuset.cpus %v", cpus)
- }
- last_cpucount = cpus
-
- c.Close()
- }
- if cpus == 0 {
- cpus = 1
- }
- if cpuacct_stat != "" {
- c, _ := os.Open(cpuacct_stat)
- b, _ := ioutil.ReadAll(c)
- var next_user int64
- var next_sys int64
- fmt.Sscanf(string(b), "user %d\nsystem %d", &next_user, &next_sys)
- c.Close()
-
- if last_user != 0 {
- user_diff := next_user - last_user
- sys_diff := next_sys - last_sys
- // Assume we're reading stats based on 100
- // jiffies per second. Because the elapsed
- // time is in milliseconds, we need to boost
- // that to 1000 jiffies per second, then boost
- // it by another 100x to get a percentage, then
- // finally divide by the actual elapsed time
- // and the number of cpus to get average load
- // over the polling period.
- user_pct := (user_diff * 10 * 100) / (elapsed * cpus)
- sys_pct := (sys_diff * 10 * 100) / (elapsed * cpus)
+ if reporter.CgroupRoot == "" {
+ reporter.Logger.Fatal("error: must provide -cgroup-root")
+ } else if signalOnDeadPPID < 0 {
+ reporter.Logger.Fatalf("-signal-on-dead-ppid=%d is invalid (use a positive signal number, or 0 to disable)", signalOnDeadPPID)
+ }
+ reporter.PollPeriod = time.Duration(*pollMsec) * time.Millisecond