forked from libcgroup/libcgroup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python: tools: Add tool for displaying a tree of PSI data
Add a tool for displaying the PSI data for a cgroup hierarchy. $ ./src/tools/cgpsitree.py -c cpu -f some-total -d 1 cpu some-total PSI data /: 516797584 ├── dev-hugepages.mount: 7 ├── dev-mqueue.mount: 0 ├── init.scope: 117064 ├── machine.slice: 0 ├── proc-sys-fs-binfmt_misc.mount: 3 ├── sys-fs-fuse-connections.mount: 3 ├── sys-kernel-config.mount: 0 ├── sys-kernel-debug.mount: 109 ├── sys-kernel-tracing.mount: 3 ├── system.slice: 58977534 └── user.slice: 425882912 $ ./src/tools/cgpsitree.py -c memory -f full-avg60 -d 1 memory full-avg60 PSI data /: 0.0 ├── dev-hugepages.mount: 0.0 ├── dev-mqueue.mount: 0.0 ├── init.scope: 0.0 ├── machine.slice: 0.0 ├── proc-sys-fs-binfmt_misc.mount: 0.0 ├── sys-fs-fuse-connections.mount: 0.0 ├── sys-kernel-config.mount: 0.0 ├── sys-kernel-debug.mount: 0.0 ├── sys-kernel-tracing.mount: 0.0 ├── system.slice: 0.0 └── user.slice: 0.0 Signed-off-by: Tom Hromatka <[email protected]>
- Loading branch information
1 parent
3e08cb3
commit 3b46d78
Showing
2 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: LGPL-2.1-only | ||
# | ||
# Display the PSI usage in a cgroup hierarchy | ||
# | ||
# Copyright (c) 2021-2024 Oracle and/or its affiliates. | ||
# Author: Tom Hromatka <[email protected]> | ||
# | ||
|
||
from libcgroup import LibcgroupPsiTree | ||
import argparse | ||
import os | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser("Libcgroup PSI Tree") | ||
parser.add_argument('-C', '--cgroup', type=str, required=False, default=None, | ||
help='Relative path to the cgroup of interest, e.g. machine.slice/foo.scope') | ||
parser.add_argument('-c', '--controller', required=True, | ||
help='PSI controller data to display. cpu, io, or memory') | ||
parser.add_argument('-f', '--field', required=False, default='some-avg10', | ||
help='Which PSI field to display, e.g. some-avg10, full-avg60, ...') | ||
parser.add_argument('-d', '--depth', type=int, required=False, default=None, | ||
help='Depth to recurse into the cgroup path. 0 == only this cgroup, 1 == this cgroup and its children, ...') | ||
|
||
args = parser.parse_args() | ||
|
||
return args | ||
|
||
def main(args): | ||
cgtree = LibcgroupPsiTree(args.cgroup, controller=args.controller, depth=args.depth, | ||
psi_field=args.field) | ||
|
||
cgtree.walk() | ||
cgtree.build() | ||
|
||
print('{} {} PSI data'.format(args.controller, args.field)) | ||
cgtree.show() | ||
|
||
if __name__ == '__main__': | ||
args = parse_args() | ||
main(args) |