Skip to main content

Unix process tree search

Project description

Travis CI Codecov Upload Python Package Pypi version Downloads Python versions Licence

pgtree

Unix process hierachy tree display for specific processes (kind of mixed pgrep + pstree)

pgtree is also able to send signal to found processes and all their children

The purpose is to have the tool working out of the box on any Unix box, using the default OS python installed, without installing anything else. The code must be compatible with python 2.x + 3.x

Should work on any Unix that can execute :

# /usr/bin/pgrep 
# /usr/bin/ps -e -o pid,ppid,stime,user,comm,args

Installation

FYI, the pgtree/pgtree.py is standalone and can be directly copied/used anywhere without any installation.

installation using pip:

# pip install pgtree

installation using setup.py, root install in /usr/local/bin:

# ./setup.py install

installation using setup.py, user install in ~/.local/bin:

# ./setup.py install --prefix=~/.local

Usage

# pgtree -h
    usage: pgtree.py [-ICya] [-c|-k|-K] [-p <pid1>,...|<pgrep args>]

    -I : use -o uid instead of -o user for ps command
         (if uid/user mapping is broken ps command can be stuck)
    -c : display processes and children only
    -k : kill -TERM processes and children
    -K : kill -KILL processes and children
    -y : do not ask for confirmation to kill
    -C : no color (default colored output on tty)
    -a : use ascii characters

    by default display full process hierarchy (parents + children of selected processes)

    -p <pids> : select processes pids to display hierarchy (default 1)
    <pgrep args> : use pgrep to select processes (see pgrep -h)

    found pids are prefixed with ▶

Examples

show all parents and children of processes matching bash

# pgtree bash

show processes matching bash and their children

# pgtree -c bash

kill all sh processes of user joknarf and their children

#pgtree -k -u joknarf -x sh

Demo

output

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pgtree, version 1.0.11
Filename, size File type Python version Upload date Hashes
Filename, size pgtree-1.0.11-py2.py3-none-any.whl (14.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pgtree-1.0.11.tar.gz (7.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page