Procpath


NameProcpath JSON
Version 1.11.1 PyPI version JSON
download
home_pagehttps://heptapod.host/saajns/procpath
SummaryProcpath is a process tree analysis workbench
upload_time2024-06-30 16:08:05
maintainerNone
docs_urlNone
authorsaaj
requires_python>=3.8
licenseLGPL-3.0-only
keywords procfs jsonpath sqlite plotting
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://img.shields.io/pypi/l/Procpath.svg
   :target: https://spdx.org/licenses/LGPL-3.0-only.html
   :alt: PyPI - License
.. image:: https://heptapod.host/saajns/procpath/badges/branch/default/pipeline.svg
   :target: https://heptapod.host/saajns/procpath/-/commits/branch/default
   :alt: Pipeline status
.. image:: https://heptapod.host/saajns/procpath/badges/branch/default/coverage.svg
   :target: https://saajns.heptapod.io/procpath/htmlcov/?badge=coverage
   :alt: Test code coverage
.. image:: https://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat
   :target: https://saajns.heptapod.io/procpath/htmlasv/?badge=asv
   :alt: Benchmark
.. image:: https://badge.fury.io/py/Procpath.svg
   :target: https://pypi.python.org/pypi/Procpath
   :alt: PyPI
.. image::
   https://img.shields.io/gitlab/pipeline-status/saajns%2Fprocpath
   ?gitlab_url=https%3A%2F%2Fheptapod.host&branch=branch%2Fdefault&label=documentation
   :target: https://saajns.heptapod.io/procpath/
   :alt: RTFM

********
Procpath
********
.. image:: https://heptapod.host/saajns/procpath/-/raw/798fffd7/manual/_static/logo.svg
   :align: center
   :alt: 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
============
.. code::

   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.

.. code::

   pip install --user Procpath

Quickstart
==========
Get comma-separated PIDs of the process subtree (including the parent process
``pid=2610``).

.. code::

   procpath query -d , '$..children[?(@.stat.pid == 2610)]..pid'

Get JSON document of said process subtree.

.. code::

   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).

.. code::

   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.

.. code::

   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.

.. code::

   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).

.. code::

   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.

.. code::

   procpath plot -d out.sqlite -o out.svg -q cpu -q rss

.. image:: https://heptapod.host/saajns/procpath/-/raw/8884bb/manual/_static/default_rss_vs_cpu.svg
   :alt: Procpath RSS vs CPU SVG


.. _pipx: https://pypi.org/project/pipx/

            

Raw data

            {
    "_id": null,
    "home_page": "https://heptapod.host/saajns/procpath",
    "name": "Procpath",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "procfs jsonpath sqlite plotting",
    "author": "saaj",
    "author_email": "mail@saaj.me",
    "download_url": "https://files.pythonhosted.org/packages/3d/f3/42e137e5b4e41247ba6be20aa456541345d28c24173ce146e019134e478f/Procpath-1.11.1.tar.gz",
    "platform": null,
    "description": ".. image:: https://img.shields.io/pypi/l/Procpath.svg\n   :target: https://spdx.org/licenses/LGPL-3.0-only.html\n   :alt: PyPI - License\n.. image:: https://heptapod.host/saajns/procpath/badges/branch/default/pipeline.svg\n   :target: https://heptapod.host/saajns/procpath/-/commits/branch/default\n   :alt: Pipeline status\n.. image:: https://heptapod.host/saajns/procpath/badges/branch/default/coverage.svg\n   :target: https://saajns.heptapod.io/procpath/htmlcov/?badge=coverage\n   :alt: Test code coverage\n.. image:: https://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat\n   :target: https://saajns.heptapod.io/procpath/htmlasv/?badge=asv\n   :alt: Benchmark\n.. image:: https://badge.fury.io/py/Procpath.svg\n   :target: https://pypi.python.org/pypi/Procpath\n   :alt: PyPI\n.. image::\n   https://img.shields.io/gitlab/pipeline-status/saajns%2Fprocpath\n   ?gitlab_url=https%3A%2F%2Fheptapod.host&branch=branch%2Fdefault&label=documentation\n   :target: https://saajns.heptapod.io/procpath/\n   :alt: RTFM\n\n********\nProcpath\n********\n.. image:: https://heptapod.host/saajns/procpath/-/raw/798fffd7/manual/_static/logo.svg\n   :align: center\n   :alt: Procpath\n\nProcpath is a process tree analysis command-line workbench. Its goal is to\nprovide natural interface to the tree structure of processes running on a\nLinux system for inspection, collection and later analysis with focus on\nperformance.\n\nInstallation\n============\n.. code::\n\n   pipx install Procpath\n\n`pipx`_ is recommended for installing Procpath (into a dedicated virtual\nenvironment). Alternatively ``pip`` can be used to install Procpath to the\nPython user install directory.\n\n.. code::\n\n   pip install --user Procpath\n\nQuickstart\n==========\nGet comma-separated PIDs of the process subtree (including the parent process\n``pid=2610``).\n\n.. code::\n\n   procpath query -d , '$..children[?(@.stat.pid == 2610)]..pid'\n\nGet JSON document of said process subtree.\n\n.. code::\n\n   procpath query -i 2 '$..children[?(@.stat.pid == 2610)]'\n\nGet total RSS in MiB of said process subtree (this is an example that\n``query`` produces JSON that can be further processed outside of ``procpath``,\nand below is a much easier way to calculate aggregates).\n\n.. code::\n\n   procpath query '$..children[?(@.stat.pid == 2610)]' \\\n     | jq '[.. | .stat? | objects | .rss] | add / 1024 * 4'\n\nGet total RSS in MiB of said process subtree the easy way.\n\n.. code::\n\n   procpath query '$..children[?(@.stat.pid == 2610)]' \\\n     'SELECT SUM(stat_rss) / 1024.0 * 4 total FROM record'\n\nGet total RSS in MiB of a docker-compose stack.\n\n.. code::\n\n   L=$(docker ps -f status=running -f name='^project_name' -q | xargs -I{} -- \\\n     docker inspect -f '{{.State.Pid}}' {} | tr '\\n' ,)\n   procpath query \"$..children[?(@.stat.pid in [$L])]\" \\\n     'SELECT SUM(stat_rss) / 1024.0 * 4 total FROM record'\n\nRecord process trees of two Docker containers once a second, re-evaluating the\ncontainers' root process PIDs once per 30 recordings. Then visualise RSS of\neach process (which is also just an example, that output SQLite database can\nbe visualised in different ways, including exporting CSV, ``sqlite3 -csv ...``,\nand doing it the old way, to using proper UI described in the documentation).\n\n.. code::\n\n   procpath record \\\n     -e C1='docker inspect -f \"{{.State.Pid}}\" project_db_1' \\\n     -e C2='docker inspect -f \"{{.State.Pid}}\" project_app_1' \\\n     -i 1 -v 30 -d out.sqlite '$..children[?(@.stat.pid in [$C1, $C2])]'\n   # press Ctrl + C\n   sqlite3 out.sqlite \\\n     \"SELECT stat_pid, group_concat(stat_rss / 1024.0 * 4) \\\n      FROM record \\\n      GROUP BY stat_pid\" \\\n     | sed -z 's/\\n/\\n\\n\\n/g' | sed 's/|/\\n/' | sed 's/,/\\n/g' > special_fmt\n   gnuplot -p -e \\\n     \"plot for [i=0:*] 'special_fmt' index i with lines title columnheader(1)\"\n\nVisualise the above recording the easy way.\n\n.. code::\n\n   procpath plot -d out.sqlite -o out.svg -q cpu -q rss\n\n.. image:: https://heptapod.host/saajns/procpath/-/raw/8884bb/manual/_static/default_rss_vs_cpu.svg\n   :alt: Procpath RSS vs CPU SVG\n\n\n.. _pipx: https://pypi.org/project/pipx/\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0-only",
    "summary": "Procpath is a process tree analysis workbench",
    "version": "1.11.1",
    "project_urls": {
        "Documentation": "https://saajns.heptapod.io/procpath/",
        "Homepage": "https://heptapod.host/saajns/procpath",
        "Release Notes": "https://saajns.heptapod.io/procpath/history.html",
        "Source Code": "https://heptapod.host/saajns/procpath"
    },
    "split_keywords": [
        "procfs",
        "jsonpath",
        "sqlite",
        "plotting"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c53bef02cc13c104278a28c1f3e5b7968d85c2faf1b3b6262cdc778ed4d17733",
                "md5": "87839d1539c821b8d26e1704de55dff3",
                "sha256": "32af1d9790888d3ab4127e1ed370194f0aaffc1b72995a7f0a55378dd9183209"
            },
            "downloads": -1,
            "filename": "Procpath-1.11.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "87839d1539c821b8d26e1704de55dff3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 76431,
            "upload_time": "2024-06-30T16:08:03",
            "upload_time_iso_8601": "2024-06-30T16:08:03.140868Z",
            "url": "https://files.pythonhosted.org/packages/c5/3b/ef02cc13c104278a28c1f3e5b7968d85c2faf1b3b6262cdc778ed4d17733/Procpath-1.11.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3df342e137e5b4e41247ba6be20aa456541345d28c24173ce146e019134e478f",
                "md5": "2985cbaecb013bf83c5aeeb1ef6d5b40",
                "sha256": "a8ebe80b8cab1db9d3b2d8d00d446a9bce6ee120ab50ef9c2d3de97b1a1326a4"
            },
            "downloads": -1,
            "filename": "Procpath-1.11.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2985cbaecb013bf83c5aeeb1ef6d5b40",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 69207,
            "upload_time": "2024-06-30T16:08:05",
            "upload_time_iso_8601": "2024-06-30T16:08:05.411871Z",
            "url": "https://files.pythonhosted.org/packages/3d/f3/42e137e5b4e41247ba6be20aa456541345d28c24173ce146e019134e478f/Procpath-1.11.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-30 16:08:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "procpath"
}
        
Elapsed time: 0.28115s