mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
add stat docs
This commit is contained in:
@ -22,6 +22,7 @@ pydocmd simple jc.parsers.netstat+ > ../docs/parsers/netstat.md
|
|||||||
pydocmd simple jc.parsers.ps+ > ../docs/parsers/ps.md
|
pydocmd simple jc.parsers.ps+ > ../docs/parsers/ps.md
|
||||||
pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
|
pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
|
||||||
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
|
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
|
||||||
|
pydocmd simple jc.parsers.stat+ > ../docs/parsers/ss.md
|
||||||
pydocmd simple jc.parsers.uname+ > ../docs/parsers/uname.md
|
pydocmd simple jc.parsers.uname+ > ../docs/parsers/uname.md
|
||||||
pydocmd simple jc.parsers.uptime+ > ../docs/parsers/uptime.md
|
pydocmd simple jc.parsers.uptime+ > ../docs/parsers/uptime.md
|
||||||
pydocmd simple jc.parsers.w+ > ../docs/parsers/w.md
|
pydocmd simple jc.parsers.w+ > ../docs/parsers/w.md
|
||||||
|
@ -1,245 +1,100 @@
|
|||||||
# jc.parsers.ss
|
# jc.parsers.stat
|
||||||
jc - JSON CLI output utility ss Parser
|
jc - JSON CLI output utility stats Parser
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
specify --ss as the first argument if the piped input is coming from ss
|
specify --stats as the first argument if the piped input is coming from stats
|
||||||
|
|
||||||
Limitations:
|
|
||||||
Extended information options like -e and -p are not supported and may cause parsing irregularities
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ sudo ss -a | jc --ss -p
|
$ stat /bin/* | jc --stat -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"netid": "nl",
|
"file": "/bin/bash",
|
||||||
"state": "UNCONN",
|
"size": 1113504,
|
||||||
"recv_q": 0,
|
"blocks": 2176,
|
||||||
"send_q": 0,
|
"io_blocks": 4096,
|
||||||
"peer_address": "*",
|
"type": "regular file",
|
||||||
"channel": "rtnl:kernel"
|
"device": "802h/2050d",
|
||||||
},
|
"inode": 131099,
|
||||||
{
|
"links": 1,
|
||||||
"netid": "nl",
|
"access": "0755",
|
||||||
"state": "UNCONN",
|
"flags": "-rwxr-xr-x",
|
||||||
"recv_q": 0,
|
"uid": 0,
|
||||||
"send_q": 0,
|
"user": "root",
|
||||||
"peer_address": "*",
|
"gid": 0,
|
||||||
"pid": 893,
|
"group": "root",
|
||||||
"channel": "rtnl:systemd-resolve"
|
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
||||||
},
|
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
||||||
...
|
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
||||||
{
|
"birth_time": "-"
|
||||||
"netid": "p_raw",
|
},
|
||||||
"state": "UNCONN",
|
{
|
||||||
"recv_q": 0,
|
"file": "/bin/btrfs",
|
||||||
"send_q": 0,
|
"size": 716464,
|
||||||
"peer_address": "*",
|
"blocks": 1400,
|
||||||
"link_layer": "LLDP",
|
"io_blocks": 4096,
|
||||||
"interface": "ens33"
|
"type": "regular file",
|
||||||
},
|
"device": "802h/2050d",
|
||||||
{
|
"inode": 131100,
|
||||||
"netid": "u_dgr",
|
"links": 1,
|
||||||
"state": "UNCONN",
|
"access": "0755",
|
||||||
"recv_q": 0,
|
"flags": "-rwxr-xr-x",
|
||||||
"send_q": 0,
|
"uid": 0,
|
||||||
"local_port": "93066",
|
"user": "root",
|
||||||
"peer_address": "*",
|
"gid": 0,
|
||||||
"peer_port": "0",
|
"group": "root",
|
||||||
"path": "/run/user/1000/systemd/notify"
|
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
||||||
},
|
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
||||||
{
|
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
||||||
"netid": "u_seq",
|
"birth_time": "-"
|
||||||
"state": "LISTEN",
|
},
|
||||||
"recv_q": 0,
|
...
|
||||||
"send_q": 128,
|
]
|
||||||
"local_port": "20699",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "0",
|
|
||||||
"path": "/run/udev/control"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
{
|
|
||||||
"netid": "icmp6",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": 0,
|
|
||||||
"send_q": 0,
|
|
||||||
"local_address": "*",
|
|
||||||
"local_port": "ipv6-icmp",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "ens33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "udp",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": 0,
|
|
||||||
"send_q": 0,
|
|
||||||
"local_address": "127.0.0.53",
|
|
||||||
"local_port": "domain",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "lo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": 0,
|
|
||||||
"send_q": 128,
|
|
||||||
"local_address": "127.0.0.53",
|
|
||||||
"local_port": "domain",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "lo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": 0,
|
|
||||||
"send_q": 128,
|
|
||||||
"local_address": "0.0.0.0",
|
|
||||||
"local_port": "ssh",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": 0,
|
|
||||||
"send_q": 128,
|
|
||||||
"local_address": "[::]",
|
|
||||||
"local_port": "ssh",
|
|
||||||
"peer_address": "[::]",
|
|
||||||
"peer_port": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "v_str",
|
|
||||||
"state": "ESTAB",
|
|
||||||
"recv_q": 0,
|
|
||||||
"send_q": 0,
|
|
||||||
"local_address": "999900439",
|
|
||||||
"local_port": "1023",
|
|
||||||
"peer_address": "0",
|
|
||||||
"peer_port": "976",
|
|
||||||
"local_port_num": 1023,
|
|
||||||
"peer_port_num": 976
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ sudo ss -a | jc --ss -p -r
|
$ stat /bin/* | jc --stat -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"netid": "nl",
|
"file": "/bin/bash",
|
||||||
"state": "UNCONN",
|
"size": "1113504",
|
||||||
"recv_q": "0",
|
"blocks": "2176",
|
||||||
"send_q": "0",
|
"io_blocks": "4096",
|
||||||
"peer_address": "*",
|
"type": "regular file",
|
||||||
"channel": "rtnl:kernel"
|
"device": "802h/2050d",
|
||||||
},
|
"inode": "131099",
|
||||||
{
|
"links": "1",
|
||||||
"netid": "nl",
|
"access": "0755",
|
||||||
"state": "UNCONN",
|
"flags": "-rwxr-xr-x",
|
||||||
"recv_q": "0",
|
"uid": "0",
|
||||||
"send_q": "0",
|
"user": "root",
|
||||||
"peer_address": "*",
|
"gid": "0",
|
||||||
"pid": "893",
|
"group": "root",
|
||||||
"channel": "rtnl:systemd-resolve"
|
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
||||||
},
|
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
||||||
...
|
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
||||||
{
|
"birth_time": "-"
|
||||||
"netid": "p_raw",
|
},
|
||||||
"state": "UNCONN",
|
{
|
||||||
"recv_q": "0",
|
"file": "/bin/btrfs",
|
||||||
"send_q": "0",
|
"size": "716464",
|
||||||
"peer_address": "*",
|
"blocks": "1400",
|
||||||
"link_layer": "LLDP",
|
"io_blocks": "4096",
|
||||||
"interface": "ens33"
|
"type": "regular file",
|
||||||
},
|
"device": "802h/2050d",
|
||||||
{
|
"inode": "131100",
|
||||||
"netid": "u_dgr",
|
"links": "1",
|
||||||
"state": "UNCONN",
|
"access": "0755",
|
||||||
"recv_q": "0",
|
"flags": "-rwxr-xr-x",
|
||||||
"send_q": "0",
|
"uid": "0",
|
||||||
"local_port": "93066",
|
"user": "root",
|
||||||
"peer_address": "*",
|
"gid": "0",
|
||||||
"peer_port": "0",
|
"group": "root",
|
||||||
"path": "/run/user/1000/systemd/notify"
|
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
||||||
},
|
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
||||||
{
|
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
||||||
"netid": "u_seq",
|
"birth_time": "-"
|
||||||
"state": "LISTEN",
|
},
|
||||||
"recv_q": "0",
|
..
|
||||||
"send_q": "128",
|
]
|
||||||
"local_port": "20699",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "0",
|
|
||||||
"path": "/run/udev/control"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
{
|
|
||||||
"netid": "icmp6",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_address": "*",
|
|
||||||
"local_port": "ipv6-icmp",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "ens33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "udp",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_address": "127.0.0.53",
|
|
||||||
"local_port": "domain",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "lo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_address": "127.0.0.53",
|
|
||||||
"local_port": "domain",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "lo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_address": "0.0.0.0",
|
|
||||||
"local_port": "ssh",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_address": "[::]",
|
|
||||||
"local_port": "ssh",
|
|
||||||
"peer_address": "[::]",
|
|
||||||
"peer_port": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "v_str",
|
|
||||||
"state": "ESTAB",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_address": "999900439",
|
|
||||||
"local_port": "1023",
|
|
||||||
"peer_address": "0",
|
|
||||||
"peer_port": "976"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
## process
|
## process
|
||||||
```python
|
```python
|
||||||
@ -258,26 +113,28 @@ Returns:
|
|||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"netid": string,
|
"file": string,
|
||||||
"state": string,
|
"link_to" string,
|
||||||
"recv_q": integer,
|
"size": integer,
|
||||||
"send_q": integer,
|
"blocks": integer,
|
||||||
"local_address": string,
|
"io_blocks": integer,
|
||||||
"local_port": string,
|
"type": string,
|
||||||
"local_port_num": integer,
|
"device": string,
|
||||||
"peer_address": string,
|
"inode": integer,
|
||||||
"peer_port": string,
|
"links": integer,
|
||||||
"peer_port_num": integer,
|
"access": string,
|
||||||
"interface": string,
|
"flags": string,
|
||||||
"link_layer" string,
|
"uid": integer,
|
||||||
"channel": string,
|
"user": string,
|
||||||
"path": string,
|
"gid": integer,
|
||||||
"pid": integer
|
"group": string,
|
||||||
|
"access_time": string,
|
||||||
|
"modify_time": string,
|
||||||
|
"change_time": string,
|
||||||
|
"birth_time": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Information from https://www.cyberciti.biz/files/ss.html used to define field names
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
parse(data, raw=False, quiet=False)
|
||||||
|
Reference in New Issue
Block a user