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.14.0.tar.gz (76.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Procpath-1.14.0-py3-none-any.whl (83.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for procpath-1.14.0.tar.gz
Algorithm Hash digest
SHA256 f7ddb1d97e7070f78386302d128cd3386249016ef765ec46e753ddc81f13e197
MD5 5fe37e0d31137d02b7e453ba98157d21
BLAKE2b-256 530d45fbc2613205cb790a933109f44451f0ebc2e90a6ac19fdd1732cce471d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Procpath-1.14.0-py3-none-any.whl
  • Upload date:
  • Size: 83.4 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.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3f93ecea4323b6be415297f05cef3eb40056dcc48d28d8aae068770615979fb
MD5 1c7e11d4d1e70f786536e4c06566f783
BLAKE2b-256 109982065e853aa1319a4f58257a7e553e00715b649d5d4fa0696a4d0d2313fc

See more details on using hashes here.

Supported by

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