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.15.0.tar.gz (79.2 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.15.0-py3-none-any.whl (86.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: procpath-1.15.0.tar.gz
  • Upload date:
  • Size: 79.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for procpath-1.15.0.tar.gz
Algorithm Hash digest
SHA256 19d5d92621a05b811bd5e93bb988992cf288a48cd00cd83302a174a690190b6b
MD5 4aab1dbaef0ec4b3f0e95d24ecf564ab
BLAKE2b-256 a5c8ad50babcfdf7ff4c60f47891ab443cd247fa99a0e0a6b87cc0710a6c8b61

See more details on using hashes here.

File details

Details for the file procpath-1.15.0-py3-none-any.whl.

File metadata

  • Download URL: procpath-1.15.0-py3-none-any.whl
  • Upload date:
  • Size: 86.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for procpath-1.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b2184ef0dca8efbe7bbe85f46c26ae6b79b68aeb3327b298d963a3f39afef57
MD5 c9af73a78501596bb688f7febf02381c
BLAKE2b-256 df89dbc45822a86d58383c191fd405d6c06c2f95e56c0b27cd1985714d547a9c

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