From 2b1e086f629aa2f46ee22cdd875b2fc102ec72f6 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Sun, 13 Mar 2016 04:53:20 +1100 Subject: [PATCH] libcontainer: cgroups: add pids.max to PidsStats In order to allow nice usage statistics (in terms of percentages and other such data), add the value of pids.max to the PidsStats struct returned from the pids cgroup controller. Signed-off-by: Aleksa Sarai --- libcontainer/cgroups/fs/pids.go | 10 ++++++++-- libcontainer/cgroups/stats.go | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libcontainer/cgroups/fs/pids.go b/libcontainer/cgroups/fs/pids.go index 96cbb896..8f187a59 100644 --- a/libcontainer/cgroups/fs/pids.go +++ b/libcontainer/cgroups/fs/pids.go @@ -47,11 +47,17 @@ func (s *PidsGroup) Remove(d *cgroupData) error { } func (s *PidsGroup) GetStats(path string, stats *cgroups.Stats) error { - value, err := getCgroupParamUint(path, "pids.current") + current, err := getCgroupParamUint(path, "pids.current") if err != nil { return fmt.Errorf("failed to parse pids.current - %s", err) } - stats.PidsStats.Current = value + max, err := getCgroupParamUint(path, "pids.max") + if err != nil { + return fmt.Errorf("failed to parse pids.max - %s", err) + } + + stats.PidsStats.Current = current + stats.PidsStats.Max = max return nil } diff --git a/libcontainer/cgroups/stats.go b/libcontainer/cgroups/stats.go index a9a07434..7eba4414 100644 --- a/libcontainer/cgroups/stats.go +++ b/libcontainer/cgroups/stats.go @@ -54,6 +54,8 @@ type MemoryStats struct { type PidsStats struct { // number of pids in the cgroup Current uint64 `json:"current,omitempty"` + // active pids hard limit + Max uint64 `json:"max,omitempty"` } type BlkioStatEntry struct {