diff --git a/fs/cpuacct.go b/fs/cpuacct.go index 391a023..dd5d7c9 100644 --- a/fs/cpuacct.go +++ b/fs/cpuacct.go @@ -133,7 +133,10 @@ func getPercpuUsageInModes(path string) ([]uint64, []uint64, error) { for scanner.Scan() { // Each line is: cpu user system - fields := strings.SplitN(scanner.Text(), " ", 3) + // Keep 'n' at 4 — downstream changes or refactoring of + // "cpuacct.usage_all" could otherwise break system usage parsing. + // (issue: https://github.com/opencontainers/cgroups/issues/46) + fields := strings.SplitN(scanner.Text(), " ", 4) if len(fields) != 3 { continue } diff --git a/fs/cpuacct_test.go b/fs/cpuacct_test.go index c0c9543..2c82756 100644 --- a/fs/cpuacct_test.go +++ b/fs/cpuacct_test.go @@ -20,6 +20,7 @@ const ( 5 872544369885276 638763309884944 6 870104915696359 640081778921247 7 870202363887496 638716766259495 + 8 867579076304580 988021047245223 792312716071280 109505081909990 ` )