Procpath


NameProcpath JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://heptapod.host/saajns/procpath
SummaryProcpath is a process tree analysis workbench
upload_time2021-04-11 20:37:31
maintainer
docs_urlNone
authorsaaj
requires_python>= 3.6
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://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://procpath.readthedocs.io/en/report/htmlcov/?badge=coverage
   :alt: Test code coverage
.. image:: http://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat
   :target: https://procpath.readthedocs.io/en/report/htmlasv/?badge=asv
   :alt: Benchmark
.. image:: https://badge.fury.io/py/Procpath.svg
   :target: https://pypi.python.org/pypi/Procpath
   :alt: PyPI
.. image:: https://readthedocs.org/projects/procpath/badge/?version=latest
   :target: https://procpath.readthedocs.io/en/latest/?badge=latest
   :alt: RTFD

********
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 and later analysis.

Installation
============
.. sourcecode::

   pip install --user Procpath

For installing Procpath into a dedicated virtual environment ``pipx`` [1]_
is recommended.

.. sourcecode::

   pipx install Procpath

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

.. sourcecode::

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

Get JSON document of said process subtree.

.. sourcecode::

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

.. sourcecode::

   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.

.. sourcecode::

   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.

.. sourcecode::

   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 Visualisation
section in the documentation).

.. sourcecode::

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

____

.. [1] https://pypi.org/project/pipx/



            

Raw data

            {
    "_id": null,
    "home_page": "https://heptapod.host/saajns/procpath",
    "name": "Procpath",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">= 3.6",
    "maintainer_email": "",
    "keywords": "procfs jsonpath sqlite plotting",
    "author": "saaj",
    "author_email": "mail@saaj.me",
    "download_url": "https://files.pythonhosted.org/packages/b2/95/221a5e78a56a0df4809cf031be63ebc7423b240b023610d9fedb23d687cf/Procpath-1.2.0.tar.gz",
    "platform": "",
    "description": ".. 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://procpath.readthedocs.io/en/report/htmlcov/?badge=coverage\n   :alt: Test code coverage\n.. image:: http://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat\n   :target: https://procpath.readthedocs.io/en/report/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:: https://readthedocs.org/projects/procpath/badge/?version=latest\n   :target: https://procpath.readthedocs.io/en/latest/?badge=latest\n   :alt: RTFD\n\n********\nProcpath\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 and later analysis.\n\nInstallation\n============\n.. sourcecode::\n\n   pip install --user Procpath\n\nFor installing Procpath into a dedicated virtual environment ``pipx`` [1]_\nis recommended.\n\n.. sourcecode::\n\n   pipx install Procpath\n\nQuickstart\n==========\nGet comma-separated PIDs of the process subtree (including the parent process\n``pid=2610``).\n\n.. sourcecode::\n\n   procpath query -d , '$..children[?(@.stat.pid == 2610)]..pid'\n\nGet JSON document of said process subtree.\n\n.. sourcecode::\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.. sourcecode::\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.. sourcecode::\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.. sourcecode::\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 Visualisation\nsection in the documentation).\n\n.. sourcecode::\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\n____\n\n.. [1] https://pypi.org/project/pipx/\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0-only",
    "summary": "Procpath is a process tree analysis workbench",
    "version": "1.2.0",
    "split_keywords": [
        "procfs",
        "jsonpath",
        "sqlite",
        "plotting"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3910437eff9693c4bc073597a3792eeb",
                "sha256": "9856c82a4b0953f4764d27fadf93ebae1f2a9dca8e76435a378e24660bf9d234"
            },
            "downloads": -1,
            "filename": "Procpath-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3910437eff9693c4bc073597a3792eeb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">= 3.6",
            "size": 53533,
            "upload_time": "2021-04-11T20:37:29",
            "upload_time_iso_8601": "2021-04-11T20:37:29.803200Z",
            "url": "https://files.pythonhosted.org/packages/22/b1/089e2ccf207fa03aa42ec41abc7ce14669ba96919f9e13a9d11b759e849c/Procpath-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "da8cd9f07a475b9d5b438d628277e65c",
                "sha256": "62a59a92415e428be4630b026b239034cceed282ea08ed681f052379234f970a"
            },
            "downloads": -1,
            "filename": "Procpath-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "da8cd9f07a475b9d5b438d628277e65c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">= 3.6",
            "size": 47871,
            "upload_time": "2021-04-11T20:37:31",
            "upload_time_iso_8601": "2021-04-11T20:37:31.802792Z",
            "url": "https://files.pythonhosted.org/packages/b2/95/221a5e78a56a0df4809cf031be63ebc7423b240b023610d9fedb23d687cf/Procpath-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-11 20:37:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "procpath"
}
        
Elapsed time: 0.32734s