From be81b5e1ed93eb65e5dbed4f52905439cde86f62 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 21 Oct 2019 13:47:22 -0700 Subject: [PATCH] readme update --- README.md | 233 ++++++++++++++++++++++++++---------------------------- 1 file changed, 112 insertions(+), 121 deletions(-) diff --git a/README.md b/README.md index 754c40e8..f84f065c 100755 --- a/README.md +++ b/README.md @@ -24,16 +24,21 @@ $ pip3 install jc ``` ## Usage +``` +jc [parser] [options] +``` + `jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. The JSON output can be compact or pretty formatted. -The first argument is required and identifies the command that is piping output to `jc` input. For example: +Parsers: - `--ls` enables the `ls` parser - `--ifconfig` enables the `ifconfig` parser - `--netstat` enables the `netstat` parser - `--ps` enables the `ps` parser - `--route` enables the `route` parser -The second `-p` argument is optional and specifies whether to pretty format the JSON output. +Options: +- `-p` specifies whether to pretty format the JSON output ## Examples ### ls @@ -157,129 +162,115 @@ $ ifconfig | jc --ifconfig -p ### netstat ``` $ netstat -p | jc --netstat -p -{ - "client": { - "tcp": { - "ipv4": [ - { - "local_address": "localhost.localdo", - "local_port": "34480", - "foreign_address": "lb-192-30-255-113", - "foreign_port": "https", - "state": "ESTABLISHED", - "pid": 53550, - "program_name": "git-remote-ht", - "receive_q": 0, - "send_q": 0 - }, - { - "local_address": "localhost.localdo", - "local_port": "34478", - "foreign_address": "lb-192-30-255-113", - "foreign_port": "https", - "state": "ESTABLISHED", - "pid": 53550, - "program_name": "git-remote-ht", - "receive_q": 0, - "send_q": 0 - } - ] - } +[ + { + "session_protocol": "tcp", + "network_protocol": "ipv4", + "local_address": "localhost.localdo", + "local_port": "34480", + "foreign_address": "lb-192-30-255-113", + "foreign_port": "https", + "state": "ESTABLISHED", + "pid": 53550, + "program_name": "git-remote-ht", + "receive_q": 0, + "send_q": 0 + }, + { + "session_protocol": "tcp", + "network_protocol": "ipv4", + "local_address": "localhost.localdo", + "local_port": "34478", + "foreign_address": "lb-192-30-255-113", + "foreign_port": "https", + "state": "ESTABLISHED", + "pid": 53550, + "program_name": "git-remote-ht", + "receive_q": 0, + "send_q": 0 } -} +] ``` ``` -$ netstat -lp | jc --netstat -p -{ - "server": { - "tcp": { - "ipv4": [ - { - "local_address": "localhost", - "local_port": "smtp", - "foreign_address": "0.0.0.0", - "foreign_port": "*", - "state": "LISTEN", - "pid": 1594, - "program_name": "master", - "receive_q": 0, - "send_q": 0 - }, - { - "local_address": "0.0.0.0", - "local_port": "ssh", - "foreign_address": "0.0.0.0", - "foreign_port": "*", - "state": "LISTEN", - "pid": 21918, - "program_name": "sshd", - "receive_q": 0, - "send_q": 0 - } - ], - "ipv6": [ - { - "local_address": "localhost", - "local_port": "smtp", - "foreign_address": "[::]", - "foreign_port": "*", - "state": "LISTEN", - "pid": 1594, - "program_name": "master", - "receive_q": 0, - "send_q": 0 - }, - { - "local_address": "[::]", - "local_port": "ssh", - "foreign_address": "[::]", - "foreign_port": "*", - "state": "LISTEN", - "pid": 21918, - "program_name": "sshd", - "receive_q": 0, - "send_q": 0 - } - ] - }, - "udp": { - "ipv4": [ - { - "local_address": "0.0.0.0", - "local_port": "bootpc", - "foreign_address": "0.0.0.0", - "foreign_port": "*", - "pid": 13903, - "program_name": "dhclient", - "receive_q": 0, - "send_q": 0 - }, - { - "local_address": "localhost", - "local_port": "323", - "foreign_address": "0.0.0.0", - "foreign_port": "*", - "pid": 30926, - "program_name": "chronyd", - "receive_q": 0, - "send_q": 0 - } - ], - "ipv6": [ - { - "local_address": "localhost", - "local_port": "323", - "foreign_address": "[::]", - "foreign_port": "*", - "pid": 30926, - "program_name": "chronyd", - "receive_q": 0, - "send_q": 0 - } - ] - } +$ netstat -lpn | jc --netstat -p +[ + { + "session_protocol": "tcp", + "network_protocol": "ipv4", + "local_address": "127.0.0.1", + "local_port": "42351", + "foreign_address": "0.0.0.0", + "foreign_port": "*", + "state": "LISTEN", + "pid": 1112, + "program_name": "containerd", + "receive_q": 0, + "send_q": 0 + }, + { + "session_protocol": "tcp", + "network_protocol": "ipv4", + "local_address": "127.0.0.53", + "local_port": "53", + "foreign_address": "0.0.0.0", + "foreign_port": "*", + "state": "LISTEN", + "pid": 885, + "program_name": "systemd-resolve", + "receive_q": 0, + "send_q": 0 + }, + { + "session_protocol": "tcp", + "network_protocol": "ipv4", + "local_address": "0.0.0.0", + "local_port": "22", + "foreign_address": "0.0.0.0", + "foreign_port": "*", + "state": "LISTEN", + "pid": 1127, + "program_name": "sshd", + "receive_q": 0, + "send_q": 0 + }, + { + "session_protocol": "tcp", + "network_protocol": "ipv6", + "local_address": "::", + "local_port": "22", + "foreign_address": "::", + "foreign_port": "*", + "state": "LISTEN", + "pid": 1127, + "program_name": "sshd", + "receive_q": 0, + "send_q": 0 + }, + { + "session_protocol": "udp", + "network_protocol": "ipv4", + "local_address": "127.0.0.53", + "local_port": "53", + "foreign_address": "0.0.0.0", + "foreign_port": "*", + "pid": 885, + "program_name": "systemd-resolve", + "receive_q": 0, + "send_q": 0 + }, + { + "session_protocol": "udp", + "network_protocol": "ipv4", + "local_address": "192.168.71.131", + "local_port": "68", + "foreign_address": "0.0.0.0", + "foreign_port": "*", + "pid": 867, + "program_name": "systemd-network", + "receive_q": 0, + "send_q": 0 } -} +] ``` ### ps ```