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 list of PSI data
Add a tool for displaying the PSI data for a cgroup hierarchy. $ ./src/tools/cgpsilist.py -c cpu -d 1 -f some-avg10 -l 10 -t 0 some-avg10 PSI CGROUP 0.00 /sys-fs-fuse-connections.mount 0.00 /sys-kernel-config.mount 0.00 /sys-kernel-debug.mount 0.00 /dev-mqueue.mount 0.00 /user.slice 0.00 /sys-kernel-tracing.mount 0.00 /init.scope 0.00 /system.slice 0.00 /proc-sys-fs-binfmt_misc.mount 0.00 /machine.slice $ ./src/tools/cgpsilist.py -c cpu -d 1 -f full-total -l 10 -t 0 full-total PSI CGROUP 421304531 /user.slice 62664636 /system.slice 118774 /init.scope 109 /sys-kernel-debug.mount 7 /dev-hugepages.mount 3 /sys-fs-fuse-connections.mount 3 /sys-kernel-tracing.mount 3 /proc-sys-fs-binfmt_misc.mount 0 /sys-kernel-config.mount 0 /dev-mqueue.mount Signed-off-by: Tom Hromatka <[email protected]>
- Loading branch information
1 parent
480eb73
commit 5e533a0
Showing
3 changed files
with
96 additions
and
0 deletions.
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
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,42 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: LGPL-2.1-only | ||
# | ||
# Display a list of cgroups and their specified PSI metrics | ||
# | ||
# Copyright (c) 2021-2024 Oracle and/or its affiliates. | ||
# Author: Tom Hromatka <[email protected]> | ||
# | ||
|
||
from libcgroup import LibcgroupPsiList | ||
import argparse | ||
import os | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser('Libcgroup PSI List') | ||
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, ...') | ||
parser.add_argument('-t', '--threshold', type=float, required=False, default=1.0, | ||
help='Only list cgroups whose PSI exceeds this percentage') | ||
parser.add_argument('-l', '--limit', type=int, required=False, default=None, | ||
help='Only display the first N cgroups. If not provided, all cgroups that match are displayed') | ||
|
||
args = parser.parse_args() | ||
|
||
return args | ||
|
||
def main(args): | ||
cglist = LibcgroupPsiList(args.cgroup, controller=args.controller, depth=args.depth, | ||
psi_field=args.field, threshold=args.threshold, limit=args.limit) | ||
|
||
cglist.walk() | ||
cglist.show() | ||
|
||
if __name__ == '__main__': | ||
args = parse_args() | ||
main(args) |