Unix process tree search
Project description
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,ucomm,args
if pgrep
command not available (AIX), pgtree uses built-in pgrep (-f -i -x -u <user>
supported).
Tested on various versions of RedHat / CentOS / Ubuntu / Debian / Suse / MacOS / Solaris / AIX including old versions
(uses -o comm on Solaris)
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 [-Iya] [-C <when>] [-O <psfield>] [-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 : color preference : y/yes/always or n/no/never (default auto)
-w : tty wrap text : y/yes or n/no (default y)
-a : use ascii characters
-O <psfield> : display <psfield> instead of 'stime' in output
<psfield> must be valid with ps -o <psfield> command
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
show processes matching bash
and their children
kill all sh
processes of user joknarf and their children
Demo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pgtree-1.0.16-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 776e870cb1b9dab162850fc0476a57f2cb59a1ce87838303f19f84cdfa62c093 |
|
MD5 | 9a028de6e66a4048cbbba44ea9326cc7 |
|
BLAKE2b-256 | 281b11d9ba72b12c25e8c00bfce578d3a99de6e4ccbbd80271ef53077bbbceae |