1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00

readme update

This commit is contained in:
Kelly Brazil
2019-10-21 13:47:22 -07:00
parent 5f88f7d8a0
commit be81b5e1ed

125
README.md
View File

@ -24,16 +24,21 @@ $ pip3 install jc
``` ```
## Usage ## 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. `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 - `--ls` enables the `ls` parser
- `--ifconfig` enables the `ifconfig` parser - `--ifconfig` enables the `ifconfig` parser
- `--netstat` enables the `netstat` parser - `--netstat` enables the `netstat` parser
- `--ps` enables the `ps` parser - `--ps` enables the `ps` parser
- `--route` enables the `route` 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 ## Examples
### ls ### ls
@ -157,11 +162,10 @@ $ ifconfig | jc --ifconfig -p
### netstat ### netstat
``` ```
$ netstat -p | jc --netstat -p $ netstat -p | jc --netstat -p
{ [
"client": {
"tcp": {
"ipv4": [
{ {
"session_protocol": "tcp",
"network_protocol": "ipv4",
"local_address": "localhost.localdo", "local_address": "localhost.localdo",
"local_port": "34480", "local_port": "34480",
"foreign_address": "lb-192-30-255-113", "foreign_address": "lb-192-30-255-113",
@ -173,6 +177,8 @@ $ netstat -p | jc --netstat -p
"send_q": 0 "send_q": 0
}, },
{ {
"session_protocol": "tcp",
"network_protocol": "ipv4",
"local_address": "localhost.localdo", "local_address": "localhost.localdo",
"local_port": "34478", "local_port": "34478",
"foreign_address": "lb-192-30-255-113", "foreign_address": "lb-192-30-255-113",
@ -183,103 +189,88 @@ $ netstat -p | jc --netstat -p
"receive_q": 0, "receive_q": 0,
"send_q": 0 "send_q": 0
} }
] ]
}
}
}
``` ```
``` ```
$ netstat -lp | jc --netstat -p $ netstat -lpn | jc --netstat -p
{ [
"server": {
"tcp": {
"ipv4": [
{ {
"local_address": "localhost", "session_protocol": "tcp",
"local_port": "smtp", "network_protocol": "ipv4",
"local_address": "127.0.0.1",
"local_port": "42351",
"foreign_address": "0.0.0.0", "foreign_address": "0.0.0.0",
"foreign_port": "*", "foreign_port": "*",
"state": "LISTEN", "state": "LISTEN",
"pid": 1594, "pid": 1112,
"program_name": "master", "program_name": "containerd",
"receive_q": 0, "receive_q": 0,
"send_q": 0 "send_q": 0
}, },
{ {
"local_address": "0.0.0.0", "session_protocol": "tcp",
"local_port": "ssh", "network_protocol": "ipv4",
"local_address": "127.0.0.53",
"local_port": "53",
"foreign_address": "0.0.0.0", "foreign_address": "0.0.0.0",
"foreign_port": "*", "foreign_port": "*",
"state": "LISTEN", "state": "LISTEN",
"pid": 21918, "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", "program_name": "sshd",
"receive_q": 0, "receive_q": 0,
"send_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": "[::]", "session_protocol": "tcp",
"local_port": "ssh", "network_protocol": "ipv6",
"foreign_address": "[::]", "local_address": "::",
"local_port": "22",
"foreign_address": "::",
"foreign_port": "*", "foreign_port": "*",
"state": "LISTEN", "state": "LISTEN",
"pid": 21918, "pid": 1127,
"program_name": "sshd", "program_name": "sshd",
"receive_q": 0, "receive_q": 0,
"send_q": 0 "send_q": 0
}
]
}, },
"udp": {
"ipv4": [
{ {
"local_address": "0.0.0.0", "session_protocol": "udp",
"local_port": "bootpc", "network_protocol": "ipv4",
"local_address": "127.0.0.53",
"local_port": "53",
"foreign_address": "0.0.0.0", "foreign_address": "0.0.0.0",
"foreign_port": "*", "foreign_port": "*",
"pid": 13903, "pid": 885,
"program_name": "dhclient", "program_name": "systemd-resolve",
"receive_q": 0, "receive_q": 0,
"send_q": 0 "send_q": 0
}, },
{ {
"local_address": "localhost", "session_protocol": "udp",
"local_port": "323", "network_protocol": "ipv4",
"local_address": "192.168.71.131",
"local_port": "68",
"foreign_address": "0.0.0.0", "foreign_address": "0.0.0.0",
"foreign_port": "*", "foreign_port": "*",
"pid": 30926, "pid": 867,
"program_name": "chronyd", "program_name": "systemd-network",
"receive_q": 0, "receive_q": 0,
"send_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
}
]
}
}
}
``` ```
### ps ### ps
``` ```