linux控制组实用工具
cgroup-utils的Python项目详细描述
什么是cgroup utils?
cgroup utils为 Linux系统。例如,cgutil top是一个类似top的工具,它显示活动 在控制组中运行进程。
安装
对于用户
$ sudo pip install cgroup-utils
对于开发者
$ git clone git://github.com/peo3/cgroup-utils.git $ cd cgroup-utils $ python setup.py build $ sudo python setup.py install
包装(RPM)
$ python setup.py bdist --formats=rpm
可用命令
- 配置
- 事件
- mkdir
- pgrep
- rmdir
- 统计
- 顶部
- 树
cgutil配置
此命令显示cgroup的配置。默认情况下,它显示 仅更改配置。
示例输出
$ cgutil configs -o memory <root> notify_on_release=1 release_agent=/usr/lib/ulatencyd/ulatencyd_cleanup.lua sys_essential swappiness=0 notify_on_release=1 sys_bg swappiness=100 notify_on_release=1
cgutil事件
此命令使cgroup.event_控件易于使用。它退出时 目标cgroup的状态超过了您设置的阈值,因此 可以知道cgroup的状态已更改。
示例输出
$ 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
这个命令类似于pgrep命令,但它在addtion中显示cgroup 致PIDS。
示例输出
$ 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统计
此命令显示cgroup的状态。
示例输出
$ cgutil stats <root> stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/sm-client.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/sendmail.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/vboxadd-service.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/colord.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/colord-sane.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/udisks2.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L} system/cups.service stat={'throttled_time': 0L, 'nr_periods': 0L, 'nr_throttled': 0L}
cgutil顶部
此命令类似于top命令,但它显示单元中的活动 一组。
示例输出
$ 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树
此命令显示cgroup的树结构。
示例输出
$ cgutil tree -o blkio <root> `system +sm-client.service +sendmail.service +vboxadd-service.service +colord.service +colord-sane.service +udisks2.service +cups.service +rtkit-daemon.service (snip) +fsck@.service +udev.service `systemd-journald.service
支持的Linux版本
4.20.y
支持的子系统
- blkio(及其调试功能)
- cpuset
- CPU和CPU单元
- 设备
- 冷冻室
- Hugetlb
- 内存
- 净成本
- 净利润
- PIDS
- RDMA
支持的python
- Python2:2.6及以上
- 已弃用
- Python3:3.4及以上
- 3.0至3.3可能有效,但未经测试
许可证
这些工具在gplv2下发布。有关详细信息,请参见复制。
更改日志
0.7
- 支持PID和RDMA子系统
- 支持新的控制文件
- mark python2已弃用
0.6
- 支持在Linux 3.9和3.18之间添加新的控制文件
- 支持Python3
- 放弃Python2.5支持
- 修复几个错误。谢谢勒博和帕维尔·奥廷佐夫!
0.5
- 支持hugetlb子系统
- 支持blkio、memory和freezer的其他cgroup文件
- 使用argparse而不是optparse
- 修复几个错误。谢谢Novas0x2a和Unicell!
0.4
- 添加控制文件解析器的单元测试和pep8的测试 合规性
- 支持top命令的动态cgroup层次结构更新
- 支持丢失的网络优先子系统
- 事件命令中的完整事件控制支持
- 执行mkdir/rmdir命令
- 修复一堆错误