Procpath is a process tree analysis workbench
Project description
Procpath
Procpath is a process tree analysis command-line workbench. Its goal is to provide natural interface to the tree structure of processes running on a Linux system for inspection, collection and later analysis with focus on performance.
Installation
pipx install Procpath
pipx is recommended for installing Procpath (into a dedicated virtual environment). Alternatively pip can be used to install Procpath to the Python user install directory.
pip install --user Procpath
Quickstart
Get comma-separated PIDs of the process subtree (including the parent process pid=2610).
procpath query -d , '$..children[?(@.stat.pid == 2610)]..pid'
Get JSON document of said process subtree.
procpath query -i 2 '$..children[?(@.stat.pid == 2610)]'
Get total RSS in MiB of said process subtree (this is an example that query produces JSON that can be further processed outside of procpath, and below is a much easier way to calculate aggregates).
procpath query '$..children[?(@.stat.pid == 2610)]' \
| jq '[.. | .stat? | objects | .rss] | add / 1024 * 4'
Get total RSS in MiB of said process subtree the easy way.
procpath query '$..children[?(@.stat.pid == 2610)]' \
'SELECT SUM(stat_rss) / 1024.0 * 4 total FROM record'
Get total RSS in MiB of a docker-compose stack.
L=$(docker ps -f status=running -f name='^project_name' -q | xargs -I{} -- \
docker inspect -f '{{.State.Pid}}' {} | tr '\n' ,)
procpath query "$..children[?(@.stat.pid in [$L])]" \
'SELECT SUM(stat_rss) / 1024.0 * 4 total FROM record'
Record process trees of two Docker containers once a second, re-evaluating the containers’ root process PIDs once per 30 recordings. Then visualise RSS of each process (which is also just an example, that output SQLite database can be visualised in different ways, including exporting CSV, sqlite3 -csv ..., and doing it the old way, to using proper UI described in the documentation).
procpath record \
-e C1='docker inspect -f "{{.State.Pid}}" project_db_1' \
-e C2='docker inspect -f "{{.State.Pid}}" project_app_1' \
-i 1 -v 30 -d out.sqlite '$..children[?(@.stat.pid in [$C1, $C2])]'
# press Ctrl + C
sqlite3 out.sqlite \
"SELECT stat_pid, group_concat(stat_rss / 1024.0 * 4) \
FROM record \
GROUP BY stat_pid" \
| sed -z 's/\n/\n\n\n/g' | sed 's/|/\n/' | sed 's/,/\n/g' > special_fmt
gnuplot -p -e \
"plot for [i=0:*] 'special_fmt' index i with lines title columnheader(1)"
Visualise the above recording the easy way.
procpath plot -d out.sqlite -o out.svg -q cpu -q rss
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Procpath-1.11.1.tar.gz
.
File metadata
- Download URL: Procpath-1.11.1.tar.gz
- Upload date:
- Size: 69.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ebe80b8cab1db9d3b2d8d00d446a9bce6ee120ab50ef9c2d3de97b1a1326a4 |
|
MD5 | 2985cbaecb013bf83c5aeeb1ef6d5b40 |
|
BLAKE2b-256 | 3df342e137e5b4e41247ba6be20aa456541345d28c24173ce146e019134e478f |
File details
Details for the file Procpath-1.11.1-py3-none-any.whl
.
File metadata
- Download URL: Procpath-1.11.1-py3-none-any.whl
- Upload date:
- Size: 76.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32af1d9790888d3ab4127e1ed370194f0aaffc1b72995a7f0a55378dd9183209 |
|
MD5 | 87839d1539c821b8d26e1704de55dff3 |
|
BLAKE2b-256 | c53bef02cc13c104278a28c1f3e5b7968d85c2faf1b3b6262cdc778ed4d17733 |