Skip to content

Commit

Permalink
libcontainer: cgroups: add pids.max to PidsStats
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cyphar committed Mar 12, 2016
1 parent bab300c commit 2b1e086
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libcontainer/cgroups/fs/pids.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions libcontainer/cgroups/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2b1e086

Please sign in to comment.