14998: Report total_* (hierarchy) stats if available.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 19 Mar 2019 19:49:49 +0000 (15:49 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Thu, 28 Mar 2019 17:43:29 +0000 (13:43 -0400)
Otherwise, host stats only include the root cgroup.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/crunchstat/crunchstat.go

index 8afe828196d9ea029e2f66a411b9e9f40225efee..028083fa0d1a23442f527b24f8ce95aacff660f4 100644 (file)
@@ -256,8 +256,13 @@ func (r *Reporter) doMemoryStats() {
        }
        var outstat bytes.Buffer
        for _, key := range wantStats {
-               if val, ok := thisSample.memStat[key]; ok {
-                       outstat.WriteString(fmt.Sprintf(" %d %s", val, key))
+               // Use "total_X" stats (entire hierarchy) if enabled,
+               // otherwise just the single cgroup -- see
+               // https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
+               if val, ok := thisSample.memStat["total_"+key]; ok {
+                       fmt.Fprintf(&outstat, " %d %s", val, key)
+               } else if val, ok := thisSample.memStat[key]; ok {
+                       fmt.Fprintf(&outstat, " %d %s", val, key)
                }
        }
        r.Logger.Printf("mem%s\n", outstat.String())