Skip to main content

Utility tools for control groups of Linux

Project description

What is cgroup-utils?

cgroup-utils provides utility tools and libraries for control groups of Linux. For example, cgutil top is a top-like tool which shows activities of running processes in control groups.


For users

$ sudo pip install cgroup-utils

For developers

$ git clone git://
$ cd cgroup-utils
$ python build
$ sudo python install

Packaging (rpm)

$ python bdist --formats=rpm

Available commands

  • configs

  • event

  • mkdir

  • pgrep

  • rmdir

  • stats

  • top

  • tree

cgutil configs

This command show you configurations of cgroups. By default, it shows only changed configurations.

Example output

$ cgutil configs -o memory

cgutil event

This command makes cgroup.event_control easy to use. It exits when a state of a target cgroup crosses a threshold which you set, thus, you can know the state of the cgroup has changed.

Example output

$ cgutil event /sys/fs/cgroup/memory/system/sshd.service/memory.usage_in_bytes +1M
$ # It exits when memory usage of processes in the cgroup has increased one more MB.

cgutil pgrep

This command is alike pgrep command but it shows cgroups in addtion to PIDs.

Example output

$ cgutil pgrep ssh
/: 15072
/: 15074
/system/sshd.service: 630
$ cgutil pgrep ssh -l -f
/: 15072 sshd: ozaki-r [priv]
/: 15074 sshd: ozaki-r@pts/2
/: 15157 /bin/python /bin/cgutil pgrep ssh -l -f
/system/sshd.service: 630 /usr/sbin/sshd -D

cgutil stats

This command shows you states of cgroups.

Example output

$ cgutil stats
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
        stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}

cgutil top

This command is alike top command but it shows activities in a unit of cgroups.

Example output

$ cgutil top -i -n 2 -b
18.1 msec to collect statistics
[  CPUACCT  ]  [     BLKIO     ]  [        MEMORY       ]
 USR    SYS      READ    WRITE     TOTAL    RSS     SWAP     # NAME
  0.0%   0.0%    0.0 /s   0.0 /s     0.0    48.0k    0.0    97 usr_1000/default
20.5 msec to collect statistics
[  CPUACCT  ]  [     BLKIO     ]  [        MEMORY       ]
 USR    SYS      READ    WRITE     TOTAL    RSS     SWAP     # NAME
  0.0%   0.0%    0.0 /s   0.0 /s   128.0k    4.0k    0.0   104 sys_daemon
  0.0%   0.0%    0.0 /s   0.0 /s   -64.0k    0.0     0.0     0 sys_essential
  0.0%   0.0%    0.0 /s   0.0 /s   108.0k   32.0k    0.0    97 usr_1000/default

cgutil tree

This command shows you tree structure of cgroups.

Example outputs

$ cgutil tree -o blkio



Supported Linux Version


Supported subsystems

  • blkio (and its debug feature)

  • cpuset

  • cpu and cpuacct

  • devices

  • freezer

  • hugetlb

  • memory

  • net_cls

  • net_prio

  • pids

  • rdma

Supported Python

  • python2: 2.6 and above

    • deprecated

  • python3: 3.4 and above

    • 3.0 to 3.3 may work but not tested


The tools are distributed under GPLv2. See COPYING for more detail.



  • Tweak cgutil top for recent environments

  • Use GitHub Actions as CI


  • Support PID and RDMA subsystems

  • Support new control files

  • Mark python2 deprecated


  • Support new control files added between Linux 3.9 and 3.18

  • Support Python 3

  • Drop Python 2.5 support

  • Fix several bugs. Thanks lebauce and pavel-odintsov!


  • Support hugetlb subsystem

  • Support additional cgroup files of blkio, memory and freezer

  • Use argparse instead of optparse

  • Fix several bugs. Thanks novas0x2a and unicell!


  • Add unit tests for control file parsers and a test for PEP8 compliance

  • Support dynamic cgroups hierarchy update for top command

  • Support missing net_prio subsystem

  • Complete event_control supports in event command

  • Implement mkdir/rmdir commands

  • Fix a bunch of bugs

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cgroup-utils-0.8.tar.gz (24.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page