Output the process tree in machine-readable JSON.
Project description
pstree-json
@readwithai - X - blog - machine-aided reading - 📖⚡️🖋️
An easily-installable command-line to output the process tree in machine readable format. Suitable for pasting into an LLM.
Warning. This is ai-generated and I cannot guarantee to not changing the options! If people use it I may freeze it but don't use it in automated scripts unless you are freezing.
Motivation
Do you ever get a feeling like "what is wrong with the world". It feels very odd that this tool does not exist, so I am creating it.
Having a tree in JSON format makes it a lot easier to do things like find a processes parents and child etc.
Using programmatic tools and grep to interact with a process tree particular useful when you have a lot of processes.
Installation
You can install pstree-json using pipx:
pipx install pstree-json
Usage
To list processes us pstree-json.
pstree-json $PID
You likely want to use a combination of gron or json-leaves (written by the author) together with grep to search what is going on with tress and jq to then extract desired information.
Attribution and prior work
This tool is a wrapper around the psutil library - but is useful from the shell.
You might like to use pgtree which combines pg with pstree to show a process tree. You can use pstree - but this did not show me enough information.
pgtree-tui provides a tui for interactive wit hthe process tree.
About me
I am @readwithai. I create tools for reading, research and agency sometimes using the markdown editor Obsidian.
I also create a stream of tools that are related to carrying out my work.
I write about lots of things - including tools like this - on X. My blog is more about reading and research and agency.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pstree_json-1.0.0.tar.gz.
File metadata
- Download URL: pstree_json-1.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d57b548b5145acf468621b714e00fd0194c7e626cbd8932ad319accc13a75284
|
|
| MD5 |
0b34a90fd7e6a66b28b21a6263292897
|
|
| BLAKE2b-256 |
7d4c7eea7a8b76f4d0dfa5532ebc175ed50bcf7d0f6be9ad04c58f6107da894f
|
File details
Details for the file pstree_json-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pstree_json-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bbf95ab5eee636d36097298903d5d8198f71adfad7d8d6bb1ddb4e21ae377da
|
|
| MD5 |
00370d9778dd1f713d7e4c33f4e0f059
|
|
| BLAKE2b-256 |
84a3f384e48ae5b1138233386bd08b7e93400052236e25cdc8032799e400c0f2
|