diff --git a/README.md b/README.md index 46918e5b..8edaee88 100755 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The first argument is required and identifies the command that is piping output - `--ls` enables the `ls` parser - `--ifconfig` enables the `ifconfig` parser - `--netstat` enables the `netstat` parser +- `--ps` enables the `ps` parser The second `-p` argument is optional and specifies whether to pretty format the JSON output. @@ -279,5 +280,57 @@ $ netstat -lp | jc --netstat -p } } ``` +### ps +``` +$ ps -ef | jc --ps -p +[ + { + "UID": "root", + "PID": "1", + "PPID": "0", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:05", + "CMD": "/lib/systemd/systemd --system --deserialize 35" + }, + { + "UID": "root", + "PID": "2", + "PPID": "0", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:00", + "CMD": "[kthreadd]" + }, + { + "UID": "root", + "PID": "4", + "PPID": "2", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:00", + "CMD": "[kworker/0:0H]" + }, + { + "UID": "root", + "PID": "6", + "PPID": "2", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:00", + "CMD": "[mm_percpu_wq]" + }, + ... +] +``` + +## Contributions +Feel free to add/improve code or parsers! + ## Acknowledgments - `ifconfig-parser` module from https://github.com/KnightWhoSayNi/ifconfig-parser +- Parsing code from Conor Heine at https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501 diff --git a/changelog.txt b/changelog.txt index 97004a7b..10356c01 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,7 +2,7 @@ jc changelog 2019xxxx v0.5.0 - Fix netstat -p parsing for Ubuntu -+ Add ps parser +- Add ps parser + Add route parser + Change some ifconfig fields to integers + Use maxsplit option in split in ls.py line 109... otherwise filenames with multiple spaces diff --git a/jc/parsers/ps.py b/jc/parsers/ps.py index f494d452..14fc45f0 100644 --- a/jc/parsers/ps.py +++ b/jc/parsers/ps.py @@ -7,8 +7,52 @@ Usage: - ef - axu -Examples: +Example: +$ ps -ef | jc --ps -p +[ + { + "UID": "root", + "PID": "1", + "PPID": "0", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:05", + "CMD": "/lib/systemd/systemd --system --deserialize 35" + }, + { + "UID": "root", + "PID": "2", + "PPID": "0", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:00", + "CMD": "[kthreadd]" + }, + { + "UID": "root", + "PID": "4", + "PPID": "2", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:00", + "CMD": "[kworker/0:0H]" + }, + { + "UID": "root", + "PID": "6", + "PPID": "2", + "C": "0", + "STIME": "13:58", + "TTY": "?", + "TIME": "00:00:00", + "CMD": "[mm_percpu_wq]" + }, + ... +] """