diff --git a/collector/cgroupv2.go b/collector/cgroupv2.go index d784f5c..9659370 100644 --- a/collector/cgroupv2.go +++ b/collector/cgroupv2.go @@ -171,7 +171,7 @@ func (e *Exporter) getMetricsv2(name string, pids []int, opts cgroup2.InitOpts) return metric, err } if stats.Memory != nil { - metric.memoryRSS = float64(stats.Memory.Anon) + swapcached + float64(stats.Memory.AnonThp) + metric.memoryRSS = float64(stats.Memory.Anon) + swapcached + float64(stats.Memory.File) metric.memoryUsed = float64(stats.Memory.Usage) metric.memoryTotal = float64(stats.Memory.UsageLimit) metric.memoryCache = float64(stats.Memory.File) diff --git a/collector/cgroupv2_test.go b/collector/cgroupv2_test.go index d4f4bdd..2cd1be9 100644 --- a/collector/cgroupv2_test.go +++ b/collector/cgroupv2_test.go @@ -110,7 +110,7 @@ func TestCollectv2UserSlice(t *testing.T) { if val := metrics[0].cpus; val != 0 { t.Errorf("Unexpected value for cpus, got %v", val) } - if val := metrics[0].memoryRSS; val != 22048768 { + if val := metrics[0].memoryRSS; val != 22626304 { t.Errorf("Unexpected value for memoryRSS, got %v", val) } if val := metrics[0].memoryUsed; val != 27115520 { @@ -184,7 +184,7 @@ func TestCollectv2SLURM(t *testing.T) { if val := m.cpus; val != 1 { t.Errorf("Unexpected value for cpus, got %v", val) } - if val := m.memoryRSS; val != 2260992 { + if val := m.memoryRSS; val != 2777088 { t.Errorf("Unexpected value for memoryRSS, got %v", val) } if val := m.memoryUsed; val != 5660672 {