Skip to main content

Procpath is a process tree analysis workbench

Project description

PyPI - License Pipeline status Test code coverage Benchmark PyPI RTFM

Procpath

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
Procpath RSS vs CPU SVG

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

procpath-1.13.0.tar.gz (74.7 kB view details)

Uploaded Source

Built Distribution

Procpath-1.13.0-py3-none-any.whl (82.2 kB view details)

Uploaded Python 3

File details

Details for the file procpath-1.13.0.tar.gz.

File metadata

  • Download URL: procpath-1.13.0.tar.gz
  • Upload date:
  • Size: 74.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for procpath-1.13.0.tar.gz
Algorithm Hash digest
SHA256 f095b7a2e2352d3a3e7b4a952e77ac32a6802df0ddd720a9c9b137f3f7a077a3
MD5 4bbffc0bbecbab2787ff529669fd6234
BLAKE2b-256 cb9db0ce805c1ade86471f5ece6dcbb3d4639f5d1f0dc025e858603e77c47a3a

See more details on using hashes here.

File details

Details for the file Procpath-1.13.0-py3-none-any.whl.

File metadata

  • Download URL: Procpath-1.13.0-py3-none-any.whl
  • Upload date:
  • Size: 82.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for Procpath-1.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd184acebb38d8b7e9535367267a1f377b592c72e190cbdee4622c926899ef10
MD5 4c07f10ebf66223703b6aa3a5795b087
BLAKE2b-256 177080a0b0cc7149de898eb2d261ae37f9b9e56474e8d440d10fc7b221f7007e

See more details on using hashes here.

Supported by

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