mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
update docs
This commit is contained in:
27
docgen.sh
Executable file
27
docgen.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Generate docs.md
|
||||||
|
|
||||||
|
cd jc
|
||||||
|
pydocmd simple jc+ > ../docs/readme.md
|
||||||
|
pydocmd simple cli+ > ../docs/cli.md
|
||||||
|
pydocmd simple utils+ > ../docs/utils.md
|
||||||
|
pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md
|
||||||
|
pydocmd simple jc.parsers.df+ > ../docs/parsers/df.md
|
||||||
|
pydocmd simple jc.parsers.dig+ > ../docs/parsers/dig.md
|
||||||
|
pydocmd simple jc.parsers.env+ > ../docs/parsers/env.md
|
||||||
|
pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md
|
||||||
|
pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md
|
||||||
|
pydocmd simple jc.parsers.ifconfig+ > ../docs/parsers/ifconfig.md
|
||||||
|
pydocmd simple jc.parsers.iptables+ > ../docs/parsers/iptables.md
|
||||||
|
pydocmd simple jc.parsers.jobs+ > ../docs/parsers/jobs.md
|
||||||
|
pydocmd simple jc.parsers.ls+ > ../docs/parsers/ls.md
|
||||||
|
pydocmd simple jc.parsers.lsblk+ > ../docs/parsers/lsblk.md
|
||||||
|
pydocmd simple jc.parsers.lsmod+ > ../docs/parsers/lsmod.md
|
||||||
|
pydocmd simple jc.parsers.lsof+ > ../docs/parsers/lsof.md
|
||||||
|
pydocmd simple jc.parsers.mount+ > ../docs/parsers/mount.md
|
||||||
|
pydocmd simple jc.parsers.netstat+ > ../docs/parsers/netstat.md
|
||||||
|
pydocmd simple jc.parsers.ps+ > ../docs/parsers/ps.md
|
||||||
|
pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
|
||||||
|
pydocmd simple jc.parsers.uname+ > ../docs/parsers/uname.md
|
||||||
|
pydocmd simple jc.parsers.uptime+ > ../docs/parsers/uptime.md
|
||||||
|
pydocmd simple jc.parsers.w+ > ../docs/parsers/w.md
|
5
docs/cli.md
Normal file
5
docs/cli.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# cli
|
||||||
|
jc - JSON CLI output utility
|
||||||
|
|
||||||
|
JC cli module
|
||||||
|
|
110
docs/parsers/arp.md
Normal file
110
docs/parsers/arp.md
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
# jc.parsers.arp
|
||||||
|
jc - JSON CLI output utility arp Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --arp as the first argument if the piped input is coming from arp
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ arp | jc --arp -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"address": "192.168.71.254",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f0:98:26",
|
||||||
|
"flags_mask": "C",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address": "gateway",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
|
"flags_mask": "C",
|
||||||
|
"iface": "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ arp | jc --arp -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"address": "gateway",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
|
"flags_mask": "C",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address": "192.168.71.254",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:fe:7a:b4",
|
||||||
|
"flags_mask": "C",
|
||||||
|
"iface": "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ arp -a | jc --arp -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": null,
|
||||||
|
"address": "192.168.71.254",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f0:98:26",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gateway",
|
||||||
|
"address": "192.168.71.2",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
|
"iface": "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ arp -a | jc --arp -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "?",
|
||||||
|
"address": "192.168.71.254",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:fe:7a:b4",
|
||||||
|
"iface": "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_gateway",
|
||||||
|
"address": "192.168.71.2",
|
||||||
|
"hwtype": "ether",
|
||||||
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
|
"iface": "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"address": string,
|
||||||
|
"hwtype": string,
|
||||||
|
"hwaddress": string,
|
||||||
|
"flags_mask": string,
|
||||||
|
"iface": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
97
docs/parsers/df.md
Normal file
97
docs/parsers/df.md
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
# jc.parsers.df
|
||||||
|
jc - JSON CLI output utility df Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --df as the first argument if the piped input is coming from df
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ df | jc --df -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": "devtmpfs",
|
||||||
|
"1k-blocks": 1918820,
|
||||||
|
"used": 0,
|
||||||
|
"available": 1918820,
|
||||||
|
"use_percent": 0,
|
||||||
|
"mounted_on": "/dev"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "tmpfs",
|
||||||
|
"1k-blocks": 1930668,
|
||||||
|
"used": 0,
|
||||||
|
"available": 1930668,
|
||||||
|
"use_percent": 0,
|
||||||
|
"mounted_on": "/dev/shm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "tmpfs",
|
||||||
|
"1k-blocks": 1930668,
|
||||||
|
"used": 11800,
|
||||||
|
"available": 1918868,
|
||||||
|
"use_percent": 1,
|
||||||
|
"mounted_on": "/run"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ df | jc --df -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": "devtmpfs",
|
||||||
|
"1k-blocks": "1918820",
|
||||||
|
"used": "0",
|
||||||
|
"available": "1918820",
|
||||||
|
"use_percent": "0%",
|
||||||
|
"mounted_on": "/dev"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "tmpfs",
|
||||||
|
"1k-blocks": "1930668",
|
||||||
|
"used": "0",
|
||||||
|
"available": "1930668",
|
||||||
|
"use_percent": "0%",
|
||||||
|
"mounted_on": "/dev/shm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "tmpfs",
|
||||||
|
"1k-blocks": "1930668",
|
||||||
|
"used": "11800",
|
||||||
|
"available": "1918868",
|
||||||
|
"use_percent": "1%",
|
||||||
|
"mounted_on": "/run"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": string,
|
||||||
|
"size": string,
|
||||||
|
"1k-blocks": integer,
|
||||||
|
"used": integer,
|
||||||
|
"available": integer,
|
||||||
|
"use_percent": integer,
|
||||||
|
"mounted_on": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
212
docs/parsers/dig.md
Normal file
212
docs/parsers/dig.md
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
# jc.parsers.dig
|
||||||
|
jc - JSON CLI output utility dig Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
Specify --dig as the first argument if the piped input is coming from dig
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "28182",
|
||||||
|
"opcode": "QUERY",
|
||||||
|
"status": "NOERROR",
|
||||||
|
"flags": "qr rd ra",
|
||||||
|
"query_num": "1",
|
||||||
|
"answer_num": "4",
|
||||||
|
"authority_num": "0",
|
||||||
|
"additional_num": "1",
|
||||||
|
"question": {
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A"
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.193.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.1.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.129.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.65.67"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": "45 msec",
|
||||||
|
"server": "192.168.71.2#53(192.168.71.2)",
|
||||||
|
"when": "Wed Oct 30 03:11:21 PDT 2019",
|
||||||
|
"rcvd": "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "23264",
|
||||||
|
"opcode": "QUERY",
|
||||||
|
"status": "NOERROR",
|
||||||
|
"flags": "qr aa rd",
|
||||||
|
"query_num": "1",
|
||||||
|
"answer_num": "1",
|
||||||
|
"authority_num": "4",
|
||||||
|
"additional_num": "1",
|
||||||
|
"question": {
|
||||||
|
"name": "www.cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A"
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": "www.cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "CNAME",
|
||||||
|
"ttl": "300",
|
||||||
|
"data": "turner-tls.map.fastly.net."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authority": [
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-1086.awsdns-07.org."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-1630.awsdns-11.co.uk."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-47.awsdns-05.com."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-576.awsdns-08.net."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": "33 msec",
|
||||||
|
"server": "205.251.194.64#53(205.251.194.64)",
|
||||||
|
"when": "Wed Oct 30 03:11:21 PDT 2019",
|
||||||
|
"rcvd": "212"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ dig -x 1.1.1.1 | jc --dig -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "27526",
|
||||||
|
"opcode": "QUERY",
|
||||||
|
"status": "NOERROR",
|
||||||
|
"flags": "qr rd ra",
|
||||||
|
"query_num": "1",
|
||||||
|
"answer_num": "1",
|
||||||
|
"authority_num": "0",
|
||||||
|
"additional_num": "1",
|
||||||
|
"question": {
|
||||||
|
"name": "1.1.1.1.in-addr.arpa.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "PTR"
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": "1.1.1.1.IN-ADDR.ARPA.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "PTR",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "one.one.one.one."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": "34 msec",
|
||||||
|
"server": "192.168.71.2#53(192.168.71.2)",
|
||||||
|
"when": "Wed Oct 30 03:13:48 PDT 2019",
|
||||||
|
"rcvd": "98"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": integer,
|
||||||
|
"opcode": string,
|
||||||
|
"status": string,
|
||||||
|
"flags": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"query_num": integer,
|
||||||
|
"answer_num": integer,
|
||||||
|
"authority_num": integer,
|
||||||
|
"additional_num": integer,
|
||||||
|
"question": {
|
||||||
|
"name": string,
|
||||||
|
"class": string,
|
||||||
|
"type": string
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"class": string,
|
||||||
|
"type": string,
|
||||||
|
"ttl": integer,
|
||||||
|
"data": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authority": [
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"class": string,
|
||||||
|
"type": string,
|
||||||
|
"ttl": integer,
|
||||||
|
"data": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": integer, # in msec
|
||||||
|
"server": string,
|
||||||
|
"when": string,
|
||||||
|
"rcvd": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
72
docs/parsers/env.md
Normal file
72
docs/parsers/env.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# jc.parsers.env
|
||||||
|
jc - JSON CLI output utility env Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --env as the first argument if the piped input is coming from env
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ env | jc --env -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "XDG_SESSION_ID",
|
||||||
|
"value": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "HOSTNAME",
|
||||||
|
"value": "localhost.localdomain"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TERM",
|
||||||
|
"value": "vt220"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHELL",
|
||||||
|
"value": "/bin/bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "HISTSIZE",
|
||||||
|
"value": "1000"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ env | jc --env -p -r
|
||||||
|
{
|
||||||
|
"TERM": "xterm-256color",
|
||||||
|
"SHELL": "/bin/bash",
|
||||||
|
"USER": "root",
|
||||||
|
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
|
"PWD": "/root",
|
||||||
|
"LANG": "en_US.UTF-8",
|
||||||
|
"HOME": "/root",
|
||||||
|
"LOGNAME": "root",
|
||||||
|
"_": "/usr/bin/env"
|
||||||
|
}
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
77
docs/parsers/free.md
Normal file
77
docs/parsers/free.md
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# jc.parsers.free
|
||||||
|
jc - JSON CLI output utility free Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --free as the first argument if the piped input is coming from free
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ free | jc --free -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "Mem",
|
||||||
|
"total": 3861340,
|
||||||
|
"used": 220508,
|
||||||
|
"free": 3381972,
|
||||||
|
"shared": 11800,
|
||||||
|
"buff_cache": 258860,
|
||||||
|
"available": 3397784
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Swap",
|
||||||
|
"total": 2097148,
|
||||||
|
"used": 0,
|
||||||
|
"free": 2097148
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ free | jc --free -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "Mem",
|
||||||
|
"total": "2017300",
|
||||||
|
"used": "213104",
|
||||||
|
"free": "1148452",
|
||||||
|
"shared": "1176",
|
||||||
|
"buff_cache": "655744",
|
||||||
|
"available": "1622204"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Swap",
|
||||||
|
"total": "2097148",
|
||||||
|
"used": "0",
|
||||||
|
"free": "2097148"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": string,
|
||||||
|
"total": integer,
|
||||||
|
"used": integer,
|
||||||
|
"free": integer,
|
||||||
|
"shared": integer,
|
||||||
|
"buff_cache": integer,
|
||||||
|
"available": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
64
docs/parsers/history.md
Normal file
64
docs/parsers/history.md
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# jc.parsers.history
|
||||||
|
jc - JSON CLI output utility history Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --history as the first argument if the piped input is coming from history
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ history | jc --history -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "118",
|
||||||
|
"command": "sleep 100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "119",
|
||||||
|
"command": "ls /bin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "120",
|
||||||
|
"command": "echo "hello""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "121",
|
||||||
|
"command": "docker images"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ history | jc --history -p -r
|
||||||
|
{
|
||||||
|
"118": "sleep 100",
|
||||||
|
"119": "ls /bin",
|
||||||
|
"120": "echo "hello"",
|
||||||
|
"121": "docker images",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"line": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
170
docs/parsers/ifconfig.md
Normal file
170
docs/parsers/ifconfig.md
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
# jc.parsers.ifconfig
|
||||||
|
jc - JSON CLI output utility ifconfig Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --ifconfig as the first argument if the piped input is coming from ifconfig
|
||||||
|
|
||||||
|
no ifconfig options are supported.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ ifconfig | jc --ifconfig -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "ens33",
|
||||||
|
"flags": 4163,
|
||||||
|
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
|
"mtu": 1500,
|
||||||
|
"ipv4_addr": "192.168.71.138",
|
||||||
|
"ipv4_mask": "255.255.255.0",
|
||||||
|
"ipv4_bcast": "192.168.71.255",
|
||||||
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
|
"ipv6_mask": 64,
|
||||||
|
"ipv6_scope": "link",
|
||||||
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
|
"type": "Ethernet",
|
||||||
|
"rx_packets": 6374,
|
||||||
|
"rx_errors": 0,
|
||||||
|
"rx_dropped": 0,
|
||||||
|
"rx_overruns": 0,
|
||||||
|
"rx_frame": 0,
|
||||||
|
"tx_packets": 3707,
|
||||||
|
"tx_errors": 0,
|
||||||
|
"tx_dropped": 0,
|
||||||
|
"tx_overruns": 0,
|
||||||
|
"tx_carrier": 0,
|
||||||
|
"tx_collisions": 0,
|
||||||
|
"metric": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "lo",
|
||||||
|
"flags": 73,
|
||||||
|
"state": "UP,LOOPBACK,RUNNING",
|
||||||
|
"mtu": 65536,
|
||||||
|
"ipv4_addr": "127.0.0.1",
|
||||||
|
"ipv4_mask": "255.0.0.0",
|
||||||
|
"ipv4_bcast": null,
|
||||||
|
"ipv6_addr": "::1",
|
||||||
|
"ipv6_mask": 128,
|
||||||
|
"ipv6_scope": "host",
|
||||||
|
"mac_addr": null,
|
||||||
|
"type": "Local Loopback",
|
||||||
|
"rx_packets": 81,
|
||||||
|
"rx_errors": 0,
|
||||||
|
"rx_dropped": 0,
|
||||||
|
"rx_overruns": 0,
|
||||||
|
"rx_frame": 0,
|
||||||
|
"tx_packets": 81,
|
||||||
|
"tx_errors": 0,
|
||||||
|
"tx_dropped": 0,
|
||||||
|
"tx_overruns": 0,
|
||||||
|
"tx_carrier": 0,
|
||||||
|
"tx_collisions": 0,
|
||||||
|
"metric": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ifconfig | jc --ifconfig -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "ens33",
|
||||||
|
"flags": "4163",
|
||||||
|
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
|
"mtu": "1500",
|
||||||
|
"ipv4_addr": "192.168.71.135",
|
||||||
|
"ipv4_mask": "255.255.255.0",
|
||||||
|
"ipv4_bcast": "192.168.71.255",
|
||||||
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
|
"ipv6_mask": "64",
|
||||||
|
"ipv6_scope": "link",
|
||||||
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
|
"type": "Ethernet",
|
||||||
|
"rx_packets": "26348",
|
||||||
|
"rx_errors": "0",
|
||||||
|
"rx_dropped": "0",
|
||||||
|
"rx_overruns": "0",
|
||||||
|
"rx_frame": "0",
|
||||||
|
"tx_packets": "5308",
|
||||||
|
"tx_errors": "0",
|
||||||
|
"tx_dropped": "0",
|
||||||
|
"tx_overruns": "0",
|
||||||
|
"tx_carrier": "0",
|
||||||
|
"tx_collisions": "0",
|
||||||
|
"metric": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "lo",
|
||||||
|
"flags": "73",
|
||||||
|
"state": "UP,LOOPBACK,RUNNING",
|
||||||
|
"mtu": "65536",
|
||||||
|
"ipv4_addr": "127.0.0.1",
|
||||||
|
"ipv4_mask": "255.0.0.0",
|
||||||
|
"ipv4_bcast": null,
|
||||||
|
"ipv6_addr": "::1",
|
||||||
|
"ipv6_mask": "128",
|
||||||
|
"ipv6_scope": "host",
|
||||||
|
"mac_addr": null,
|
||||||
|
"type": "Local Loopback",
|
||||||
|
"rx_packets": "64",
|
||||||
|
"rx_errors": "0",
|
||||||
|
"rx_dropped": "0",
|
||||||
|
"rx_overruns": "0",
|
||||||
|
"rx_frame": "0",
|
||||||
|
"tx_packets": "64",
|
||||||
|
"tx_errors": "0",
|
||||||
|
"tx_dropped": "0",
|
||||||
|
"tx_overruns": "0",
|
||||||
|
"tx_carrier": "0",
|
||||||
|
"tx_collisions": "0",
|
||||||
|
"metric": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"flags": integer,
|
||||||
|
"state": string,
|
||||||
|
"mtu": integer,
|
||||||
|
"ipv4_addr": string,
|
||||||
|
"ipv4_mask": string,
|
||||||
|
"ipv4_bcast": string,
|
||||||
|
"ipv6_addr": string,
|
||||||
|
"ipv6_mask": integer,
|
||||||
|
"ipv6_scope": string,
|
||||||
|
"mac_addr": string,
|
||||||
|
"type": string,
|
||||||
|
"rx_packets": integer,
|
||||||
|
"rx_errors": integer,
|
||||||
|
"rx_dropped": integer,
|
||||||
|
"rx_overruns": integer,
|
||||||
|
"rx_frame": integer,
|
||||||
|
"tx_packets": integer,
|
||||||
|
"tx_errors": integer,
|
||||||
|
"tx_dropped": integer,
|
||||||
|
"tx_overruns": integer,
|
||||||
|
"tx_carrier": integer,
|
||||||
|
"tx_collisions": integer,
|
||||||
|
"metric": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
168
docs/parsers/iptables.md
Normal file
168
docs/parsers/iptables.md
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
# jc.parsers.iptables
|
||||||
|
jc - JSON CLI output utility ipables Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
Specify --iptables as the first argument if the piped input is coming from iptables
|
||||||
|
|
||||||
|
Supports -vLn for all tables
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"chain": "PREROUTING",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"num": 1,
|
||||||
|
"pkts": 2183,
|
||||||
|
"bytes": 186000,
|
||||||
|
"target": "PREROUTING_direct",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": 2,
|
||||||
|
"pkts": 2183,
|
||||||
|
"bytes": 186000,
|
||||||
|
"target": "PREROUTING_ZONES_SOURCE",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": 3,
|
||||||
|
"pkts": 2183,
|
||||||
|
"bytes": 186000,
|
||||||
|
"target": "PREROUTING_ZONES",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": 4,
|
||||||
|
"pkts": 0,
|
||||||
|
"bytes": 0,
|
||||||
|
"target": "DOCKER",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere",
|
||||||
|
"options": "ADDRTYPE match dst-type LOCAL"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"chain": "PREROUTING",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"num": "1",
|
||||||
|
"pkts": "2183",
|
||||||
|
"bytes": "186K",
|
||||||
|
"target": "PREROUTING_direct",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": "2",
|
||||||
|
"pkts": "2183",
|
||||||
|
"bytes": "186K",
|
||||||
|
"target": "PREROUTING_ZONES_SOURCE",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": "3",
|
||||||
|
"pkts": "2183",
|
||||||
|
"bytes": "186K",
|
||||||
|
"target": "PREROUTING_ZONES",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": "4",
|
||||||
|
"pkts": "0",
|
||||||
|
"bytes": "0",
|
||||||
|
"target": "DOCKER",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere",
|
||||||
|
"options": "ADDRTYPE match dst-type LOCAL"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"chain": string,
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"num" integer,
|
||||||
|
"pkts": integer,
|
||||||
|
"bytes": integer, # converted based on suffix
|
||||||
|
"target": string,
|
||||||
|
"prot": string,
|
||||||
|
"opt": string, # "--" = Null
|
||||||
|
"in": string,
|
||||||
|
"out": string,
|
||||||
|
"source": string,
|
||||||
|
"destination": string,
|
||||||
|
"options": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
98
docs/parsers/jobs.md
Normal file
98
docs/parsers/jobs.md
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
# jc.parsers.jobs
|
||||||
|
jc - JSON CLI output utility jobs Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --jobs as the first argument if the piped input is coming from jobs
|
||||||
|
|
||||||
|
Also supports the -l option
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ jobs -l | jc --jobs -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job_number": 1,
|
||||||
|
"pid": 5283,
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 10000 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"job_number": 2,
|
||||||
|
"pid": 5284,
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 10100 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"job_number": 3,
|
||||||
|
"pid": 5285,
|
||||||
|
"history": "previous",
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 10001 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"job_number": 4,
|
||||||
|
"pid": 5286,
|
||||||
|
"history": "current",
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 10112 &"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ jobs -l | jc --jobs -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job_number": "1",
|
||||||
|
"pid": "19510",
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 1000 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"job_number": "2",
|
||||||
|
"pid": "19511",
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 1001 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"job_number": "3",
|
||||||
|
"pid": "19512",
|
||||||
|
"history": "previous",
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 1002 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"job_number": "4",
|
||||||
|
"pid": "19513",
|
||||||
|
"history": "current",
|
||||||
|
"status": "Running",
|
||||||
|
"command": "sleep 1003 &"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"job_number": integer,
|
||||||
|
"pid": integer,
|
||||||
|
"history": string,
|
||||||
|
"status": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
168
docs/parsers/ls.md
Normal file
168
docs/parsers/ls.md
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
# jc.parsers.ls
|
||||||
|
jc - JSON CLI output utility ls Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --ls as the first argument if the piped input is coming from ls
|
||||||
|
|
||||||
|
ls options supported:
|
||||||
|
- None
|
||||||
|
- la
|
||||||
|
- h file sizes will be available in text form with -r but larger file sizes
|
||||||
|
with human readable suffixes will be converted to Null in default view
|
||||||
|
since the parser attempts to convert this field to an integer.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ ls /usr/bin | jc --ls -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": "apropos"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "arch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "awk"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "base64"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": "apropos",
|
||||||
|
"link_to": "whatis",
|
||||||
|
"flags": "lrwxrwxrwx.",
|
||||||
|
"links": 1,
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": 6,
|
||||||
|
"date": "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "ar",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": 1,
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": 62744,
|
||||||
|
"date": "Aug 8 16:14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "arch",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": 1,
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": 33080,
|
||||||
|
"date": "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": "apropos",
|
||||||
|
"link_to": "whatis",
|
||||||
|
"flags": "lrwxrwxrwx.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "6",
|
||||||
|
"date": "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "arch",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "33080",
|
||||||
|
"date": "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "awk",
|
||||||
|
"link_to": "gawk",
|
||||||
|
"flags": "lrwxrwxrwx.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "4",
|
||||||
|
"date": "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "base64",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "37360",
|
||||||
|
"date": "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "basename",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "29032",
|
||||||
|
"date": "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "bash",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "964600",
|
||||||
|
"date": "Aug 8 05:06"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'
|
||||||
|
{
|
||||||
|
"filename": "emacs",
|
||||||
|
"flags": "-r-xr-xr-x",
|
||||||
|
"links": 1,
|
||||||
|
"owner": "root",
|
||||||
|
"group": "wheel",
|
||||||
|
"size": 117164432,
|
||||||
|
"date": "May 3 2019"
|
||||||
|
}
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": string,
|
||||||
|
"flags": string,
|
||||||
|
"links": integer,
|
||||||
|
"owner": string,
|
||||||
|
"group": string,
|
||||||
|
"size": integer,
|
||||||
|
"date": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
273
docs/parsers/lsblk.md
Normal file
273
docs/parsers/lsblk.md
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
# jc.parsers.lsblk
|
||||||
|
jc - JSON CLI output utility lsblk Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --lsblk as the first argument if the piped input is coming from lsblk
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ lsblk | jc --lsblk -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "sda",
|
||||||
|
"maj_min": "8:0",
|
||||||
|
"rm": false,
|
||||||
|
"size": "20G",
|
||||||
|
"ro": false,
|
||||||
|
"type": "disk",
|
||||||
|
"mountpoint": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sda1",
|
||||||
|
"maj_min": "8:1",
|
||||||
|
"rm": false,
|
||||||
|
"size": "1G",
|
||||||
|
"ro": false,
|
||||||
|
"type": "part",
|
||||||
|
"mountpoint": "/boot"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "sda",
|
||||||
|
"maj_min": "8:0",
|
||||||
|
"rm": false,
|
||||||
|
"size": "20G",
|
||||||
|
"ro": false,
|
||||||
|
"type": "disk",
|
||||||
|
"mountpoint": null,
|
||||||
|
"kname": "sda",
|
||||||
|
"fstype": null,
|
||||||
|
"label": null,
|
||||||
|
"uuid": null,
|
||||||
|
"partlabel": null,
|
||||||
|
"partuuid": null,
|
||||||
|
"ra": 4096,
|
||||||
|
"model": "VMware Virtual S",
|
||||||
|
"serial": null,
|
||||||
|
"state": "running",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "disk",
|
||||||
|
"mode": "brw-rw----",
|
||||||
|
"alignment": 0,
|
||||||
|
"min_io": 512,
|
||||||
|
"opt_io": 0,
|
||||||
|
"phy_sec": 512,
|
||||||
|
"log_sec": 512,
|
||||||
|
"rota": true,
|
||||||
|
"sched": "deadline",
|
||||||
|
"rq_size": 128,
|
||||||
|
"disc_aln": 0,
|
||||||
|
"disc_gran": "0B",
|
||||||
|
"disc_max": "0B",
|
||||||
|
"disc_zero": false,
|
||||||
|
"wsame": "32M",
|
||||||
|
"wwn": null,
|
||||||
|
"rand": true,
|
||||||
|
"pkname": null,
|
||||||
|
"hctl": "0:0:0:0",
|
||||||
|
"tran": "spi",
|
||||||
|
"rev": "1.0",
|
||||||
|
"vendor": "VMware,"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sda1",
|
||||||
|
"maj_min": "8:1",
|
||||||
|
"rm": false,
|
||||||
|
"size": "1G",
|
||||||
|
"ro": false,
|
||||||
|
"type": "part",
|
||||||
|
"mountpoint": "/boot",
|
||||||
|
"kname": "sda1",
|
||||||
|
"fstype": "xfs",
|
||||||
|
"label": null,
|
||||||
|
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
|
"partlabel": null,
|
||||||
|
"partuuid": null,
|
||||||
|
"ra": 4096,
|
||||||
|
"model": null,
|
||||||
|
"serial": null,
|
||||||
|
"state": null,
|
||||||
|
"owner": "root",
|
||||||
|
"group": "disk",
|
||||||
|
"mode": "brw-rw----",
|
||||||
|
"alignment": 0,
|
||||||
|
"min_io": 512,
|
||||||
|
"opt_io": 0,
|
||||||
|
"phy_sec": 512,
|
||||||
|
"log_sec": 512,
|
||||||
|
"rota": true,
|
||||||
|
"sched": "deadline",
|
||||||
|
"rq_size": 128,
|
||||||
|
"disc_aln": 0,
|
||||||
|
"disc_gran": "0B",
|
||||||
|
"disc_max": "0B",
|
||||||
|
"disc_zero": false,
|
||||||
|
"wsame": "32M",
|
||||||
|
"wwn": null,
|
||||||
|
"rand": true,
|
||||||
|
"pkname": "sda",
|
||||||
|
"hctl": null,
|
||||||
|
"tran": null,
|
||||||
|
"rev": null,
|
||||||
|
"vendor": null
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "sda",
|
||||||
|
"maj_min": "8:0",
|
||||||
|
"rm": "0",
|
||||||
|
"size": "20G",
|
||||||
|
"ro": "0",
|
||||||
|
"type": "disk",
|
||||||
|
"mountpoint": null,
|
||||||
|
"kname": "sda",
|
||||||
|
"fstype": null,
|
||||||
|
"label": null,
|
||||||
|
"uuid": null,
|
||||||
|
"partlabel": null,
|
||||||
|
"partuuid": null,
|
||||||
|
"ra": "4096",
|
||||||
|
"model": "VMware Virtual S",
|
||||||
|
"serial": null,
|
||||||
|
"state": "running",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "disk",
|
||||||
|
"mode": "brw-rw----",
|
||||||
|
"alignment": "0",
|
||||||
|
"min_io": "512",
|
||||||
|
"opt_io": "0",
|
||||||
|
"phy_sec": "512",
|
||||||
|
"log_sec": "512",
|
||||||
|
"rota": "1",
|
||||||
|
"sched": "deadline",
|
||||||
|
"rq_size": "128",
|
||||||
|
"disc_aln": "0",
|
||||||
|
"disc_gran": "0B",
|
||||||
|
"disc_max": "0B",
|
||||||
|
"disc_zero": "0",
|
||||||
|
"wsame": "32M",
|
||||||
|
"wwn": null,
|
||||||
|
"rand": "1",
|
||||||
|
"pkname": null,
|
||||||
|
"hctl": "0:0:0:0",
|
||||||
|
"tran": "spi",
|
||||||
|
"rev": "1.0",
|
||||||
|
"vendor": "VMware,"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sda1",
|
||||||
|
"maj_min": "8:1",
|
||||||
|
"rm": "0",
|
||||||
|
"size": "1G",
|
||||||
|
"ro": "0",
|
||||||
|
"type": "part",
|
||||||
|
"mountpoint": "/boot",
|
||||||
|
"kname": "sda1",
|
||||||
|
"fstype": "xfs",
|
||||||
|
"label": null,
|
||||||
|
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
|
"partlabel": null,
|
||||||
|
"partuuid": null,
|
||||||
|
"ra": "4096",
|
||||||
|
"model": null,
|
||||||
|
"serial": null,
|
||||||
|
"state": null,
|
||||||
|
"owner": "root",
|
||||||
|
"group": "disk",
|
||||||
|
"mode": "brw-rw----",
|
||||||
|
"alignment": "0",
|
||||||
|
"min_io": "512",
|
||||||
|
"opt_io": "0",
|
||||||
|
"phy_sec": "512",
|
||||||
|
"log_sec": "512",
|
||||||
|
"rota": "1",
|
||||||
|
"sched": "deadline",
|
||||||
|
"rq_size": "128",
|
||||||
|
"disc_aln": "0",
|
||||||
|
"disc_gran": "0B",
|
||||||
|
"disc_max": "0B",
|
||||||
|
"disc_zero": "0",
|
||||||
|
"wsame": "32M",
|
||||||
|
"wwn": null,
|
||||||
|
"rand": "1",
|
||||||
|
"pkname": "sda",
|
||||||
|
"hctl": null,
|
||||||
|
"tran": null,
|
||||||
|
"rev": null,
|
||||||
|
"vendor": null
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"maj_min": string,
|
||||||
|
"rm": boolean,
|
||||||
|
"size": string,
|
||||||
|
"ro": boolean,
|
||||||
|
"type": string,
|
||||||
|
"mountpoint": string,
|
||||||
|
"kname": string,
|
||||||
|
"fstype": string,
|
||||||
|
"label": string,
|
||||||
|
"uuid": string,
|
||||||
|
"partlabel": string,
|
||||||
|
"partuuid": string,
|
||||||
|
"ra": integer,
|
||||||
|
"model": string,
|
||||||
|
"serial": string,
|
||||||
|
"state": string,
|
||||||
|
"owner": string,
|
||||||
|
"group": string,
|
||||||
|
"mode": string,
|
||||||
|
"alignment": integer,
|
||||||
|
"min_io": integer,
|
||||||
|
"opt_io": integer,
|
||||||
|
"phy_sec": integer,
|
||||||
|
"log_sec": integer,
|
||||||
|
"rota": boolean,
|
||||||
|
"sched": string,
|
||||||
|
"rq_size": integer,
|
||||||
|
"disc_aln": integer,
|
||||||
|
"disc_gran": string,
|
||||||
|
"disc_max": string,
|
||||||
|
"disc_zero": boolean,
|
||||||
|
"wsame": string,
|
||||||
|
"wwn": string,
|
||||||
|
"rand": boolean,
|
||||||
|
"pkname": string,
|
||||||
|
"hctl": string,
|
||||||
|
"tran": string,
|
||||||
|
"rev": string,
|
||||||
|
"vendor": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
130
docs/parsers/lsmod.md
Normal file
130
docs/parsers/lsmod.md
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
# jc.parsers.lsmod
|
||||||
|
jc - JSON CLI output utility lsmod Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --lsmod as the first argument if the piped input is coming from lsmod
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ lsmod | jc --lsmod -p
|
||||||
|
[
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"module": "nf_nat",
|
||||||
|
"size": 26583,
|
||||||
|
"used": 3,
|
||||||
|
"by": [
|
||||||
|
"nf_nat_ipv4",
|
||||||
|
"nf_nat_ipv6",
|
||||||
|
"nf_nat_masquerade_ipv4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "iptable_mangle",
|
||||||
|
"size": 12695,
|
||||||
|
"used": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "iptable_security",
|
||||||
|
"size": 12705,
|
||||||
|
"used": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "iptable_raw",
|
||||||
|
"size": 12678,
|
||||||
|
"used": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "nf_conntrack",
|
||||||
|
"size": 139224,
|
||||||
|
"used": 7,
|
||||||
|
"by": [
|
||||||
|
"nf_nat",
|
||||||
|
"nf_nat_ipv4",
|
||||||
|
"nf_nat_ipv6",
|
||||||
|
"xt_conntrack",
|
||||||
|
"nf_nat_masquerade_ipv4",
|
||||||
|
"nf_conntrack_ipv4",
|
||||||
|
"nf_conntrack_ipv6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ lsmod | jc --lsmod -p -r
|
||||||
|
[
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"module": "nf_conntrack",
|
||||||
|
"size": "139224",
|
||||||
|
"used": "7",
|
||||||
|
"by": [
|
||||||
|
"nf_nat",
|
||||||
|
"nf_nat_ipv4",
|
||||||
|
"nf_nat_ipv6",
|
||||||
|
"xt_conntrack",
|
||||||
|
"nf_nat_masquerade_ipv4",
|
||||||
|
"nf_conntrack_ipv4",
|
||||||
|
"nf_conntrack_ipv6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "ip_set",
|
||||||
|
"size": "45799",
|
||||||
|
"used": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "nfnetlink",
|
||||||
|
"size": "14519",
|
||||||
|
"used": "1",
|
||||||
|
"by": [
|
||||||
|
"ip_set"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "ebtable_filter",
|
||||||
|
"size": "12827",
|
||||||
|
"used": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "ebtables",
|
||||||
|
"size": "35009",
|
||||||
|
"used": "2",
|
||||||
|
"by": [
|
||||||
|
"ebtable_nat",
|
||||||
|
"ebtable_filter"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"module": string,
|
||||||
|
"size": integer,
|
||||||
|
"used": integer,
|
||||||
|
"by": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
124
docs/parsers/lsof.md
Normal file
124
docs/parsers/lsof.md
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
# jc.parsers.lsof
|
||||||
|
jc - JSON CLI output utility lsof Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --lsof as the first argument if the piped input is coming from lsof
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ sudo lsof | jc --lsof -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"command": "systemd",
|
||||||
|
"pid": 1,
|
||||||
|
"tid": null,
|
||||||
|
"user": "root",
|
||||||
|
"fd": "cwd",
|
||||||
|
"type": "DIR",
|
||||||
|
"device": "253,0",
|
||||||
|
"size_off": 224,
|
||||||
|
"node": 64,
|
||||||
|
"name": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "systemd",
|
||||||
|
"pid": 1,
|
||||||
|
"tid": null,
|
||||||
|
"user": "root",
|
||||||
|
"fd": "rtd",
|
||||||
|
"type": "DIR",
|
||||||
|
"device": "253,0",
|
||||||
|
"size_off": 224,
|
||||||
|
"node": 64,
|
||||||
|
"name": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "systemd",
|
||||||
|
"pid": 1,
|
||||||
|
"tid": null,
|
||||||
|
"user": "root",
|
||||||
|
"fd": "txt",
|
||||||
|
"type": "REG",
|
||||||
|
"device": "253,0",
|
||||||
|
"size_off": 1624520,
|
||||||
|
"node": 50360451,
|
||||||
|
"name": "/usr/lib/systemd/systemd"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo lsof | jc --lsof -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"command": "systemd",
|
||||||
|
"pid": "1",
|
||||||
|
"tid": null,
|
||||||
|
"user": "root",
|
||||||
|
"fd": "cwd",
|
||||||
|
"type": "DIR",
|
||||||
|
"device": "8,2",
|
||||||
|
"size_off": "4096",
|
||||||
|
"node": "2",
|
||||||
|
"name": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "systemd",
|
||||||
|
"pid": "1",
|
||||||
|
"tid": null,
|
||||||
|
"user": "root",
|
||||||
|
"fd": "rtd",
|
||||||
|
"type": "DIR",
|
||||||
|
"device": "8,2",
|
||||||
|
"size_off": "4096",
|
||||||
|
"node": "2",
|
||||||
|
"name": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "systemd",
|
||||||
|
"pid": "1",
|
||||||
|
"tid": null,
|
||||||
|
"user": "root",
|
||||||
|
"fd": "txt",
|
||||||
|
"type": "REG",
|
||||||
|
"device": "8,2",
|
||||||
|
"size_off": "1595792",
|
||||||
|
"node": "668802",
|
||||||
|
"name": "/lib/systemd/systemd"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"command": string,
|
||||||
|
"pid": integer,
|
||||||
|
"tid": integer,
|
||||||
|
"user": string,
|
||||||
|
"fd": string,
|
||||||
|
"type": string,
|
||||||
|
"device": string,
|
||||||
|
"size_off": integer,
|
||||||
|
"node": integer,
|
||||||
|
"name": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
82
docs/parsers/mount.md
Normal file
82
docs/parsers/mount.md
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# jc.parsers.mount
|
||||||
|
jc - JSON CLI output utility mount Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --mount as the first argument if the piped input is coming from mount
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ mount | jc --mount -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": "sysfs",
|
||||||
|
"mount_point": "/sys",
|
||||||
|
"type": "sysfs",
|
||||||
|
"access": [
|
||||||
|
"rw",
|
||||||
|
"nosuid",
|
||||||
|
"nodev",
|
||||||
|
"noexec",
|
||||||
|
"relatime"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "proc",
|
||||||
|
"mount_point": "/proc",
|
||||||
|
"type": "proc",
|
||||||
|
"access": [
|
||||||
|
"rw",
|
||||||
|
"nosuid",
|
||||||
|
"nodev",
|
||||||
|
"noexec",
|
||||||
|
"relatime"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "udev",
|
||||||
|
"mount_point": "/dev",
|
||||||
|
"type": "devtmpfs",
|
||||||
|
"access": [
|
||||||
|
"rw",
|
||||||
|
"nosuid",
|
||||||
|
"relatime",
|
||||||
|
"size=977500k",
|
||||||
|
"nr_inodes=244375",
|
||||||
|
"mode=755"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": string,
|
||||||
|
"mount_point": string,
|
||||||
|
"type": string,
|
||||||
|
"access": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
nothing to process
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
352
docs/parsers/netstat.md
Normal file
352
docs/parsers/netstat.md
Normal file
@ -0,0 +1,352 @@
|
|||||||
|
# jc.parsers.netstat
|
||||||
|
jc - JSON CLI output utility netstat Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
Specify --netstat as the first argument if the piped input is coming from netstat
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ sudo netstat -apee | jc --netstat -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "0.0.0.0",
|
||||||
|
"state": "LISTEN",
|
||||||
|
"user": "systemd-resolve",
|
||||||
|
"inode": 26958,
|
||||||
|
"program_name": "systemd-resolve",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 887,
|
||||||
|
"local_port": "domain",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "0.0.0.0",
|
||||||
|
"foreign_address": "0.0.0.0",
|
||||||
|
"state": "LISTEN",
|
||||||
|
"user": "root",
|
||||||
|
"inode": 30499,
|
||||||
|
"program_name": "sshd",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 1186,
|
||||||
|
"local_port": "ssh",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "localhost",
|
||||||
|
"state": "ESTABLISHED",
|
||||||
|
"user": "root",
|
||||||
|
"inode": 46829,
|
||||||
|
"program_name": "sshd: root",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 2242,
|
||||||
|
"local_port": "ssh",
|
||||||
|
"foreign_port": "52186",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"foreign_port_num": 52186
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "localhost",
|
||||||
|
"state": "ESTABLISHED",
|
||||||
|
"user": "root",
|
||||||
|
"inode": 46828,
|
||||||
|
"program_name": "ssh",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 2241,
|
||||||
|
"local_port": "52186",
|
||||||
|
"foreign_port": "ssh",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4",
|
||||||
|
"local_port_num": 52186
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp6",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "[::]",
|
||||||
|
"foreign_address": "[::]",
|
||||||
|
"state": "LISTEN",
|
||||||
|
"user": "root",
|
||||||
|
"inode": 30510,
|
||||||
|
"program_name": "sshd",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 1186,
|
||||||
|
"local_port": "ssh",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "udp",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "0.0.0.0",
|
||||||
|
"state": null,
|
||||||
|
"user": "systemd-resolve",
|
||||||
|
"inode": 26957,
|
||||||
|
"program_name": "systemd-resolve",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 887,
|
||||||
|
"local_port": "domain",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "udp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "raw6",
|
||||||
|
"recv_q": 0,
|
||||||
|
"send_q": 0,
|
||||||
|
"local_address": "[::]",
|
||||||
|
"foreign_address": "[::]",
|
||||||
|
"state": "7",
|
||||||
|
"user": "systemd-network",
|
||||||
|
"inode": 27001,
|
||||||
|
"program_name": "systemd-network",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": 867,
|
||||||
|
"local_port": "ipv6-icmp",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": null,
|
||||||
|
"network_protocol": "ipv6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "unix",
|
||||||
|
"refcnt": 2,
|
||||||
|
"flags": null,
|
||||||
|
"type": "DGRAM",
|
||||||
|
"state": null,
|
||||||
|
"inode": 33322,
|
||||||
|
"program_name": "systemd",
|
||||||
|
"path": "/run/user/1000/systemd/notify",
|
||||||
|
"kind": "socket",
|
||||||
|
"pid": 1607
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "unix",
|
||||||
|
"refcnt": 2,
|
||||||
|
"flags": "ACC",
|
||||||
|
"type": "SEQPACKET",
|
||||||
|
"state": "LISTENING",
|
||||||
|
"inode": 20835,
|
||||||
|
"program_name": "init",
|
||||||
|
"path": "/run/udev/control",
|
||||||
|
"kind": "socket",
|
||||||
|
"pid": 1
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo netstat -apee | jc --netstat -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "0.0.0.0",
|
||||||
|
"state": "LISTEN",
|
||||||
|
"user": "systemd-resolve",
|
||||||
|
"inode": "26958",
|
||||||
|
"program_name": "systemd-resolve",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "887",
|
||||||
|
"local_port": "domain",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "0.0.0.0",
|
||||||
|
"foreign_address": "0.0.0.0",
|
||||||
|
"state": "LISTEN",
|
||||||
|
"user": "root",
|
||||||
|
"inode": "30499",
|
||||||
|
"program_name": "sshd",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "1186",
|
||||||
|
"local_port": "ssh",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "localhost",
|
||||||
|
"state": "ESTABLISHED",
|
||||||
|
"user": "root",
|
||||||
|
"inode": "46829",
|
||||||
|
"program_name": "sshd: root",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "2242",
|
||||||
|
"local_port": "ssh",
|
||||||
|
"foreign_port": "52186",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "localhost",
|
||||||
|
"state": "ESTABLISHED",
|
||||||
|
"user": "root",
|
||||||
|
"inode": "46828",
|
||||||
|
"program_name": "ssh",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "2241",
|
||||||
|
"local_port": "52186",
|
||||||
|
"foreign_port": "ssh",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "tcp6",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "[::]",
|
||||||
|
"foreign_address": "[::]",
|
||||||
|
"state": "LISTEN",
|
||||||
|
"user": "root",
|
||||||
|
"inode": "30510",
|
||||||
|
"program_name": "sshd",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "1186",
|
||||||
|
"local_port": "ssh",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "tcp",
|
||||||
|
"network_protocol": "ipv6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "udp",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "localhost",
|
||||||
|
"foreign_address": "0.0.0.0",
|
||||||
|
"state": null,
|
||||||
|
"user": "systemd-resolve",
|
||||||
|
"inode": "26957",
|
||||||
|
"program_name": "systemd-resolve",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "887",
|
||||||
|
"local_port": "domain",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": "udp",
|
||||||
|
"network_protocol": "ipv4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "raw6",
|
||||||
|
"recv_q": "0",
|
||||||
|
"send_q": "0",
|
||||||
|
"local_address": "[::]",
|
||||||
|
"foreign_address": "[::]",
|
||||||
|
"state": "7",
|
||||||
|
"user": "systemd-network",
|
||||||
|
"inode": "27001",
|
||||||
|
"program_name": "systemd-network",
|
||||||
|
"kind": "network",
|
||||||
|
"pid": "867",
|
||||||
|
"local_port": "ipv6-icmp",
|
||||||
|
"foreign_port": "*",
|
||||||
|
"transport_protocol": null,
|
||||||
|
"network_protocol": "ipv6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "unix",
|
||||||
|
"refcnt": "2",
|
||||||
|
"flags": null,
|
||||||
|
"type": "DGRAM",
|
||||||
|
"state": null,
|
||||||
|
"inode": "33322",
|
||||||
|
"program_name": "systemd",
|
||||||
|
"path": "/run/user/1000/systemd/notify",
|
||||||
|
"kind": "socket",
|
||||||
|
"pid": " 1607"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"proto": "unix",
|
||||||
|
"refcnt": "2",
|
||||||
|
"flags": "ACC",
|
||||||
|
"type": "SEQPACKET",
|
||||||
|
"state": "LISTENING",
|
||||||
|
"inode": "20835",
|
||||||
|
"program_name": "init",
|
||||||
|
"path": "/run/udev/control",
|
||||||
|
"kind": "socket",
|
||||||
|
"pid": " 1"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"proto": string,
|
||||||
|
"recv_q": integer,
|
||||||
|
"send_q": integer,
|
||||||
|
"transport_protocol" string,
|
||||||
|
"network_protocol": string,
|
||||||
|
"local_address": string,
|
||||||
|
"local_port": string,
|
||||||
|
"local_port_num": integer,
|
||||||
|
"foreign_address": string,
|
||||||
|
"foreign_port": string,
|
||||||
|
"foreign_port_num": integer,
|
||||||
|
"state": string,
|
||||||
|
"program_name": string,
|
||||||
|
"pid": integer,
|
||||||
|
"user": string,
|
||||||
|
"security_context": string,
|
||||||
|
"refcnt": integer,
|
||||||
|
"flags": string,
|
||||||
|
"type": string,
|
||||||
|
"inode": integer,
|
||||||
|
"path": string,
|
||||||
|
"kind": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
223
docs/parsers/ps.md
Normal file
223
docs/parsers/ps.md
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
# jc.parsers.ps
|
||||||
|
jc - JSON CLI output utility ps Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --ps as the first argument if the piped input is coming from ps
|
||||||
|
|
||||||
|
ps options supported:
|
||||||
|
- ef
|
||||||
|
- axu
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ ps -ef | jc --ps -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"uid": "root",
|
||||||
|
"pid": 1,
|
||||||
|
"ppid": 0,
|
||||||
|
"c": 0,
|
||||||
|
"stime": "Nov01",
|
||||||
|
"tty": null,
|
||||||
|
"time": "00:00:11",
|
||||||
|
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uid": "root",
|
||||||
|
"pid": 2,
|
||||||
|
"ppid": 0,
|
||||||
|
"c": 0,
|
||||||
|
"stime": "Nov01",
|
||||||
|
"tty": null,
|
||||||
|
"time": "00:00:00",
|
||||||
|
"cmd": "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uid": "root",
|
||||||
|
"pid": 4,
|
||||||
|
"ppid": 2,
|
||||||
|
"c": 0,
|
||||||
|
"stime": "Nov01",
|
||||||
|
"tty": null,
|
||||||
|
"time": "00:00:00",
|
||||||
|
"cmd": "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ps -ef | jc --ps -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"uid": "root",
|
||||||
|
"pid": "1",
|
||||||
|
"ppid": "0",
|
||||||
|
"c": "0",
|
||||||
|
"stime": "Nov01",
|
||||||
|
"tty": "?",
|
||||||
|
"time": "00:00:11",
|
||||||
|
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uid": "root",
|
||||||
|
"pid": "2",
|
||||||
|
"ppid": "0",
|
||||||
|
"c": "0",
|
||||||
|
"stime": "Nov01",
|
||||||
|
"tty": "?",
|
||||||
|
"time": "00:00:00",
|
||||||
|
"cmd": "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uid": "root",
|
||||||
|
"pid": "4",
|
||||||
|
"ppid": "2",
|
||||||
|
"c": "0",
|
||||||
|
"stime": "Nov01",
|
||||||
|
"tty": "?",
|
||||||
|
"time": "00:00:00",
|
||||||
|
"cmd": "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ps axu | jc --ps -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": 1,
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.1",
|
||||||
|
"vsz": "128072",
|
||||||
|
"rss": "6676",
|
||||||
|
"tty": null,
|
||||||
|
"stat": "Ss",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:06",
|
||||||
|
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": 2,
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.0",
|
||||||
|
"vsz": "0",
|
||||||
|
"rss": "0",
|
||||||
|
"tty": null,
|
||||||
|
"stat": "S",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:00",
|
||||||
|
"command": "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": 4,
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.0",
|
||||||
|
"vsz": "0",
|
||||||
|
"rss": "0",
|
||||||
|
"tty": null,
|
||||||
|
"stat": "S<",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:00",
|
||||||
|
"command": "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ps axu | jc --ps -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": "1",
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.1",
|
||||||
|
"vsz": "128072",
|
||||||
|
"rss": "6676",
|
||||||
|
"tty": "?",
|
||||||
|
"stat": "Ss",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:06",
|
||||||
|
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": "2",
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.0",
|
||||||
|
"vsz": "0",
|
||||||
|
"rss": "0",
|
||||||
|
"tty": "?",
|
||||||
|
"stat": "S",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:00",
|
||||||
|
"command": "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": "4",
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.0",
|
||||||
|
"vsz": "0",
|
||||||
|
"rss": "0",
|
||||||
|
"tty": "?",
|
||||||
|
"stat": "S<",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:00",
|
||||||
|
"command": "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"pid": "6",
|
||||||
|
"cpu_percent": "0.0",
|
||||||
|
"mem_percent": "0.0",
|
||||||
|
"vsz": "0",
|
||||||
|
"rss": "0",
|
||||||
|
"tty": "?",
|
||||||
|
"stat": "S",
|
||||||
|
"start": "Nov09",
|
||||||
|
"time": "0:00",
|
||||||
|
"command": "[ksoftirqd/0]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"uid": string,
|
||||||
|
"pid": integer,
|
||||||
|
"ppid": integer,
|
||||||
|
"c": integer,
|
||||||
|
"stime": string,
|
||||||
|
"tty": string, # ? = Null
|
||||||
|
"time": string,
|
||||||
|
"cmd": string,
|
||||||
|
"user": string,
|
||||||
|
"cpu_percent": float,
|
||||||
|
"mem_percent": float,
|
||||||
|
"vsz": integer,
|
||||||
|
"rss": integer,
|
||||||
|
"stat": string,
|
||||||
|
"start": string,
|
||||||
|
"command": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
129
docs/parsers/route.md
Normal file
129
docs/parsers/route.md
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
# jc.parsers.route
|
||||||
|
jc - JSON CLI output utility route Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --route as the first argument if the piped input is coming from route
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ route -ee | jc --route -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"destination": "default",
|
||||||
|
"gateway": "gateway",
|
||||||
|
"genmask": "0.0.0.0",
|
||||||
|
"flags": "UG",
|
||||||
|
"metric": 100,
|
||||||
|
"ref": 0,
|
||||||
|
"use": 0,
|
||||||
|
"iface": "ens33",
|
||||||
|
"mss": 0,
|
||||||
|
"window": 0,
|
||||||
|
"irtt": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"destination": "172.17.0.0",
|
||||||
|
"gateway": "0.0.0.0",
|
||||||
|
"genmask": "255.255.0.0",
|
||||||
|
"flags": "U",
|
||||||
|
"metric": 0,
|
||||||
|
"ref": 0,
|
||||||
|
"use": 0,
|
||||||
|
"iface": "docker",
|
||||||
|
"mss": 0,
|
||||||
|
"window": 0,
|
||||||
|
"irtt": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"destination": "192.168.71.0",
|
||||||
|
"gateway": "0.0.0.0",
|
||||||
|
"genmask": "255.255.255.0",
|
||||||
|
"flags": "U",
|
||||||
|
"metric": 100,
|
||||||
|
"ref": 0,
|
||||||
|
"use": 0,
|
||||||
|
"iface": "ens33",
|
||||||
|
"mss": 0,
|
||||||
|
"window": 0,
|
||||||
|
"irtt": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ route -ee | jc --route -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"destination": "default",
|
||||||
|
"gateway": "gateway",
|
||||||
|
"genmask": "0.0.0.0",
|
||||||
|
"flags": "UG",
|
||||||
|
"metric": "100",
|
||||||
|
"ref": "0",
|
||||||
|
"use": "0",
|
||||||
|
"iface": "ens33",
|
||||||
|
"mss": "0",
|
||||||
|
"window": "0",
|
||||||
|
"irtt": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"destination": "172.17.0.0",
|
||||||
|
"gateway": "0.0.0.0",
|
||||||
|
"genmask": "255.255.0.0",
|
||||||
|
"flags": "U",
|
||||||
|
"metric": "0",
|
||||||
|
"ref": "0",
|
||||||
|
"use": "0",
|
||||||
|
"iface": "docker",
|
||||||
|
"mss": "0",
|
||||||
|
"window": "0",
|
||||||
|
"irtt": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"destination": "192.168.71.0",
|
||||||
|
"gateway": "0.0.0.0",
|
||||||
|
"genmask": "255.255.255.0",
|
||||||
|
"flags": "U",
|
||||||
|
"metric": "100",
|
||||||
|
"ref": "0",
|
||||||
|
"use": "0",
|
||||||
|
"iface": "ens33",
|
||||||
|
"mss": "0",
|
||||||
|
"window": "0",
|
||||||
|
"irtt": "0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"destination": string,
|
||||||
|
"gateway": string,
|
||||||
|
"genmask": string,
|
||||||
|
"flags": string,
|
||||||
|
"metric": integer,
|
||||||
|
"ref": integer,
|
||||||
|
"use": integer,
|
||||||
|
"mss": integer,
|
||||||
|
"window": integer,
|
||||||
|
"irtt": integer,
|
||||||
|
"iface": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
55
docs/parsers/uname.md
Normal file
55
docs/parsers/uname.md
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# jc.parsers.uname
|
||||||
|
jc - JSON CLI output utility uname Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --uname as the first argument if the piped input is coming from uname
|
||||||
|
|
||||||
|
Limitations:
|
||||||
|
must use 'uname -a'
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ uname -a | jc --uname -p
|
||||||
|
{
|
||||||
|
"kernel_name": "Linux",
|
||||||
|
"node_name": "user-ubuntu",
|
||||||
|
"kernel_release": "4.15.0-65-generic",
|
||||||
|
"operating_system": "GNU/Linux",
|
||||||
|
"hardware_platform": "x86_64",
|
||||||
|
"processor": "x86_64",
|
||||||
|
"machine": "x86_64",
|
||||||
|
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||||
|
}
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"kernel_name": string,
|
||||||
|
"node_name": string,
|
||||||
|
"kernel_release": string,
|
||||||
|
"operating_system": string,
|
||||||
|
"hardware_platform": string,
|
||||||
|
"processor": string,
|
||||||
|
"machine": string,
|
||||||
|
"kernel_version": string
|
||||||
|
}
|
||||||
|
|
||||||
|
no extra processing
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
56
docs/parsers/uptime.md
Normal file
56
docs/parsers/uptime.md
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# jc.parsers.uptime
|
||||||
|
jc - JSON CLI output utility uptime Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --uptime as the first argument if the piped input is coming from uptime
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
$ uptime | jc --uptime -p
|
||||||
|
{
|
||||||
|
"time": "11:30:44",
|
||||||
|
"uptime": "1 day, 21:17",
|
||||||
|
"users": 1,
|
||||||
|
"load_1m": 0.01,
|
||||||
|
"load_5m": 0.04,
|
||||||
|
"load_15m": 0.05
|
||||||
|
}
|
||||||
|
|
||||||
|
$ uptime | jc --uptime -p -r
|
||||||
|
{
|
||||||
|
"time": "11:31:09",
|
||||||
|
"uptime": "1 day, 21:17",
|
||||||
|
"users": "1",
|
||||||
|
"load_1m": "0.00",
|
||||||
|
"load_5m": "0.04",
|
||||||
|
"load_15m": "0.05"
|
||||||
|
}
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
{
|
||||||
|
"time": string,
|
||||||
|
"uptime": string,
|
||||||
|
"users": integer,
|
||||||
|
"load_1m": float,
|
||||||
|
"load_5m": float,
|
||||||
|
"load_15m": float
|
||||||
|
}
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
108
docs/parsers/w.md
Normal file
108
docs/parsers/w.md
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
# jc.parsers.w
|
||||||
|
jc - JSON CLI output utility w Parser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
specify --w as the first argument if the piped input is coming from w
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
$ w | jc --w -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"tty": "tty1",
|
||||||
|
"from": null,
|
||||||
|
"login_at": "07:49",
|
||||||
|
"idle": "1:15m",
|
||||||
|
"jcpu": "0.00s",
|
||||||
|
"pcpu": "0.00s",
|
||||||
|
"what": "-bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"tty": "ttyS0",
|
||||||
|
"from": null,
|
||||||
|
"login_at": "06:24",
|
||||||
|
"idle": "0.00s",
|
||||||
|
"jcpu": "0.43s",
|
||||||
|
"pcpu": "0.00s",
|
||||||
|
"what": "w"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "root",
|
||||||
|
"tty": "pts/0",
|
||||||
|
"from": "192.168.71.1",
|
||||||
|
"login_at": "06:29",
|
||||||
|
"idle": "2:35m",
|
||||||
|
"jcpu": "0.00s",
|
||||||
|
"pcpu": "0.00s",
|
||||||
|
"what": "-bash"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ w | jc --w -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": "kbrazil",
|
||||||
|
"tty": "tty1",
|
||||||
|
"from": "-",
|
||||||
|
"login_at": "07:49",
|
||||||
|
"idle": "1:16m",
|
||||||
|
"jcpu": "0.00s",
|
||||||
|
"pcpu": "0.00s",
|
||||||
|
"what": "-bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "kbrazil",
|
||||||
|
"tty": "ttyS0",
|
||||||
|
"from": "-",
|
||||||
|
"login_at": "06:24",
|
||||||
|
"idle": "2.00s",
|
||||||
|
"jcpu": "0.46s",
|
||||||
|
"pcpu": "0.00s",
|
||||||
|
"what": "w"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "kbrazil",
|
||||||
|
"tty": "pts/0",
|
||||||
|
"from": "192.168.71.1",
|
||||||
|
"login_at": "06:29",
|
||||||
|
"idle": "2:36m",
|
||||||
|
"jcpu": "0.00s",
|
||||||
|
"pcpu": "0.00s",
|
||||||
|
"what": "-bash"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## process
|
||||||
|
```python
|
||||||
|
process(proc_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"user": string, # '-'' = null
|
||||||
|
"tty": string, # '-'' = null
|
||||||
|
"from": string, # '-'' = null
|
||||||
|
"login_at": string, # '-'' = null
|
||||||
|
"idle": string, # '-'' = null
|
||||||
|
"jcpu": string,
|
||||||
|
"pcpu": string,
|
||||||
|
"what": string # '-'' = null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
## parse
|
||||||
|
```python
|
||||||
|
parse(data, raw=False, quiet=False)
|
||||||
|
```
|
||||||
|
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
|
79
docs/readme.md
Normal file
79
docs/readme.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# jc
|
||||||
|
JC - JSON CLI output utility
|
||||||
|
|
||||||
|
* kellyjonbrazil@gmail.com
|
||||||
|
|
||||||
|
This package serializes the output of many standard unix command line tools to JSON format.
|
||||||
|
|
||||||
|
CLI Example:
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filename": "apropos",
|
||||||
|
"link_to": "whatis",
|
||||||
|
"flags": "lrwxrwxrwx.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "6",
|
||||||
|
"date": "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "arch",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "33080",
|
||||||
|
"date": "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "awk",
|
||||||
|
"link_to": "gawk",
|
||||||
|
"flags": "lrwxrwxrwx.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "4",
|
||||||
|
"date": "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "base64",
|
||||||
|
"flags": "-rwxr-xr-x.",
|
||||||
|
"links": "1",
|
||||||
|
"owner": "root",
|
||||||
|
"group": "root",
|
||||||
|
"size": "37360",
|
||||||
|
"date": "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
Module Example:
|
||||||
|
|
||||||
|
>>> import jc.parsers.ls
|
||||||
|
>>>
|
||||||
|
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
|
||||||
|
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
|
||||||
|
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
|
||||||
|
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
|
||||||
|
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
|
||||||
|
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
|
||||||
|
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
|
||||||
|
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
|
||||||
|
>>>
|
||||||
|
>>> jc.parsers.ls.parse(data)
|
||||||
|
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
||||||
|
'size': '23648', 'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x',
|
||||||
|
'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '30016', 'date': 'May 3 22:26'},
|
||||||
|
{'filename': 'cp', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
||||||
|
'size': '29024', 'date': 'May 3 22:26'}, {'filename': 'csh', 'flags': '-rwxr-xr-x', 'links': '1',
|
||||||
|
'owner': 'root', 'group': 'wheel', 'size': '375824', 'date': 'May 3 22:26'}, {'filename': 'date',
|
||||||
|
'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '28608',
|
||||||
|
'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root',
|
||||||
|
'group': 'wheel', 'size': '32000', 'date': 'May 3 22:26'}, {'filename': 'df', 'flags': '-rwxr-xr-x',
|
||||||
|
'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '23392', 'date': 'May 3 22:26'},
|
||||||
|
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
||||||
|
'size': '18128', 'date': 'May 3 22:26'}]
|
||||||
|
|
22
docs/utils.md
Normal file
22
docs/utils.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# utils
|
||||||
|
jc - JSON CLI output utility utils
|
||||||
|
## warning_message
|
||||||
|
```python
|
||||||
|
warning_message(message)
|
||||||
|
```
|
||||||
|
Prints a warning message for non-fatal issues
|
||||||
|
## error_message
|
||||||
|
```python
|
||||||
|
error_message(message)
|
||||||
|
```
|
||||||
|
Prints an error message for fatal issues
|
||||||
|
## compatibility
|
||||||
|
```python
|
||||||
|
compatibility(mod_name, compatible)
|
||||||
|
```
|
||||||
|
Checks for the parser's compatibility with the running OS platform.
|
||||||
|
|
||||||
|
compatible options:
|
||||||
|
|
||||||
|
linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
135
jc/__init__.py
135
jc/__init__.py
@ -2,80 +2,79 @@
|
|||||||
|
|
||||||
* kellyjonbrazil@gmail.com
|
* kellyjonbrazil@gmail.com
|
||||||
|
|
||||||
This module serializes standard unix command line output to structured JSON
|
This package serializes the output of many standard unix command line tools to JSON format.
|
||||||
output.
|
|
||||||
|
|
||||||
CLI Example:
|
CLI Example:
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls -p
|
$ ls -l /usr/bin | jc --ls -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": "apropos",
|
"filename": "apropos",
|
||||||
"link_to": "whatis",
|
"link_to": "whatis",
|
||||||
"flags": "lrwxrwxrwx.",
|
"flags": "lrwxrwxrwx.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "6",
|
"size": "6",
|
||||||
"date": "Aug 15 10:53"
|
"date": "Aug 15 10:53"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "arch",
|
"filename": "arch",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "33080",
|
"size": "33080",
|
||||||
"date": "Aug 19 23:25"
|
"date": "Aug 19 23:25"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "awk",
|
"filename": "awk",
|
||||||
"link_to": "gawk",
|
"link_to": "gawk",
|
||||||
"flags": "lrwxrwxrwx.",
|
"flags": "lrwxrwxrwx.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "4",
|
"size": "4",
|
||||||
"date": "Aug 15 10:53"
|
"date": "Aug 15 10:53"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "base64",
|
"filename": "base64",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "37360",
|
"size": "37360",
|
||||||
"date": "Aug 19 23:25"
|
"date": "Aug 19 23:25"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
Module Example:
|
Module Example:
|
||||||
|
|
||||||
>>> import jc.parsers.ls
|
>>> import jc.parsers.ls
|
||||||
>>>
|
>>>
|
||||||
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
|
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
|
||||||
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
|
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
|
||||||
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
|
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
|
||||||
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
|
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
|
||||||
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
|
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
|
||||||
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
|
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
|
||||||
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
|
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
|
||||||
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
|
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
|
||||||
>>>
|
>>>
|
||||||
>>> jc.parsers.ls.parse(data)
|
>>> jc.parsers.ls.parse(data)
|
||||||
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
||||||
'size': '23648', 'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x',
|
'size': '23648', 'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x',
|
||||||
'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '30016', 'date': 'May 3 22:26'},
|
'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '30016', 'date': 'May 3 22:26'},
|
||||||
{'filename': 'cp', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
{'filename': 'cp', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
||||||
'size': '29024', 'date': 'May 3 22:26'}, {'filename': 'csh', 'flags': '-rwxr-xr-x', 'links': '1',
|
'size': '29024', 'date': 'May 3 22:26'}, {'filename': 'csh', 'flags': '-rwxr-xr-x', 'links': '1',
|
||||||
'owner': 'root', 'group': 'wheel', 'size': '375824', 'date': 'May 3 22:26'}, {'filename': 'date',
|
'owner': 'root', 'group': 'wheel', 'size': '375824', 'date': 'May 3 22:26'}, {'filename': 'date',
|
||||||
'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '28608',
|
'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '28608',
|
||||||
'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root',
|
'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root',
|
||||||
'group': 'wheel', 'size': '32000', 'date': 'May 3 22:26'}, {'filename': 'df', 'flags': '-rwxr-xr-x',
|
'group': 'wheel', 'size': '32000', 'date': 'May 3 22:26'}, {'filename': 'df', 'flags': '-rwxr-xr-x',
|
||||||
'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '23392', 'date': 'May 3 22:26'},
|
'links': '1', 'owner': 'root', 'group': 'wheel', 'size': '23392', 'date': 'May 3 22:26'},
|
||||||
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': '1', 'owner': 'root', 'group': 'wheel',
|
||||||
'size': '18128', 'date': 'May 3 22:26'}]
|
'size': '18128', 'date': 'May 3 22:26'}]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = 'jc'
|
name = 'jc'
|
||||||
|
@ -5,95 +5,96 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ arp | jc --arp -p
|
$ arp | jc --arp -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"address": "192.168.71.254",
|
"address": "192.168.71.254",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
"hwaddress": "00:50:56:f0:98:26",
|
"hwaddress": "00:50:56:f0:98:26",
|
||||||
"flags_mask": "C",
|
"flags_mask": "C",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "gateway",
|
"address": "gateway",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
"flags_mask": "C",
|
"flags_mask": "C",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ arp | jc --arp -p -r
|
$ arp | jc --arp -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"address": "gateway",
|
"address": "gateway",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
"flags_mask": "C",
|
"flags_mask": "C",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "192.168.71.254",
|
"address": "192.168.71.254",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
"hwaddress": "00:50:56:fe:7a:b4",
|
"hwaddress": "00:50:56:fe:7a:b4",
|
||||||
"flags_mask": "C",
|
"flags_mask": "C",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ arp -a | jc --arp -p
|
$ arp -a | jc --arp -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"address": "192.168.71.254",
|
"address": "192.168.71.254",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
"hwaddress": "00:50:56:f0:98:26",
|
"hwaddress": "00:50:56:f0:98:26",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gateway",
|
"name": "gateway",
|
||||||
"address": "192.168.71.2",
|
"address": "192.168.71.2",
|
||||||
"hwtype": "ether",
|
"hwtype": "ether",
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
"iface": "ens33"
|
"iface": "ens33"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
$ arp -a | jc --arp -p -r
|
||||||
$ arp -a | jc --arp -p -r
|
[
|
||||||
[
|
{
|
||||||
{
|
"name": "?",
|
||||||
"name": "?",
|
"address": "192.168.71.254",
|
||||||
"address": "192.168.71.254",
|
"hwtype": "ether",
|
||||||
"hwtype": "ether",
|
"hwaddress": "00:50:56:fe:7a:b4",
|
||||||
"hwaddress": "00:50:56:fe:7a:b4",
|
"iface": "ens33"
|
||||||
"iface": "ens33"
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "_gateway",
|
||||||
"name": "_gateway",
|
"address": "192.168.71.2",
|
||||||
"address": "192.168.71.2",
|
"hwtype": "ether",
|
||||||
"hwtype": "ether",
|
"hwaddress": "00:50:56:f7:4a:fc",
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
"iface": "ens33"
|
||||||
"iface": "ens33"
|
}
|
||||||
}
|
]
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"name": string,
|
[
|
||||||
"address": string,
|
{
|
||||||
"hwtype": string,
|
"name": string,
|
||||||
"hwaddress": string,
|
"address": string,
|
||||||
"flags_mask": string,
|
"hwtype": string,
|
||||||
"iface": string
|
"hwaddress": string,
|
||||||
}
|
"flags_mask": string,
|
||||||
]
|
"iface": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
# in BSD style, change name to null if it is a question mark
|
# in BSD style, change name to null if it is a question mark
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
@ -104,6 +105,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'aix', 'freebsd']
|
compatible = ['linux', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
127
jc/parsers/df.py
127
jc/parsers/df.py
@ -5,69 +5,71 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ df | jc --df -p
|
$ df | jc --df -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filesystem": "devtmpfs",
|
"filesystem": "devtmpfs",
|
||||||
"1k-blocks": 1918820,
|
"1k-blocks": 1918820,
|
||||||
"used": 0,
|
"used": 0,
|
||||||
"available": 1918820,
|
"available": 1918820,
|
||||||
"use_percent": 0,
|
"use_percent": 0,
|
||||||
"mounted_on": "/dev"
|
"mounted_on": "/dev"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filesystem": "tmpfs",
|
"filesystem": "tmpfs",
|
||||||
"1k-blocks": 1930668,
|
"1k-blocks": 1930668,
|
||||||
"used": 0,
|
"used": 0,
|
||||||
"available": 1930668,
|
"available": 1930668,
|
||||||
"use_percent": 0,
|
"use_percent": 0,
|
||||||
"mounted_on": "/dev/shm"
|
"mounted_on": "/dev/shm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filesystem": "tmpfs",
|
"filesystem": "tmpfs",
|
||||||
"1k-blocks": 1930668,
|
"1k-blocks": 1930668,
|
||||||
"used": 11800,
|
"used": 11800,
|
||||||
"available": 1918868,
|
"available": 1918868,
|
||||||
"use_percent": 1,
|
"use_percent": 1,
|
||||||
"mounted_on": "/run"
|
"mounted_on": "/run"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ df | jc --df -p -r
|
$ df | jc --df -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filesystem": "devtmpfs",
|
"filesystem": "devtmpfs",
|
||||||
"1k-blocks": "1918820",
|
"1k-blocks": "1918820",
|
||||||
"used": "0",
|
"used": "0",
|
||||||
"available": "1918820",
|
"available": "1918820",
|
||||||
"use_percent": "0%",
|
"use_percent": "0%",
|
||||||
"mounted_on": "/dev"
|
"mounted_on": "/dev"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filesystem": "tmpfs",
|
"filesystem": "tmpfs",
|
||||||
"1k-blocks": "1930668",
|
"1k-blocks": "1930668",
|
||||||
"used": "0",
|
"used": "0",
|
||||||
"available": "1930668",
|
"available": "1930668",
|
||||||
"use_percent": "0%",
|
"use_percent": "0%",
|
||||||
"mounted_on": "/dev/shm"
|
"mounted_on": "/dev/shm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filesystem": "tmpfs",
|
"filesystem": "tmpfs",
|
||||||
"1k-blocks": "1930668",
|
"1k-blocks": "1930668",
|
||||||
"used": "11800",
|
"used": "11800",
|
||||||
"available": "1918868",
|
"available": "1918868",
|
||||||
"use_percent": "1%",
|
"use_percent": "1%",
|
||||||
"mounted_on": "/run"
|
"mounted_on": "/run"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
''' schema:
|
"""
|
||||||
|
schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filesystem": string,
|
"filesystem": string,
|
||||||
@ -79,7 +81,7 @@ def process(proc_data):
|
|||||||
"mounted_on": string
|
"mounted_on": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
'''
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# change any entry for key with '-blocks' in the name to int
|
# change any entry for key with '-blocks' in the name to int
|
||||||
for k in entry:
|
for k in entry:
|
||||||
@ -108,6 +110,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,196 +5,199 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
|
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"id": "28182",
|
|
||||||
"opcode": "QUERY",
|
|
||||||
"status": "NOERROR",
|
|
||||||
"flags": "qr rd ra",
|
|
||||||
"query_num": "1",
|
|
||||||
"answer_num": "4",
|
|
||||||
"authority_num": "0",
|
|
||||||
"additional_num": "1",
|
|
||||||
"question": {
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A"
|
|
||||||
},
|
|
||||||
"answer": [
|
|
||||||
{
|
{
|
||||||
"name": "cnn.com.",
|
"id": "28182",
|
||||||
"class": "IN",
|
"opcode": "QUERY",
|
||||||
"type": "A",
|
"status": "NOERROR",
|
||||||
"ttl": "5",
|
"flags": "qr rd ra",
|
||||||
"data": "151.101.193.67"
|
"query_num": "1",
|
||||||
|
"answer_num": "4",
|
||||||
|
"authority_num": "0",
|
||||||
|
"additional_num": "1",
|
||||||
|
"question": {
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A"
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.193.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.1.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.129.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "A",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "151.101.65.67"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": "45 msec",
|
||||||
|
"server": "192.168.71.2#53(192.168.71.2)",
|
||||||
|
"when": "Wed Oct 30 03:11:21 PDT 2019",
|
||||||
|
"rcvd": "100"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cnn.com.",
|
"id": "23264",
|
||||||
"class": "IN",
|
"opcode": "QUERY",
|
||||||
"type": "A",
|
"status": "NOERROR",
|
||||||
"ttl": "5",
|
"flags": "qr aa rd",
|
||||||
"data": "151.101.1.67"
|
"query_num": "1",
|
||||||
},
|
"answer_num": "1",
|
||||||
{
|
"authority_num": "4",
|
||||||
"name": "cnn.com.",
|
"additional_num": "1",
|
||||||
"class": "IN",
|
"question": {
|
||||||
"type": "A",
|
"name": "www.cnn.com.",
|
||||||
"ttl": "5",
|
"class": "IN",
|
||||||
"data": "151.101.129.67"
|
"type": "A"
|
||||||
},
|
},
|
||||||
{
|
"answer": [
|
||||||
"name": "cnn.com.",
|
{
|
||||||
"class": "IN",
|
"name": "www.cnn.com.",
|
||||||
"type": "A",
|
"class": "IN",
|
||||||
"ttl": "5",
|
"type": "CNAME",
|
||||||
"data": "151.101.65.67"
|
"ttl": "300",
|
||||||
|
"data": "turner-tls.map.fastly.net."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authority": [
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-1086.awsdns-07.org."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-1630.awsdns-11.co.uk."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-47.awsdns-05.com."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn.com.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "NS",
|
||||||
|
"ttl": "3600",
|
||||||
|
"data": "ns-576.awsdns-08.net."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": "33 msec",
|
||||||
|
"server": "205.251.194.64#53(205.251.194.64)",
|
||||||
|
"when": "Wed Oct 30 03:11:21 PDT 2019",
|
||||||
|
"rcvd": "212"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"query_time": "45 msec",
|
|
||||||
"server": "192.168.71.2#53(192.168.71.2)",
|
|
||||||
"when": "Wed Oct 30 03:11:21 PDT 2019",
|
|
||||||
"rcvd": "100"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "23264",
|
|
||||||
"opcode": "QUERY",
|
|
||||||
"status": "NOERROR",
|
|
||||||
"flags": "qr aa rd",
|
|
||||||
"query_num": "1",
|
|
||||||
"answer_num": "1",
|
|
||||||
"authority_num": "4",
|
|
||||||
"additional_num": "1",
|
|
||||||
"question": {
|
|
||||||
"name": "www.cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A"
|
|
||||||
},
|
|
||||||
"answer": [
|
|
||||||
{
|
|
||||||
"name": "www.cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "CNAME",
|
|
||||||
"ttl": "300",
|
|
||||||
"data": "turner-tls.map.fastly.net."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"authority": [
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "NS",
|
|
||||||
"ttl": "3600",
|
|
||||||
"data": "ns-1086.awsdns-07.org."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "NS",
|
|
||||||
"ttl": "3600",
|
|
||||||
"data": "ns-1630.awsdns-11.co.uk."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "NS",
|
|
||||||
"ttl": "3600",
|
|
||||||
"data": "ns-47.awsdns-05.com."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "NS",
|
|
||||||
"ttl": "3600",
|
|
||||||
"data": "ns-576.awsdns-08.net."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"query_time": "33 msec",
|
|
||||||
"server": "205.251.194.64#53(205.251.194.64)",
|
|
||||||
"when": "Wed Oct 30 03:11:21 PDT 2019",
|
|
||||||
"rcvd": "212"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ dig -x 1.1.1.1 | jc --dig -p
|
$ dig -x 1.1.1.1 | jc --dig -p
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"id": "27526",
|
|
||||||
"opcode": "QUERY",
|
|
||||||
"status": "NOERROR",
|
|
||||||
"flags": "qr rd ra",
|
|
||||||
"query_num": "1",
|
|
||||||
"answer_num": "1",
|
|
||||||
"authority_num": "0",
|
|
||||||
"additional_num": "1",
|
|
||||||
"question": {
|
|
||||||
"name": "1.1.1.1.in-addr.arpa.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "PTR"
|
|
||||||
},
|
|
||||||
"answer": [
|
|
||||||
{
|
{
|
||||||
"name": "1.1.1.1.IN-ADDR.ARPA.",
|
"id": "27526",
|
||||||
"class": "IN",
|
"opcode": "QUERY",
|
||||||
"type": "PTR",
|
"status": "NOERROR",
|
||||||
"ttl": "5",
|
"flags": "qr rd ra",
|
||||||
"data": "one.one.one.one."
|
"query_num": "1",
|
||||||
|
"answer_num": "1",
|
||||||
|
"authority_num": "0",
|
||||||
|
"additional_num": "1",
|
||||||
|
"question": {
|
||||||
|
"name": "1.1.1.1.in-addr.arpa.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "PTR"
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": "1.1.1.1.IN-ADDR.ARPA.",
|
||||||
|
"class": "IN",
|
||||||
|
"type": "PTR",
|
||||||
|
"ttl": "5",
|
||||||
|
"data": "one.one.one.one."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": "34 msec",
|
||||||
|
"server": "192.168.71.2#53(192.168.71.2)",
|
||||||
|
"when": "Wed Oct 30 03:13:48 PDT 2019",
|
||||||
|
"rcvd": "98"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"query_time": "34 msec",
|
|
||||||
"server": "192.168.71.2#53(192.168.71.2)",
|
|
||||||
"when": "Wed Oct 30 03:13:48 PDT 2019",
|
|
||||||
"rcvd": "98"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
''' schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"id": integer,
|
[
|
||||||
"opcode": string,
|
|
||||||
"status": string,
|
|
||||||
"flags": [
|
|
||||||
string
|
|
||||||
],
|
|
||||||
"query_num": integer,
|
|
||||||
"answer_num": integer,
|
|
||||||
"authority_num": integer,
|
|
||||||
"additional_num": integer,
|
|
||||||
"question": {
|
|
||||||
"name": string,
|
|
||||||
"class": string,
|
|
||||||
"type": string
|
|
||||||
},
|
|
||||||
"answer": [
|
|
||||||
{
|
{
|
||||||
"name": string,
|
"id": integer,
|
||||||
"class": string,
|
"opcode": string,
|
||||||
"type": string,
|
"status": string,
|
||||||
"ttl": integer,
|
"flags": [
|
||||||
"data": string
|
string
|
||||||
|
],
|
||||||
|
"query_num": integer,
|
||||||
|
"answer_num": integer,
|
||||||
|
"authority_num": integer,
|
||||||
|
"additional_num": integer,
|
||||||
|
"question": {
|
||||||
|
"name": string,
|
||||||
|
"class": string,
|
||||||
|
"type": string
|
||||||
|
},
|
||||||
|
"answer": [
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"class": string,
|
||||||
|
"type": string,
|
||||||
|
"ttl": integer,
|
||||||
|
"data": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authority": [
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"class": string,
|
||||||
|
"type": string,
|
||||||
|
"ttl": integer,
|
||||||
|
"data": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"query_time": integer, # in msec
|
||||||
|
"server": string,
|
||||||
|
"when": string,
|
||||||
|
"rcvd": integer
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"authority": [
|
"""
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"class": string,
|
|
||||||
"type": string,
|
|
||||||
"ttl": integer,
|
|
||||||
"data": string
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"query_time": integer, # in msec
|
|
||||||
"server": string,
|
|
||||||
"when": string,
|
|
||||||
"rcvd": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
'''
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['id', 'query_num', 'answer_num', 'authority_num', 'additional_num', 'rcvd']
|
int_list = ['id', 'query_num', 'answer_num', 'authority_num', 'additional_num', 'rcvd']
|
||||||
for key in int_list:
|
for key in int_list:
|
||||||
@ -312,6 +315,15 @@ def parse_answer(answer):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -5,56 +5,58 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ env | jc --env -p
|
$ env | jc --env -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "XDG_SESSION_ID",
|
"name": "XDG_SESSION_ID",
|
||||||
"value": "1"
|
"value": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "HOSTNAME",
|
"name": "HOSTNAME",
|
||||||
"value": "localhost.localdomain"
|
"value": "localhost.localdomain"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "TERM",
|
"name": "TERM",
|
||||||
"value": "vt220"
|
"value": "vt220"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SHELL",
|
"name": "SHELL",
|
||||||
"value": "/bin/bash"
|
"value": "/bin/bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "HISTSIZE",
|
"name": "HISTSIZE",
|
||||||
"value": "1000"
|
"value": "1000"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ env | jc --env -p -r
|
$ env | jc --env -p -r
|
||||||
{
|
{
|
||||||
"TERM": "xterm-256color",
|
"TERM": "xterm-256color",
|
||||||
"SHELL": "/bin/bash",
|
"SHELL": "/bin/bash",
|
||||||
"USER": "root",
|
"USER": "root",
|
||||||
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
"PWD": "/root",
|
"PWD": "/root",
|
||||||
"LANG": "en_US.UTF-8",
|
"LANG": "en_US.UTF-8",
|
||||||
"HOME": "/root",
|
"HOME": "/root",
|
||||||
"LOGNAME": "root",
|
"LOGNAME": "root",
|
||||||
"_": "/usr/bin/env"
|
"_": "/usr/bin/env"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"name": string,
|
[
|
||||||
"value": string
|
{
|
||||||
}
|
"name": string,
|
||||||
]
|
"value": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
# rebuild output for added semantic information
|
# rebuild output for added semantic information
|
||||||
processed = []
|
processed = []
|
||||||
@ -68,6 +70,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -5,31 +5,42 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ foo | jc --foo -p
|
$ foo | jc --foo -p
|
||||||
[]
|
[]
|
||||||
|
|
||||||
$ foo | jc --foo -p -r
|
$ foo | jc --foo -p -r
|
||||||
[]
|
[]
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"foo": string,
|
[
|
||||||
"bar": boolean,
|
{
|
||||||
"baz": integer
|
"foo": string,
|
||||||
}
|
"bar": boolean,
|
||||||
]
|
"baz": integer
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
# rebuild output for added semantic information
|
# rebuild output for added semantic information
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -5,61 +5,63 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ free | jc --free -p
|
$ free | jc --free -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": "Mem",
|
"type": "Mem",
|
||||||
"total": 3861340,
|
"total": 3861340,
|
||||||
"used": 220508,
|
"used": 220508,
|
||||||
"free": 3381972,
|
"free": 3381972,
|
||||||
"shared": 11800,
|
"shared": 11800,
|
||||||
"buff_cache": 258860,
|
"buff_cache": 258860,
|
||||||
"available": 3397784
|
"available": 3397784
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Swap",
|
"type": "Swap",
|
||||||
"total": 2097148,
|
"total": 2097148,
|
||||||
"used": 0,
|
"used": 0,
|
||||||
"free": 2097148
|
"free": 2097148
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ free | jc --free -p -r
|
$ free | jc --free -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": "Mem",
|
"type": "Mem",
|
||||||
"total": "2017300",
|
"total": "2017300",
|
||||||
"used": "213104",
|
"used": "213104",
|
||||||
"free": "1148452",
|
"free": "1148452",
|
||||||
"shared": "1176",
|
"shared": "1176",
|
||||||
"buff_cache": "655744",
|
"buff_cache": "655744",
|
||||||
"available": "1622204"
|
"available": "1622204"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Swap",
|
"type": "Swap",
|
||||||
"total": "2097148",
|
"total": "2097148",
|
||||||
"used": "0",
|
"used": "0",
|
||||||
"free": "2097148"
|
"free": "2097148"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"type": string,
|
[
|
||||||
"total": integer,
|
{
|
||||||
"used": integer,
|
"type": string,
|
||||||
"free": integer,
|
"total": integer,
|
||||||
"shared": integer,
|
"used": integer,
|
||||||
"buff_cache": integer,
|
"free": integer,
|
||||||
"available": integer
|
"shared": integer,
|
||||||
}
|
"buff_cache": integer,
|
||||||
]
|
"available": integer
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['total', 'used', 'free', 'shared', 'buff_cache', 'available']
|
int_list = ['total', 'used', 'free', 'shared', 'buff_cache', 'available']
|
||||||
@ -75,6 +77,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,48 +5,50 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ history | jc --history -p
|
$ history | jc --history -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"line": "118",
|
"line": "118",
|
||||||
"command": "sleep 100"
|
"command": "sleep 100"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"line": "119",
|
"line": "119",
|
||||||
"command": "ls /bin"
|
"command": "ls /bin"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"line": "120",
|
"line": "120",
|
||||||
"command": "echo \"hello\""
|
"command": "echo \"hello\""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"line": "121",
|
"line": "121",
|
||||||
"command": "docker images"
|
"command": "docker images"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ history | jc --history -p -r
|
$ history | jc --history -p -r
|
||||||
{
|
{
|
||||||
"118": "sleep 100",
|
"118": "sleep 100",
|
||||||
"119": "ls /bin",
|
"119": "ls /bin",
|
||||||
"120": "echo \"hello\"",
|
"120": "echo \"hello\"",
|
||||||
"121": "docker images",
|
"121": "docker images",
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import jc
|
import jc
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"line": string,
|
[
|
||||||
"command": string
|
{
|
||||||
}
|
"line": string,
|
||||||
]
|
"command": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
# rebuild output for added semantic information
|
# rebuild output for added semantic information
|
||||||
processed = []
|
processed = []
|
||||||
@ -60,6 +62,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -7,154 +7,155 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p
|
$ ifconfig | jc --ifconfig -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "ens33",
|
"name": "ens33",
|
||||||
"flags": 4163,
|
"flags": 4163,
|
||||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
"mtu": 1500,
|
"mtu": 1500,
|
||||||
"ipv4_addr": "192.168.71.138",
|
"ipv4_addr": "192.168.71.138",
|
||||||
"ipv4_mask": "255.255.255.0",
|
"ipv4_mask": "255.255.255.0",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
"ipv4_bcast": "192.168.71.255",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_mask": 64,
|
"ipv6_mask": 64,
|
||||||
"ipv6_scope": "link",
|
"ipv6_scope": "link",
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
"type": "Ethernet",
|
"type": "Ethernet",
|
||||||
"rx_packets": 6374,
|
"rx_packets": 6374,
|
||||||
"rx_errors": 0,
|
"rx_errors": 0,
|
||||||
"rx_dropped": 0,
|
"rx_dropped": 0,
|
||||||
"rx_overruns": 0,
|
"rx_overruns": 0,
|
||||||
"rx_frame": 0,
|
"rx_frame": 0,
|
||||||
"tx_packets": 3707,
|
"tx_packets": 3707,
|
||||||
"tx_errors": 0,
|
"tx_errors": 0,
|
||||||
"tx_dropped": 0,
|
"tx_dropped": 0,
|
||||||
"tx_overruns": 0,
|
"tx_overruns": 0,
|
||||||
"tx_carrier": 0,
|
"tx_carrier": 0,
|
||||||
"tx_collisions": 0,
|
"tx_collisions": 0,
|
||||||
"metric": null
|
"metric": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lo",
|
"name": "lo",
|
||||||
"flags": 73,
|
"flags": 73,
|
||||||
"state": "UP,LOOPBACK,RUNNING",
|
"state": "UP,LOOPBACK,RUNNING",
|
||||||
"mtu": 65536,
|
"mtu": 65536,
|
||||||
"ipv4_addr": "127.0.0.1",
|
"ipv4_addr": "127.0.0.1",
|
||||||
"ipv4_mask": "255.0.0.0",
|
"ipv4_mask": "255.0.0.0",
|
||||||
"ipv4_bcast": null,
|
"ipv4_bcast": null,
|
||||||
"ipv6_addr": "::1",
|
"ipv6_addr": "::1",
|
||||||
"ipv6_mask": 128,
|
"ipv6_mask": 128,
|
||||||
"ipv6_scope": "host",
|
"ipv6_scope": "host",
|
||||||
"mac_addr": null,
|
"mac_addr": null,
|
||||||
"type": "Local Loopback",
|
"type": "Local Loopback",
|
||||||
"rx_packets": 81,
|
"rx_packets": 81,
|
||||||
"rx_errors": 0,
|
"rx_errors": 0,
|
||||||
"rx_dropped": 0,
|
"rx_dropped": 0,
|
||||||
"rx_overruns": 0,
|
"rx_overruns": 0,
|
||||||
"rx_frame": 0,
|
"rx_frame": 0,
|
||||||
"tx_packets": 81,
|
"tx_packets": 81,
|
||||||
"tx_errors": 0,
|
"tx_errors": 0,
|
||||||
"tx_dropped": 0,
|
"tx_dropped": 0,
|
||||||
"tx_overruns": 0,
|
"tx_overruns": 0,
|
||||||
"tx_carrier": 0,
|
"tx_carrier": 0,
|
||||||
"tx_collisions": 0,
|
"tx_collisions": 0,
|
||||||
"metric": null
|
"metric": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
$ ifconfig | jc --ifconfig -p -r
|
||||||
$ ifconfig | jc --ifconfig -p -r
|
[
|
||||||
[
|
{
|
||||||
{
|
"name": "ens33",
|
||||||
"name": "ens33",
|
"flags": "4163",
|
||||||
"flags": "4163",
|
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
"mtu": "1500",
|
||||||
"mtu": "1500",
|
"ipv4_addr": "192.168.71.135",
|
||||||
"ipv4_addr": "192.168.71.135",
|
"ipv4_mask": "255.255.255.0",
|
||||||
"ipv4_mask": "255.255.255.0",
|
"ipv4_bcast": "192.168.71.255",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
"ipv6_mask": "64",
|
||||||
"ipv6_mask": "64",
|
"ipv6_scope": "link",
|
||||||
"ipv6_scope": "link",
|
"mac_addr": "00:0c:29:3b:58:0e",
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
"type": "Ethernet",
|
||||||
"type": "Ethernet",
|
"rx_packets": "26348",
|
||||||
"rx_packets": "26348",
|
"rx_errors": "0",
|
||||||
"rx_errors": "0",
|
"rx_dropped": "0",
|
||||||
"rx_dropped": "0",
|
"rx_overruns": "0",
|
||||||
"rx_overruns": "0",
|
"rx_frame": "0",
|
||||||
"rx_frame": "0",
|
"tx_packets": "5308",
|
||||||
"tx_packets": "5308",
|
"tx_errors": "0",
|
||||||
"tx_errors": "0",
|
"tx_dropped": "0",
|
||||||
"tx_dropped": "0",
|
"tx_overruns": "0",
|
||||||
"tx_overruns": "0",
|
"tx_carrier": "0",
|
||||||
"tx_carrier": "0",
|
"tx_collisions": "0",
|
||||||
"tx_collisions": "0",
|
"metric": null
|
||||||
"metric": null
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "lo",
|
||||||
"name": "lo",
|
"flags": "73",
|
||||||
"flags": "73",
|
"state": "UP,LOOPBACK,RUNNING",
|
||||||
"state": "UP,LOOPBACK,RUNNING",
|
"mtu": "65536",
|
||||||
"mtu": "65536",
|
"ipv4_addr": "127.0.0.1",
|
||||||
"ipv4_addr": "127.0.0.1",
|
"ipv4_mask": "255.0.0.0",
|
||||||
"ipv4_mask": "255.0.0.0",
|
"ipv4_bcast": null,
|
||||||
"ipv4_bcast": null,
|
"ipv6_addr": "::1",
|
||||||
"ipv6_addr": "::1",
|
"ipv6_mask": "128",
|
||||||
"ipv6_mask": "128",
|
"ipv6_scope": "host",
|
||||||
"ipv6_scope": "host",
|
"mac_addr": null,
|
||||||
"mac_addr": null,
|
"type": "Local Loopback",
|
||||||
"type": "Local Loopback",
|
"rx_packets": "64",
|
||||||
"rx_packets": "64",
|
"rx_errors": "0",
|
||||||
"rx_errors": "0",
|
"rx_dropped": "0",
|
||||||
"rx_dropped": "0",
|
"rx_overruns": "0",
|
||||||
"rx_overruns": "0",
|
"rx_frame": "0",
|
||||||
"rx_frame": "0",
|
"tx_packets": "64",
|
||||||
"tx_packets": "64",
|
"tx_errors": "0",
|
||||||
"tx_errors": "0",
|
"tx_dropped": "0",
|
||||||
"tx_dropped": "0",
|
"tx_overruns": "0",
|
||||||
"tx_overruns": "0",
|
"tx_carrier": "0",
|
||||||
"tx_carrier": "0",
|
"tx_collisions": "0",
|
||||||
"tx_collisions": "0",
|
"metric": null
|
||||||
"metric": null
|
}
|
||||||
}
|
]
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from ifconfigparser import IfconfigParser
|
from ifconfigparser import IfconfigParser
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"name": string,
|
[
|
||||||
"flags": integer,
|
{
|
||||||
"state": string,
|
"name": string,
|
||||||
"mtu": integer,
|
"flags": integer,
|
||||||
"ipv4_addr": string,
|
"state": string,
|
||||||
"ipv4_mask": string,
|
"mtu": integer,
|
||||||
"ipv4_bcast": string,
|
"ipv4_addr": string,
|
||||||
"ipv6_addr": string,
|
"ipv4_mask": string,
|
||||||
"ipv6_mask": integer,
|
"ipv4_bcast": string,
|
||||||
"ipv6_scope": string,
|
"ipv6_addr": string,
|
||||||
"mac_addr": string,
|
"ipv6_mask": integer,
|
||||||
"type": string,
|
"ipv6_scope": string,
|
||||||
"rx_packets": integer,
|
"mac_addr": string,
|
||||||
"rx_errors": integer,
|
"type": string,
|
||||||
"rx_dropped": integer,
|
"rx_packets": integer,
|
||||||
"rx_overruns": integer,
|
"rx_errors": integer,
|
||||||
"rx_frame": integer,
|
"rx_dropped": integer,
|
||||||
"tx_packets": integer,
|
"rx_overruns": integer,
|
||||||
"tx_errors": integer,
|
"rx_frame": integer,
|
||||||
"tx_dropped": integer,
|
"tx_packets": integer,
|
||||||
"tx_overruns": integer,
|
"tx_errors": integer,
|
||||||
"tx_carrier": integer,
|
"tx_dropped": integer,
|
||||||
"tx_collisions": integer,
|
"tx_overruns": integer,
|
||||||
"metric": integer
|
"tx_carrier": integer,
|
||||||
}
|
"tx_collisions": integer,
|
||||||
]
|
"metric": integer
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['flags', 'mtu', 'ipv6_mask', 'rx_packets', 'rx_errors', 'rx_dropped', 'rx_overruns',
|
int_list = ['flags', 'mtu', 'ipv6_mask', 'rx_packets', 'rx_errors', 'rx_dropped', 'rx_overruns',
|
||||||
'rx_frame', 'tx_packets', 'tx_errors', 'tx_dropped', 'tx_overruns', 'tx_carrier',
|
'rx_frame', 'tx_packets', 'tx_errors', 'tx_dropped', 'tx_overruns', 'tx_carrier',
|
||||||
@ -171,6 +172,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'aix', 'freebsd']
|
compatible = ['linux', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -7,150 +7,152 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"chain": "PREROUTING",
|
|
||||||
"rules": [
|
|
||||||
{
|
{
|
||||||
"num": 1,
|
"chain": "PREROUTING",
|
||||||
"pkts": 2183,
|
"rules": [
|
||||||
"bytes": 186000,
|
{
|
||||||
"target": "PREROUTING_direct",
|
"num": 1,
|
||||||
"prot": "all",
|
"pkts": 2183,
|
||||||
"opt": null,
|
"bytes": 186000,
|
||||||
"in": "any",
|
"target": "PREROUTING_direct",
|
||||||
"out": "any",
|
"prot": "all",
|
||||||
"source": "anywhere",
|
"opt": null,
|
||||||
"destination": "anywhere"
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": 2,
|
||||||
|
"pkts": 2183,
|
||||||
|
"bytes": 186000,
|
||||||
|
"target": "PREROUTING_ZONES_SOURCE",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": 3,
|
||||||
|
"pkts": 2183,
|
||||||
|
"bytes": 186000,
|
||||||
|
"target": "PREROUTING_ZONES",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": 4,
|
||||||
|
"pkts": 0,
|
||||||
|
"bytes": 0,
|
||||||
|
"target": "DOCKER",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": null,
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere",
|
||||||
|
"options": "ADDRTYPE match dst-type LOCAL"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
...
|
||||||
"num": 2,
|
|
||||||
"pkts": 2183,
|
|
||||||
"bytes": 186000,
|
|
||||||
"target": "PREROUTING_ZONES_SOURCE",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": null,
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": 3,
|
|
||||||
"pkts": 2183,
|
|
||||||
"bytes": 186000,
|
|
||||||
"target": "PREROUTING_ZONES",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": null,
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": 4,
|
|
||||||
"pkts": 0,
|
|
||||||
"bytes": 0,
|
|
||||||
"target": "DOCKER",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": null,
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere",
|
|
||||||
"options": "ADDRTYPE match dst-type LOCAL"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
||||||
[
|
[
|
||||||
{
|
|
||||||
"chain": "PREROUTING",
|
|
||||||
"rules": [
|
|
||||||
{
|
{
|
||||||
"num": "1",
|
"chain": "PREROUTING",
|
||||||
"pkts": "2183",
|
"rules": [
|
||||||
"bytes": "186K",
|
{
|
||||||
"target": "PREROUTING_direct",
|
"num": "1",
|
||||||
"prot": "all",
|
"pkts": "2183",
|
||||||
"opt": "--",
|
"bytes": "186K",
|
||||||
"in": "any",
|
"target": "PREROUTING_direct",
|
||||||
"out": "any",
|
"prot": "all",
|
||||||
"source": "anywhere",
|
"opt": "--",
|
||||||
"destination": "anywhere"
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": "2",
|
||||||
|
"pkts": "2183",
|
||||||
|
"bytes": "186K",
|
||||||
|
"target": "PREROUTING_ZONES_SOURCE",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": "3",
|
||||||
|
"pkts": "2183",
|
||||||
|
"bytes": "186K",
|
||||||
|
"target": "PREROUTING_ZONES",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"num": "4",
|
||||||
|
"pkts": "0",
|
||||||
|
"bytes": "0",
|
||||||
|
"target": "DOCKER",
|
||||||
|
"prot": "all",
|
||||||
|
"opt": "--",
|
||||||
|
"in": "any",
|
||||||
|
"out": "any",
|
||||||
|
"source": "anywhere",
|
||||||
|
"destination": "anywhere",
|
||||||
|
"options": "ADDRTYPE match dst-type LOCAL"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
...
|
||||||
"num": "2",
|
|
||||||
"pkts": "2183",
|
|
||||||
"bytes": "186K",
|
|
||||||
"target": "PREROUTING_ZONES_SOURCE",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": "3",
|
|
||||||
"pkts": "2183",
|
|
||||||
"bytes": "186K",
|
|
||||||
"target": "PREROUTING_ZONES",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": "4",
|
|
||||||
"pkts": "0",
|
|
||||||
"bytes": "0",
|
|
||||||
"target": "DOCKER",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere",
|
|
||||||
"options": "ADDRTYPE match dst-type LOCAL"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"chain": string,
|
[
|
||||||
"rules": [
|
|
||||||
{
|
{
|
||||||
"num" integer,
|
"chain": string,
|
||||||
"pkts": integer,
|
"rules": [
|
||||||
"bytes": integer, # converted based on suffix
|
{
|
||||||
"target": string,
|
"num" integer,
|
||||||
"prot": string,
|
"pkts": integer,
|
||||||
"opt": string, # "--" = Null
|
"bytes": integer, # converted based on suffix
|
||||||
"in": string,
|
"target": string,
|
||||||
"out": string,
|
"prot": string,
|
||||||
"source": string,
|
"opt": string, # "--" = Null
|
||||||
"destination": string,
|
"in": string,
|
||||||
"options": string
|
"out": string,
|
||||||
|
"source": string,
|
||||||
|
"destination": string,
|
||||||
|
"options": string
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
"""
|
||||||
]
|
|
||||||
'''
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
for rule in entry['rules']:
|
for rule in entry['rules']:
|
||||||
int_list = ['num', 'pkts']
|
int_list = ['num', 'pkts']
|
||||||
@ -194,6 +196,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -7,82 +7,83 @@ Usage:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ jobs -l | jc --jobs -p
|
$ jobs -l | jc --jobs -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"job_number": 1,
|
"job_number": 1,
|
||||||
"pid": 5283,
|
"pid": 5283,
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 10000 &"
|
"command": "sleep 10000 &"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"job_number": 2,
|
"job_number": 2,
|
||||||
"pid": 5284,
|
"pid": 5284,
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 10100 &"
|
"command": "sleep 10100 &"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"job_number": 3,
|
"job_number": 3,
|
||||||
"pid": 5285,
|
"pid": 5285,
|
||||||
"history": "previous",
|
"history": "previous",
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 10001 &"
|
"command": "sleep 10001 &"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"job_number": 4,
|
"job_number": 4,
|
||||||
"pid": 5286,
|
"pid": 5286,
|
||||||
"history": "current",
|
"history": "current",
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 10112 &"
|
"command": "sleep 10112 &"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ jobs -l | jc --jobs -p -r
|
$ jobs -l | jc --jobs -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"job_number": "1",
|
"job_number": "1",
|
||||||
"pid": "19510",
|
"pid": "19510",
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 1000 &"
|
"command": "sleep 1000 &"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"job_number": "2",
|
"job_number": "2",
|
||||||
"pid": "19511",
|
"pid": "19511",
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 1001 &"
|
"command": "sleep 1001 &"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"job_number": "3",
|
"job_number": "3",
|
||||||
"pid": "19512",
|
"pid": "19512",
|
||||||
"history": "previous",
|
"history": "previous",
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 1002 &"
|
"command": "sleep 1002 &"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"job_number": "4",
|
"job_number": "4",
|
||||||
"pid": "19513",
|
"pid": "19513",
|
||||||
"history": "current",
|
"history": "current",
|
||||||
"status": "Running",
|
"status": "Running",
|
||||||
"command": "sleep 1003 &"
|
"command": "sleep 1003 &"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import string
|
import string
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
[
|
||||||
"job_number": integer,
|
{
|
||||||
"pid": integer,
|
"job_number": integer,
|
||||||
"history": string,
|
"pid": integer,
|
||||||
"status": string,
|
"history": string,
|
||||||
"command": string
|
"status": string,
|
||||||
}
|
"command": string
|
||||||
]
|
}
|
||||||
'''
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['job_number', 'pid']
|
int_list = ['job_number', 'pid']
|
||||||
for key in int_list:
|
for key in int_list:
|
||||||
@ -97,6 +98,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
274
jc/parsers/ls.py
274
jc/parsers/ls.py
@ -12,146 +12,149 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ls /usr/bin | jc --ls -p
|
$ ls /usr/bin | jc --ls -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": "apropos"
|
"filename": "apropos"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "arch"
|
"filename": "arch"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "awk"
|
"filename": "awk"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "base64"
|
"filename": "base64"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls -p
|
$ ls -l /usr/bin | jc --ls -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": "apropos",
|
"filename": "apropos",
|
||||||
"link_to": "whatis",
|
"link_to": "whatis",
|
||||||
"flags": "lrwxrwxrwx.",
|
"flags": "lrwxrwxrwx.",
|
||||||
"links": 1,
|
"links": 1,
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": 6,
|
"size": 6,
|
||||||
"date": "Aug 15 10:53"
|
"date": "Aug 15 10:53"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "ar",
|
"filename": "ar",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": 1,
|
"links": 1,
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": 62744,
|
"size": 62744,
|
||||||
"date": "Aug 8 16:14"
|
"date": "Aug 8 16:14"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "arch",
|
"filename": "arch",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": 1,
|
"links": 1,
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": 33080,
|
"size": 33080,
|
||||||
"date": "Aug 19 23:25"
|
"date": "Aug 19 23:25"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls -p -r
|
$ ls -l /usr/bin | jc --ls -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": "apropos",
|
"filename": "apropos",
|
||||||
"link_to": "whatis",
|
"link_to": "whatis",
|
||||||
"flags": "lrwxrwxrwx.",
|
"flags": "lrwxrwxrwx.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "6",
|
"size": "6",
|
||||||
"date": "Aug 15 10:53"
|
"date": "Aug 15 10:53"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "arch",
|
"filename": "arch",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "33080",
|
"size": "33080",
|
||||||
"date": "Aug 19 23:25"
|
"date": "Aug 19 23:25"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "awk",
|
"filename": "awk",
|
||||||
"link_to": "gawk",
|
"link_to": "gawk",
|
||||||
"flags": "lrwxrwxrwx.",
|
"flags": "lrwxrwxrwx.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "4",
|
"size": "4",
|
||||||
"date": "Aug 15 10:53"
|
"date": "Aug 15 10:53"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "base64",
|
"filename": "base64",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "37360",
|
"size": "37360",
|
||||||
"date": "Aug 19 23:25"
|
"date": "Aug 19 23:25"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "basename",
|
"filename": "basename",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "29032",
|
"size": "29032",
|
||||||
"date": "Aug 19 23:25"
|
"date": "Aug 19 23:25"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "bash",
|
"filename": "bash",
|
||||||
"flags": "-rwxr-xr-x.",
|
"flags": "-rwxr-xr-x.",
|
||||||
"links": "1",
|
"links": "1",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "root",
|
"group": "root",
|
||||||
"size": "964600",
|
"size": "964600",
|
||||||
"date": "Aug 8 05:06"
|
"date": "Aug 8 05:06"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'
|
$ ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'
|
||||||
{
|
{
|
||||||
"filename": "emacs",
|
"filename": "emacs",
|
||||||
"flags": "-r-xr-xr-x",
|
"flags": "-r-xr-xr-x",
|
||||||
"links": 1,
|
"links": 1,
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "wheel",
|
"group": "wheel",
|
||||||
"size": 117164432,
|
"size": 117164432,
|
||||||
"date": "May 3 2019"
|
"date": "May 3 2019"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"filename": string,
|
[
|
||||||
"flags": string,
|
{
|
||||||
"links": integer,
|
"filename": string,
|
||||||
"owner": string,
|
"flags": string,
|
||||||
"group": string,
|
"links": integer,
|
||||||
"size": integer,
|
"owner": string,
|
||||||
"date": string
|
"group": string,
|
||||||
}
|
"size": integer,
|
||||||
]
|
"date": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['links', 'size']
|
int_list = ['links', 'size']
|
||||||
for key in int_list:
|
for key in int_list:
|
||||||
@ -166,6 +169,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -5,258 +5,260 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ lsblk | jc --lsblk -p
|
$ lsblk | jc --lsblk -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "sda",
|
"name": "sda",
|
||||||
"maj_min": "8:0",
|
"maj_min": "8:0",
|
||||||
"rm": false,
|
"rm": false,
|
||||||
"size": "20G",
|
"size": "20G",
|
||||||
"ro": false,
|
"ro": false,
|
||||||
"type": "disk",
|
"type": "disk",
|
||||||
"mountpoint": null
|
"mountpoint": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sda1",
|
"name": "sda1",
|
||||||
"maj_min": "8:1",
|
"maj_min": "8:1",
|
||||||
"rm": false,
|
"rm": false,
|
||||||
"size": "1G",
|
"size": "1G",
|
||||||
"ro": false,
|
"ro": false,
|
||||||
"type": "part",
|
"type": "part",
|
||||||
"mountpoint": "/boot"
|
"mountpoint": "/boot"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "sda",
|
"name": "sda",
|
||||||
"maj_min": "8:0",
|
"maj_min": "8:0",
|
||||||
"rm": false,
|
"rm": false,
|
||||||
"size": "20G",
|
"size": "20G",
|
||||||
"ro": false,
|
"ro": false,
|
||||||
"type": "disk",
|
"type": "disk",
|
||||||
"mountpoint": null,
|
"mountpoint": null,
|
||||||
"kname": "sda",
|
"kname": "sda",
|
||||||
"fstype": null,
|
"fstype": null,
|
||||||
"label": null,
|
"label": null,
|
||||||
"uuid": null,
|
"uuid": null,
|
||||||
"partlabel": null,
|
"partlabel": null,
|
||||||
"partuuid": null,
|
"partuuid": null,
|
||||||
"ra": 4096,
|
"ra": 4096,
|
||||||
"model": "VMware Virtual S",
|
"model": "VMware Virtual S",
|
||||||
"serial": null,
|
"serial": null,
|
||||||
"state": "running",
|
"state": "running",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "disk",
|
"group": "disk",
|
||||||
"mode": "brw-rw----",
|
"mode": "brw-rw----",
|
||||||
"alignment": 0,
|
"alignment": 0,
|
||||||
"min_io": 512,
|
"min_io": 512,
|
||||||
"opt_io": 0,
|
"opt_io": 0,
|
||||||
"phy_sec": 512,
|
"phy_sec": 512,
|
||||||
"log_sec": 512,
|
"log_sec": 512,
|
||||||
"rota": true,
|
"rota": true,
|
||||||
"sched": "deadline",
|
"sched": "deadline",
|
||||||
"rq_size": 128,
|
"rq_size": 128,
|
||||||
"disc_aln": 0,
|
"disc_aln": 0,
|
||||||
"disc_gran": "0B",
|
"disc_gran": "0B",
|
||||||
"disc_max": "0B",
|
"disc_max": "0B",
|
||||||
"disc_zero": false,
|
"disc_zero": false,
|
||||||
"wsame": "32M",
|
"wsame": "32M",
|
||||||
"wwn": null,
|
"wwn": null,
|
||||||
"rand": true,
|
"rand": true,
|
||||||
"pkname": null,
|
"pkname": null,
|
||||||
"hctl": "0:0:0:0",
|
"hctl": "0:0:0:0",
|
||||||
"tran": "spi",
|
"tran": "spi",
|
||||||
"rev": "1.0",
|
"rev": "1.0",
|
||||||
"vendor": "VMware,"
|
"vendor": "VMware,"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sda1",
|
"name": "sda1",
|
||||||
"maj_min": "8:1",
|
"maj_min": "8:1",
|
||||||
"rm": false,
|
"rm": false,
|
||||||
"size": "1G",
|
"size": "1G",
|
||||||
"ro": false,
|
"ro": false,
|
||||||
"type": "part",
|
"type": "part",
|
||||||
"mountpoint": "/boot",
|
"mountpoint": "/boot",
|
||||||
"kname": "sda1",
|
"kname": "sda1",
|
||||||
"fstype": "xfs",
|
"fstype": "xfs",
|
||||||
"label": null,
|
"label": null,
|
||||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
"partlabel": null,
|
"partlabel": null,
|
||||||
"partuuid": null,
|
"partuuid": null,
|
||||||
"ra": 4096,
|
"ra": 4096,
|
||||||
"model": null,
|
"model": null,
|
||||||
"serial": null,
|
"serial": null,
|
||||||
"state": null,
|
"state": null,
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "disk",
|
"group": "disk",
|
||||||
"mode": "brw-rw----",
|
"mode": "brw-rw----",
|
||||||
"alignment": 0,
|
"alignment": 0,
|
||||||
"min_io": 512,
|
"min_io": 512,
|
||||||
"opt_io": 0,
|
"opt_io": 0,
|
||||||
"phy_sec": 512,
|
"phy_sec": 512,
|
||||||
"log_sec": 512,
|
"log_sec": 512,
|
||||||
"rota": true,
|
"rota": true,
|
||||||
"sched": "deadline",
|
"sched": "deadline",
|
||||||
"rq_size": 128,
|
"rq_size": 128,
|
||||||
"disc_aln": 0,
|
"disc_aln": 0,
|
||||||
"disc_gran": "0B",
|
"disc_gran": "0B",
|
||||||
"disc_max": "0B",
|
"disc_max": "0B",
|
||||||
"disc_zero": false,
|
"disc_zero": false,
|
||||||
"wsame": "32M",
|
"wsame": "32M",
|
||||||
"wwn": null,
|
"wwn": null,
|
||||||
"rand": true,
|
"rand": true,
|
||||||
"pkname": "sda",
|
"pkname": "sda",
|
||||||
"hctl": null,
|
"hctl": null,
|
||||||
"tran": null,
|
"tran": null,
|
||||||
"rev": null,
|
"rev": null,
|
||||||
"vendor": null
|
"vendor": null
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "sda",
|
"name": "sda",
|
||||||
"maj_min": "8:0",
|
"maj_min": "8:0",
|
||||||
"rm": "0",
|
"rm": "0",
|
||||||
"size": "20G",
|
"size": "20G",
|
||||||
"ro": "0",
|
"ro": "0",
|
||||||
"type": "disk",
|
"type": "disk",
|
||||||
"mountpoint": null,
|
"mountpoint": null,
|
||||||
"kname": "sda",
|
"kname": "sda",
|
||||||
"fstype": null,
|
"fstype": null,
|
||||||
"label": null,
|
"label": null,
|
||||||
"uuid": null,
|
"uuid": null,
|
||||||
"partlabel": null,
|
"partlabel": null,
|
||||||
"partuuid": null,
|
"partuuid": null,
|
||||||
"ra": "4096",
|
"ra": "4096",
|
||||||
"model": "VMware Virtual S",
|
"model": "VMware Virtual S",
|
||||||
"serial": null,
|
"serial": null,
|
||||||
"state": "running",
|
"state": "running",
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "disk",
|
"group": "disk",
|
||||||
"mode": "brw-rw----",
|
"mode": "brw-rw----",
|
||||||
"alignment": "0",
|
"alignment": "0",
|
||||||
"min_io": "512",
|
"min_io": "512",
|
||||||
"opt_io": "0",
|
"opt_io": "0",
|
||||||
"phy_sec": "512",
|
"phy_sec": "512",
|
||||||
"log_sec": "512",
|
"log_sec": "512",
|
||||||
"rota": "1",
|
"rota": "1",
|
||||||
"sched": "deadline",
|
"sched": "deadline",
|
||||||
"rq_size": "128",
|
"rq_size": "128",
|
||||||
"disc_aln": "0",
|
"disc_aln": "0",
|
||||||
"disc_gran": "0B",
|
"disc_gran": "0B",
|
||||||
"disc_max": "0B",
|
"disc_max": "0B",
|
||||||
"disc_zero": "0",
|
"disc_zero": "0",
|
||||||
"wsame": "32M",
|
"wsame": "32M",
|
||||||
"wwn": null,
|
"wwn": null,
|
||||||
"rand": "1",
|
"rand": "1",
|
||||||
"pkname": null,
|
"pkname": null,
|
||||||
"hctl": "0:0:0:0",
|
"hctl": "0:0:0:0",
|
||||||
"tran": "spi",
|
"tran": "spi",
|
||||||
"rev": "1.0",
|
"rev": "1.0",
|
||||||
"vendor": "VMware,"
|
"vendor": "VMware,"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sda1",
|
"name": "sda1",
|
||||||
"maj_min": "8:1",
|
"maj_min": "8:1",
|
||||||
"rm": "0",
|
"rm": "0",
|
||||||
"size": "1G",
|
"size": "1G",
|
||||||
"ro": "0",
|
"ro": "0",
|
||||||
"type": "part",
|
"type": "part",
|
||||||
"mountpoint": "/boot",
|
"mountpoint": "/boot",
|
||||||
"kname": "sda1",
|
"kname": "sda1",
|
||||||
"fstype": "xfs",
|
"fstype": "xfs",
|
||||||
"label": null,
|
"label": null,
|
||||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
"partlabel": null,
|
"partlabel": null,
|
||||||
"partuuid": null,
|
"partuuid": null,
|
||||||
"ra": "4096",
|
"ra": "4096",
|
||||||
"model": null,
|
"model": null,
|
||||||
"serial": null,
|
"serial": null,
|
||||||
"state": null,
|
"state": null,
|
||||||
"owner": "root",
|
"owner": "root",
|
||||||
"group": "disk",
|
"group": "disk",
|
||||||
"mode": "brw-rw----",
|
"mode": "brw-rw----",
|
||||||
"alignment": "0",
|
"alignment": "0",
|
||||||
"min_io": "512",
|
"min_io": "512",
|
||||||
"opt_io": "0",
|
"opt_io": "0",
|
||||||
"phy_sec": "512",
|
"phy_sec": "512",
|
||||||
"log_sec": "512",
|
"log_sec": "512",
|
||||||
"rota": "1",
|
"rota": "1",
|
||||||
"sched": "deadline",
|
"sched": "deadline",
|
||||||
"rq_size": "128",
|
"rq_size": "128",
|
||||||
"disc_aln": "0",
|
"disc_aln": "0",
|
||||||
"disc_gran": "0B",
|
"disc_gran": "0B",
|
||||||
"disc_max": "0B",
|
"disc_max": "0B",
|
||||||
"disc_zero": "0",
|
"disc_zero": "0",
|
||||||
"wsame": "32M",
|
"wsame": "32M",
|
||||||
"wwn": null,
|
"wwn": null,
|
||||||
"rand": "1",
|
"rand": "1",
|
||||||
"pkname": "sda",
|
"pkname": "sda",
|
||||||
"hctl": null,
|
"hctl": null,
|
||||||
"tran": null,
|
"tran": null,
|
||||||
"rev": null,
|
"rev": null,
|
||||||
"vendor": null
|
"vendor": null
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import string
|
import string
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"name": string,
|
[
|
||||||
"maj_min": string,
|
{
|
||||||
"rm": boolean,
|
"name": string,
|
||||||
"size": string,
|
"maj_min": string,
|
||||||
"ro": boolean,
|
"rm": boolean,
|
||||||
"type": string,
|
"size": string,
|
||||||
"mountpoint": string,
|
"ro": boolean,
|
||||||
"kname": string,
|
"type": string,
|
||||||
"fstype": string,
|
"mountpoint": string,
|
||||||
"label": string,
|
"kname": string,
|
||||||
"uuid": string,
|
"fstype": string,
|
||||||
"partlabel": string,
|
"label": string,
|
||||||
"partuuid": string,
|
"uuid": string,
|
||||||
"ra": integer,
|
"partlabel": string,
|
||||||
"model": string,
|
"partuuid": string,
|
||||||
"serial": string,
|
"ra": integer,
|
||||||
"state": string,
|
"model": string,
|
||||||
"owner": string,
|
"serial": string,
|
||||||
"group": string,
|
"state": string,
|
||||||
"mode": string,
|
"owner": string,
|
||||||
"alignment": integer,
|
"group": string,
|
||||||
"min_io": integer,
|
"mode": string,
|
||||||
"opt_io": integer,
|
"alignment": integer,
|
||||||
"phy_sec": integer,
|
"min_io": integer,
|
||||||
"log_sec": integer,
|
"opt_io": integer,
|
||||||
"rota": boolean,
|
"phy_sec": integer,
|
||||||
"sched": string,
|
"log_sec": integer,
|
||||||
"rq_size": integer,
|
"rota": boolean,
|
||||||
"disc_aln": integer,
|
"sched": string,
|
||||||
"disc_gran": string,
|
"rq_size": integer,
|
||||||
"disc_max": string,
|
"disc_aln": integer,
|
||||||
"disc_zero": boolean,
|
"disc_gran": string,
|
||||||
"wsame": string,
|
"disc_max": string,
|
||||||
"wwn": string,
|
"disc_zero": boolean,
|
||||||
"rand": boolean,
|
"wsame": string,
|
||||||
"pkname": string,
|
"wwn": string,
|
||||||
"hctl": string,
|
"rand": boolean,
|
||||||
"tran": string,
|
"pkname": string,
|
||||||
"rev": string,
|
"hctl": string,
|
||||||
"vendor": string
|
"tran": string,
|
||||||
}
|
"rev": string,
|
||||||
]
|
"vendor": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# boolean changes
|
# boolean changes
|
||||||
bool_list = ['rm', 'ro', 'rota', 'disc_zero', 'rand']
|
bool_list = ['rm', 'ro', 'rota', 'disc_zero', 'rand']
|
||||||
@ -282,6 +284,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,114 +5,116 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ lsmod | jc --lsmod -p
|
$ lsmod | jc --lsmod -p
|
||||||
[
|
[
|
||||||
...
|
...
|
||||||
{
|
{
|
||||||
"module": "nf_nat",
|
"module": "nf_nat",
|
||||||
"size": 26583,
|
"size": 26583,
|
||||||
"used": 3,
|
"used": 3,
|
||||||
"by": [
|
"by": [
|
||||||
"nf_nat_ipv4",
|
"nf_nat_ipv4",
|
||||||
"nf_nat_ipv6",
|
"nf_nat_ipv6",
|
||||||
"nf_nat_masquerade_ipv4"
|
"nf_nat_masquerade_ipv4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "iptable_mangle",
|
||||||
|
"size": 12695,
|
||||||
|
"used": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "iptable_security",
|
||||||
|
"size": 12705,
|
||||||
|
"used": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "iptable_raw",
|
||||||
|
"size": 12678,
|
||||||
|
"used": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "nf_conntrack",
|
||||||
|
"size": 139224,
|
||||||
|
"used": 7,
|
||||||
|
"by": [
|
||||||
|
"nf_nat",
|
||||||
|
"nf_nat_ipv4",
|
||||||
|
"nf_nat_ipv6",
|
||||||
|
"xt_conntrack",
|
||||||
|
"nf_nat_masquerade_ipv4",
|
||||||
|
"nf_conntrack_ipv4",
|
||||||
|
"nf_conntrack_ipv6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "iptable_mangle",
|
|
||||||
"size": 12695,
|
|
||||||
"used": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "iptable_security",
|
|
||||||
"size": 12705,
|
|
||||||
"used": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "iptable_raw",
|
|
||||||
"size": 12678,
|
|
||||||
"used": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "nf_conntrack",
|
|
||||||
"size": 139224,
|
|
||||||
"used": 7,
|
|
||||||
"by": [
|
|
||||||
"nf_nat",
|
|
||||||
"nf_nat_ipv4",
|
|
||||||
"nf_nat_ipv6",
|
|
||||||
"xt_conntrack",
|
|
||||||
"nf_nat_masquerade_ipv4",
|
|
||||||
"nf_conntrack_ipv4",
|
|
||||||
"nf_conntrack_ipv6"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
$ lsmod | jc --lsmod -p -r
|
$ lsmod | jc --lsmod -p -r
|
||||||
[
|
[
|
||||||
...
|
...
|
||||||
{
|
{
|
||||||
"module": "nf_conntrack",
|
"module": "nf_conntrack",
|
||||||
"size": "139224",
|
"size": "139224",
|
||||||
"used": "7",
|
"used": "7",
|
||||||
"by": [
|
"by": [
|
||||||
"nf_nat",
|
"nf_nat",
|
||||||
"nf_nat_ipv4",
|
"nf_nat_ipv4",
|
||||||
"nf_nat_ipv6",
|
"nf_nat_ipv6",
|
||||||
"xt_conntrack",
|
"xt_conntrack",
|
||||||
"nf_nat_masquerade_ipv4",
|
"nf_nat_masquerade_ipv4",
|
||||||
"nf_conntrack_ipv4",
|
"nf_conntrack_ipv4",
|
||||||
"nf_conntrack_ipv6"
|
"nf_conntrack_ipv6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "ip_set",
|
||||||
|
"size": "45799",
|
||||||
|
"used": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "nfnetlink",
|
||||||
|
"size": "14519",
|
||||||
|
"used": "1",
|
||||||
|
"by": [
|
||||||
|
"ip_set"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "ebtable_filter",
|
||||||
|
"size": "12827",
|
||||||
|
"used": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"module": "ebtables",
|
||||||
|
"size": "35009",
|
||||||
|
"used": "2",
|
||||||
|
"by": [
|
||||||
|
"ebtable_nat",
|
||||||
|
"ebtable_filter"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "ip_set",
|
|
||||||
"size": "45799",
|
|
||||||
"used": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "nfnetlink",
|
|
||||||
"size": "14519",
|
|
||||||
"used": "1",
|
|
||||||
"by": [
|
|
||||||
"ip_set"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "ebtable_filter",
|
|
||||||
"size": "12827",
|
|
||||||
"used": "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "ebtables",
|
|
||||||
"size": "35009",
|
|
||||||
"used": "2",
|
|
||||||
"by": [
|
|
||||||
"ebtable_nat",
|
|
||||||
"ebtable_filter"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"module": string,
|
[
|
||||||
"size": integer,
|
{
|
||||||
"used": integer,
|
"module": string,
|
||||||
"by": [
|
"size": integer,
|
||||||
string
|
"used": integer,
|
||||||
|
"by": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
"""
|
||||||
]
|
|
||||||
'''
|
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# integer changes
|
# integer changes
|
||||||
int_list = ['size', 'used']
|
int_list = ['size', 'used']
|
||||||
@ -128,6 +130,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,109 +5,111 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ sudo lsof | jc --lsof -p
|
$ sudo lsof | jc --lsof -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"command": "systemd",
|
"command": "systemd",
|
||||||
"pid": 1,
|
"pid": 1,
|
||||||
"tid": null,
|
"tid": null,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"fd": "cwd",
|
"fd": "cwd",
|
||||||
"type": "DIR",
|
"type": "DIR",
|
||||||
"device": "253,0",
|
"device": "253,0",
|
||||||
"size_off": 224,
|
"size_off": 224,
|
||||||
"node": 64,
|
"node": 64,
|
||||||
"name": "/"
|
"name": "/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "systemd",
|
"command": "systemd",
|
||||||
"pid": 1,
|
"pid": 1,
|
||||||
"tid": null,
|
"tid": null,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"fd": "rtd",
|
"fd": "rtd",
|
||||||
"type": "DIR",
|
"type": "DIR",
|
||||||
"device": "253,0",
|
"device": "253,0",
|
||||||
"size_off": 224,
|
"size_off": 224,
|
||||||
"node": 64,
|
"node": 64,
|
||||||
"name": "/"
|
"name": "/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "systemd",
|
"command": "systemd",
|
||||||
"pid": 1,
|
"pid": 1,
|
||||||
"tid": null,
|
"tid": null,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"fd": "txt",
|
"fd": "txt",
|
||||||
"type": "REG",
|
"type": "REG",
|
||||||
"device": "253,0",
|
"device": "253,0",
|
||||||
"size_off": 1624520,
|
"size_off": 1624520,
|
||||||
"node": 50360451,
|
"node": 50360451,
|
||||||
"name": "/usr/lib/systemd/systemd"
|
"name": "/usr/lib/systemd/systemd"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ sudo lsof | jc --lsof -p -r
|
$ sudo lsof | jc --lsof -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"command": "systemd",
|
"command": "systemd",
|
||||||
"pid": "1",
|
"pid": "1",
|
||||||
"tid": null,
|
"tid": null,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"fd": "cwd",
|
"fd": "cwd",
|
||||||
"type": "DIR",
|
"type": "DIR",
|
||||||
"device": "8,2",
|
"device": "8,2",
|
||||||
"size_off": "4096",
|
"size_off": "4096",
|
||||||
"node": "2",
|
"node": "2",
|
||||||
"name": "/"
|
"name": "/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "systemd",
|
"command": "systemd",
|
||||||
"pid": "1",
|
"pid": "1",
|
||||||
"tid": null,
|
"tid": null,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"fd": "rtd",
|
"fd": "rtd",
|
||||||
"type": "DIR",
|
"type": "DIR",
|
||||||
"device": "8,2",
|
"device": "8,2",
|
||||||
"size_off": "4096",
|
"size_off": "4096",
|
||||||
"node": "2",
|
"node": "2",
|
||||||
"name": "/"
|
"name": "/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "systemd",
|
"command": "systemd",
|
||||||
"pid": "1",
|
"pid": "1",
|
||||||
"tid": null,
|
"tid": null,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"fd": "txt",
|
"fd": "txt",
|
||||||
"type": "REG",
|
"type": "REG",
|
||||||
"device": "8,2",
|
"device": "8,2",
|
||||||
"size_off": "1595792",
|
"size_off": "1595792",
|
||||||
"node": "668802",
|
"node": "668802",
|
||||||
"name": "/lib/systemd/systemd"
|
"name": "/lib/systemd/systemd"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import string
|
import string
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"command": string,
|
[
|
||||||
"pid": integer,
|
{
|
||||||
"tid": integer,
|
"command": string,
|
||||||
"user": string,
|
"pid": integer,
|
||||||
"fd": string,
|
"tid": integer,
|
||||||
"type": string,
|
"user": string,
|
||||||
"device": string,
|
"fd": string,
|
||||||
"size_off": integer,
|
"type": string,
|
||||||
"node": integer,
|
"device": string,
|
||||||
"name": string
|
"size_off": integer,
|
||||||
}
|
"node": integer,
|
||||||
]
|
"name": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# integer changes
|
# integer changes
|
||||||
int_list = ['pid', 'tid', 'size_off', 'node']
|
int_list = ['pid', 'tid', 'size_off', 'node']
|
||||||
@ -122,6 +124,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,70 +5,81 @@ Usage:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ mount | jc --mount -p
|
$ mount | jc --mount -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filesystem": "sysfs",
|
"filesystem": "sysfs",
|
||||||
"mount_point": "/sys",
|
"mount_point": "/sys",
|
||||||
"type": "sysfs",
|
"type": "sysfs",
|
||||||
"access": [
|
"access": [
|
||||||
"rw",
|
"rw",
|
||||||
"nosuid",
|
"nosuid",
|
||||||
"nodev",
|
"nodev",
|
||||||
"noexec",
|
"noexec",
|
||||||
"relatime"
|
"relatime"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "proc",
|
||||||
|
"mount_point": "/proc",
|
||||||
|
"type": "proc",
|
||||||
|
"access": [
|
||||||
|
"rw",
|
||||||
|
"nosuid",
|
||||||
|
"nodev",
|
||||||
|
"noexec",
|
||||||
|
"relatime"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filesystem": "udev",
|
||||||
|
"mount_point": "/dev",
|
||||||
|
"type": "devtmpfs",
|
||||||
|
"access": [
|
||||||
|
"rw",
|
||||||
|
"nosuid",
|
||||||
|
"relatime",
|
||||||
|
"size=977500k",
|
||||||
|
"nr_inodes=244375",
|
||||||
|
"mode=755"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"filesystem": "proc",
|
|
||||||
"mount_point": "/proc",
|
|
||||||
"type": "proc",
|
|
||||||
"access": [
|
|
||||||
"rw",
|
|
||||||
"nosuid",
|
|
||||||
"nodev",
|
|
||||||
"noexec",
|
|
||||||
"relatime"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filesystem": "udev",
|
|
||||||
"mount_point": "/dev",
|
|
||||||
"type": "devtmpfs",
|
|
||||||
"access": [
|
|
||||||
"rw",
|
|
||||||
"nosuid",
|
|
||||||
"relatime",
|
|
||||||
"size=977500k",
|
|
||||||
"nr_inodes=244375",
|
|
||||||
"mode=755"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"filesystem": string,
|
[
|
||||||
"mount_point": string,
|
{
|
||||||
"type": string,
|
"filesystem": string,
|
||||||
"access": [
|
"mount_point": string,
|
||||||
string
|
"type": string,
|
||||||
|
"access": [
|
||||||
|
string
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
nothing to process
|
nothing to process
|
||||||
'''
|
"""
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,337 +5,339 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ sudo netstat -apee | jc --netstat -p
|
$ sudo netstat -apee | jc --netstat -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "0.0.0.0",
|
"foreign_address": "0.0.0.0",
|
||||||
"state": "LISTEN",
|
"state": "LISTEN",
|
||||||
"user": "systemd-resolve",
|
"user": "systemd-resolve",
|
||||||
"inode": 26958,
|
"inode": 26958,
|
||||||
"program_name": "systemd-resolve",
|
"program_name": "systemd-resolve",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 887,
|
"pid": 887,
|
||||||
"local_port": "domain",
|
"local_port": "domain",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "0.0.0.0",
|
"local_address": "0.0.0.0",
|
||||||
"foreign_address": "0.0.0.0",
|
"foreign_address": "0.0.0.0",
|
||||||
"state": "LISTEN",
|
"state": "LISTEN",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": 30499,
|
"inode": 30499,
|
||||||
"program_name": "sshd",
|
"program_name": "sshd",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 1186,
|
"pid": 1186,
|
||||||
"local_port": "ssh",
|
"local_port": "ssh",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "localhost",
|
"foreign_address": "localhost",
|
||||||
"state": "ESTABLISHED",
|
"state": "ESTABLISHED",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": 46829,
|
"inode": 46829,
|
||||||
"program_name": "sshd: root",
|
"program_name": "sshd: root",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 2242,
|
"pid": 2242,
|
||||||
"local_port": "ssh",
|
"local_port": "ssh",
|
||||||
"foreign_port": "52186",
|
"foreign_port": "52186",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4",
|
"network_protocol": "ipv4",
|
||||||
"foreign_port_num": 52186
|
"foreign_port_num": 52186
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "localhost",
|
"foreign_address": "localhost",
|
||||||
"state": "ESTABLISHED",
|
"state": "ESTABLISHED",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": 46828,
|
"inode": 46828,
|
||||||
"program_name": "ssh",
|
"program_name": "ssh",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 2241,
|
"pid": 2241,
|
||||||
"local_port": "52186",
|
"local_port": "52186",
|
||||||
"foreign_port": "ssh",
|
"foreign_port": "ssh",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4",
|
"network_protocol": "ipv4",
|
||||||
"local_port_num": 52186
|
"local_port_num": 52186
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp6",
|
"proto": "tcp6",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "[::]",
|
"local_address": "[::]",
|
||||||
"foreign_address": "[::]",
|
"foreign_address": "[::]",
|
||||||
"state": "LISTEN",
|
"state": "LISTEN",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": 30510,
|
"inode": 30510,
|
||||||
"program_name": "sshd",
|
"program_name": "sshd",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 1186,
|
"pid": 1186,
|
||||||
"local_port": "ssh",
|
"local_port": "ssh",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv6"
|
"network_protocol": "ipv6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "udp",
|
"proto": "udp",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "0.0.0.0",
|
"foreign_address": "0.0.0.0",
|
||||||
"state": null,
|
"state": null,
|
||||||
"user": "systemd-resolve",
|
"user": "systemd-resolve",
|
||||||
"inode": 26957,
|
"inode": 26957,
|
||||||
"program_name": "systemd-resolve",
|
"program_name": "systemd-resolve",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 887,
|
"pid": 887,
|
||||||
"local_port": "domain",
|
"local_port": "domain",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "udp",
|
"transport_protocol": "udp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "raw6",
|
"proto": "raw6",
|
||||||
"recv_q": 0,
|
"recv_q": 0,
|
||||||
"send_q": 0,
|
"send_q": 0,
|
||||||
"local_address": "[::]",
|
"local_address": "[::]",
|
||||||
"foreign_address": "[::]",
|
"foreign_address": "[::]",
|
||||||
"state": "7",
|
"state": "7",
|
||||||
"user": "systemd-network",
|
"user": "systemd-network",
|
||||||
"inode": 27001,
|
"inode": 27001,
|
||||||
"program_name": "systemd-network",
|
"program_name": "systemd-network",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": 867,
|
"pid": 867,
|
||||||
"local_port": "ipv6-icmp",
|
"local_port": "ipv6-icmp",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": null,
|
"transport_protocol": null,
|
||||||
"network_protocol": "ipv6"
|
"network_protocol": "ipv6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "unix",
|
"proto": "unix",
|
||||||
"refcnt": 2,
|
"refcnt": 2,
|
||||||
"flags": null,
|
"flags": null,
|
||||||
"type": "DGRAM",
|
"type": "DGRAM",
|
||||||
"state": null,
|
"state": null,
|
||||||
"inode": 33322,
|
"inode": 33322,
|
||||||
"program_name": "systemd",
|
"program_name": "systemd",
|
||||||
"path": "/run/user/1000/systemd/notify",
|
"path": "/run/user/1000/systemd/notify",
|
||||||
"kind": "socket",
|
"kind": "socket",
|
||||||
"pid": 1607
|
"pid": 1607
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "unix",
|
"proto": "unix",
|
||||||
"refcnt": 2,
|
"refcnt": 2,
|
||||||
"flags": "ACC",
|
"flags": "ACC",
|
||||||
"type": "SEQPACKET",
|
"type": "SEQPACKET",
|
||||||
"state": "LISTENING",
|
"state": "LISTENING",
|
||||||
"inode": 20835,
|
"inode": 20835,
|
||||||
"program_name": "init",
|
"program_name": "init",
|
||||||
"path": "/run/udev/control",
|
"path": "/run/udev/control",
|
||||||
"kind": "socket",
|
"kind": "socket",
|
||||||
"pid": 1
|
"pid": 1
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ sudo netstat -apee | jc --netstat -p -r
|
$ sudo netstat -apee | jc --netstat -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "0.0.0.0",
|
"foreign_address": "0.0.0.0",
|
||||||
"state": "LISTEN",
|
"state": "LISTEN",
|
||||||
"user": "systemd-resolve",
|
"user": "systemd-resolve",
|
||||||
"inode": "26958",
|
"inode": "26958",
|
||||||
"program_name": "systemd-resolve",
|
"program_name": "systemd-resolve",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "887",
|
"pid": "887",
|
||||||
"local_port": "domain",
|
"local_port": "domain",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "0.0.0.0",
|
"local_address": "0.0.0.0",
|
||||||
"foreign_address": "0.0.0.0",
|
"foreign_address": "0.0.0.0",
|
||||||
"state": "LISTEN",
|
"state": "LISTEN",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": "30499",
|
"inode": "30499",
|
||||||
"program_name": "sshd",
|
"program_name": "sshd",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "1186",
|
"pid": "1186",
|
||||||
"local_port": "ssh",
|
"local_port": "ssh",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "localhost",
|
"foreign_address": "localhost",
|
||||||
"state": "ESTABLISHED",
|
"state": "ESTABLISHED",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": "46829",
|
"inode": "46829",
|
||||||
"program_name": "sshd: root",
|
"program_name": "sshd: root",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "2242",
|
"pid": "2242",
|
||||||
"local_port": "ssh",
|
"local_port": "ssh",
|
||||||
"foreign_port": "52186",
|
"foreign_port": "52186",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp",
|
"proto": "tcp",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "localhost",
|
"foreign_address": "localhost",
|
||||||
"state": "ESTABLISHED",
|
"state": "ESTABLISHED",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": "46828",
|
"inode": "46828",
|
||||||
"program_name": "ssh",
|
"program_name": "ssh",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "2241",
|
"pid": "2241",
|
||||||
"local_port": "52186",
|
"local_port": "52186",
|
||||||
"foreign_port": "ssh",
|
"foreign_port": "ssh",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "tcp6",
|
"proto": "tcp6",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "[::]",
|
"local_address": "[::]",
|
||||||
"foreign_address": "[::]",
|
"foreign_address": "[::]",
|
||||||
"state": "LISTEN",
|
"state": "LISTEN",
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"inode": "30510",
|
"inode": "30510",
|
||||||
"program_name": "sshd",
|
"program_name": "sshd",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "1186",
|
"pid": "1186",
|
||||||
"local_port": "ssh",
|
"local_port": "ssh",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "tcp",
|
"transport_protocol": "tcp",
|
||||||
"network_protocol": "ipv6"
|
"network_protocol": "ipv6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "udp",
|
"proto": "udp",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "localhost",
|
"local_address": "localhost",
|
||||||
"foreign_address": "0.0.0.0",
|
"foreign_address": "0.0.0.0",
|
||||||
"state": null,
|
"state": null,
|
||||||
"user": "systemd-resolve",
|
"user": "systemd-resolve",
|
||||||
"inode": "26957",
|
"inode": "26957",
|
||||||
"program_name": "systemd-resolve",
|
"program_name": "systemd-resolve",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "887",
|
"pid": "887",
|
||||||
"local_port": "domain",
|
"local_port": "domain",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": "udp",
|
"transport_protocol": "udp",
|
||||||
"network_protocol": "ipv4"
|
"network_protocol": "ipv4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "raw6",
|
"proto": "raw6",
|
||||||
"recv_q": "0",
|
"recv_q": "0",
|
||||||
"send_q": "0",
|
"send_q": "0",
|
||||||
"local_address": "[::]",
|
"local_address": "[::]",
|
||||||
"foreign_address": "[::]",
|
"foreign_address": "[::]",
|
||||||
"state": "7",
|
"state": "7",
|
||||||
"user": "systemd-network",
|
"user": "systemd-network",
|
||||||
"inode": "27001",
|
"inode": "27001",
|
||||||
"program_name": "systemd-network",
|
"program_name": "systemd-network",
|
||||||
"kind": "network",
|
"kind": "network",
|
||||||
"pid": "867",
|
"pid": "867",
|
||||||
"local_port": "ipv6-icmp",
|
"local_port": "ipv6-icmp",
|
||||||
"foreign_port": "*",
|
"foreign_port": "*",
|
||||||
"transport_protocol": null,
|
"transport_protocol": null,
|
||||||
"network_protocol": "ipv6"
|
"network_protocol": "ipv6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "unix",
|
"proto": "unix",
|
||||||
"refcnt": "2",
|
"refcnt": "2",
|
||||||
"flags": null,
|
"flags": null,
|
||||||
"type": "DGRAM",
|
"type": "DGRAM",
|
||||||
"state": null,
|
"state": null,
|
||||||
"inode": "33322",
|
"inode": "33322",
|
||||||
"program_name": "systemd",
|
"program_name": "systemd",
|
||||||
"path": "/run/user/1000/systemd/notify",
|
"path": "/run/user/1000/systemd/notify",
|
||||||
"kind": "socket",
|
"kind": "socket",
|
||||||
"pid": " 1607"
|
"pid": " 1607"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"proto": "unix",
|
"proto": "unix",
|
||||||
"refcnt": "2",
|
"refcnt": "2",
|
||||||
"flags": "ACC",
|
"flags": "ACC",
|
||||||
"type": "SEQPACKET",
|
"type": "SEQPACKET",
|
||||||
"state": "LISTENING",
|
"state": "LISTENING",
|
||||||
"inode": "20835",
|
"inode": "20835",
|
||||||
"program_name": "init",
|
"program_name": "init",
|
||||||
"path": "/run/udev/control",
|
"path": "/run/udev/control",
|
||||||
"kind": "socket",
|
"kind": "socket",
|
||||||
"pid": " 1"
|
"pid": " 1"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import string
|
import string
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"proto": string,
|
[
|
||||||
"recv_q": integer,
|
{
|
||||||
"send_q": integer,
|
"proto": string,
|
||||||
"transport_protocol" string,
|
"recv_q": integer,
|
||||||
"network_protocol": string,
|
"send_q": integer,
|
||||||
"local_address": string,
|
"transport_protocol" string,
|
||||||
"local_port": string,
|
"network_protocol": string,
|
||||||
"local_port_num": integer,
|
"local_address": string,
|
||||||
"foreign_address": string,
|
"local_port": string,
|
||||||
"foreign_port": string,
|
"local_port_num": integer,
|
||||||
"foreign_port_num": integer,
|
"foreign_address": string,
|
||||||
"state": string,
|
"foreign_port": string,
|
||||||
"program_name": string,
|
"foreign_port_num": integer,
|
||||||
"pid": integer,
|
"state": string,
|
||||||
"user": string,
|
"program_name": string,
|
||||||
"security_context": string,
|
"pid": integer,
|
||||||
"refcnt": integer,
|
"user": string,
|
||||||
"flags": string,
|
"security_context": string,
|
||||||
"type": string,
|
"refcnt": integer,
|
||||||
"inode": integer,
|
"flags": string,
|
||||||
"path": string,
|
"type": string,
|
||||||
"kind": string
|
"inode": integer,
|
||||||
}
|
"path": string,
|
||||||
]
|
"kind": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# integer changes
|
# integer changes
|
||||||
int_list = ['recv_q', 'send_q', 'pid', 'refcnt', 'inode']
|
int_list = ['recv_q', 'send_q', 'pid', 'refcnt', 'inode']
|
||||||
@ -485,6 +487,15 @@ def parse_post(raw_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
389
jc/parsers/ps.py
389
jc/parsers/ps.py
@ -9,203 +9,205 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ ps -ef | jc --ps -p
|
$ ps -ef | jc --ps -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
"pid": 1,
|
"pid": 1,
|
||||||
"ppid": 0,
|
"ppid": 0,
|
||||||
"c": 0,
|
"c": 0,
|
||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"time": "00:00:11",
|
"time": "00:00:11",
|
||||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
"pid": 2,
|
"pid": 2,
|
||||||
"ppid": 0,
|
"ppid": 0,
|
||||||
"c": 0,
|
"c": 0,
|
||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"time": "00:00:00",
|
"time": "00:00:00",
|
||||||
"cmd": "[kthreadd]"
|
"cmd": "[kthreadd]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
"pid": 4,
|
"pid": 4,
|
||||||
"ppid": 2,
|
"ppid": 2,
|
||||||
"c": 0,
|
"c": 0,
|
||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"time": "00:00:00",
|
"time": "00:00:00",
|
||||||
"cmd": "[kworker/0:0H]"
|
"cmd": "[kworker/0:0H]"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ps -ef | jc --ps -p -r
|
$ ps -ef | jc --ps -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
"pid": "1",
|
"pid": "1",
|
||||||
"ppid": "0",
|
"ppid": "0",
|
||||||
"c": "0",
|
"c": "0",
|
||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"time": "00:00:11",
|
"time": "00:00:11",
|
||||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
"pid": "2",
|
"pid": "2",
|
||||||
"ppid": "0",
|
"ppid": "0",
|
||||||
"c": "0",
|
"c": "0",
|
||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"time": "00:00:00",
|
"time": "00:00:00",
|
||||||
"cmd": "[kthreadd]"
|
"cmd": "[kthreadd]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uid": "root",
|
"uid": "root",
|
||||||
"pid": "4",
|
"pid": "4",
|
||||||
"ppid": "2",
|
"ppid": "2",
|
||||||
"c": "0",
|
"c": "0",
|
||||||
"stime": "Nov01",
|
"stime": "Nov01",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"time": "00:00:00",
|
"time": "00:00:00",
|
||||||
"cmd": "[kworker/0:0H]"
|
"cmd": "[kworker/0:0H]"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ps axu | jc --ps -p
|
$ ps axu | jc --ps -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": 1,
|
"pid": 1,
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.1",
|
"mem_percent": "0.1",
|
||||||
"vsz": "128072",
|
"vsz": "128072",
|
||||||
"rss": "6676",
|
"rss": "6676",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"stat": "Ss",
|
"stat": "Ss",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:06",
|
"time": "0:06",
|
||||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": 2,
|
"pid": 2,
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.0",
|
"mem_percent": "0.0",
|
||||||
"vsz": "0",
|
"vsz": "0",
|
||||||
"rss": "0",
|
"rss": "0",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"stat": "S",
|
"stat": "S",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:00",
|
"time": "0:00",
|
||||||
"command": "[kthreadd]"
|
"command": "[kthreadd]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": 4,
|
"pid": 4,
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.0",
|
"mem_percent": "0.0",
|
||||||
"vsz": "0",
|
"vsz": "0",
|
||||||
"rss": "0",
|
"rss": "0",
|
||||||
"tty": null,
|
"tty": null,
|
||||||
"stat": "S<",
|
"stat": "S<",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:00",
|
"time": "0:00",
|
||||||
"command": "[kworker/0:0H]"
|
"command": "[kworker/0:0H]"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
$ ps axu | jc --ps -p -r
|
$ ps axu | jc --ps -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": "1",
|
"pid": "1",
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.1",
|
"mem_percent": "0.1",
|
||||||
"vsz": "128072",
|
"vsz": "128072",
|
||||||
"rss": "6676",
|
"rss": "6676",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"stat": "Ss",
|
"stat": "Ss",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:06",
|
"time": "0:06",
|
||||||
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": "2",
|
"pid": "2",
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.0",
|
"mem_percent": "0.0",
|
||||||
"vsz": "0",
|
"vsz": "0",
|
||||||
"rss": "0",
|
"rss": "0",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"stat": "S",
|
"stat": "S",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:00",
|
"time": "0:00",
|
||||||
"command": "[kthreadd]"
|
"command": "[kthreadd]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": "4",
|
"pid": "4",
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.0",
|
"mem_percent": "0.0",
|
||||||
"vsz": "0",
|
"vsz": "0",
|
||||||
"rss": "0",
|
"rss": "0",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"stat": "S<",
|
"stat": "S<",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:00",
|
"time": "0:00",
|
||||||
"command": "[kworker/0:0H]"
|
"command": "[kworker/0:0H]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"pid": "6",
|
"pid": "6",
|
||||||
"cpu_percent": "0.0",
|
"cpu_percent": "0.0",
|
||||||
"mem_percent": "0.0",
|
"mem_percent": "0.0",
|
||||||
"vsz": "0",
|
"vsz": "0",
|
||||||
"rss": "0",
|
"rss": "0",
|
||||||
"tty": "?",
|
"tty": "?",
|
||||||
"stat": "S",
|
"stat": "S",
|
||||||
"start": "Nov09",
|
"start": "Nov09",
|
||||||
"time": "0:00",
|
"time": "0:00",
|
||||||
"command": "[ksoftirqd/0]"
|
"command": "[ksoftirqd/0]"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"uid": string,
|
[
|
||||||
"pid": integer,
|
{
|
||||||
"ppid": integer,
|
"uid": string,
|
||||||
"c": integer,
|
"pid": integer,
|
||||||
"stime": string,
|
"ppid": integer,
|
||||||
"tty": string, # ? = Null
|
"c": integer,
|
||||||
"time": string,
|
"stime": string,
|
||||||
"cmd": string,
|
"tty": string, # ? = Null
|
||||||
"user": string,
|
"time": string,
|
||||||
"cpu_percent": float,
|
"cmd": string,
|
||||||
"mem_percent": float,
|
"user": string,
|
||||||
"vsz": integer,
|
"cpu_percent": float,
|
||||||
"rss": integer,
|
"mem_percent": float,
|
||||||
"stat": string,
|
"vsz": integer,
|
||||||
"start": string,
|
"rss": integer,
|
||||||
"command": string
|
"stat": string,
|
||||||
}
|
"start": string,
|
||||||
]
|
"command": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# change to int
|
# change to int
|
||||||
int_list = ['pid', 'ppid', 'c', 'vsz', 'rss']
|
int_list = ['pid', 'ppid', 'c', 'vsz', 'rss']
|
||||||
@ -235,6 +237,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -5,113 +5,115 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ route -ee | jc --route -p
|
$ route -ee | jc --route -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"destination": "default",
|
"destination": "default",
|
||||||
"gateway": "gateway",
|
"gateway": "gateway",
|
||||||
"genmask": "0.0.0.0",
|
"genmask": "0.0.0.0",
|
||||||
"flags": "UG",
|
"flags": "UG",
|
||||||
"metric": 100,
|
"metric": 100,
|
||||||
"ref": 0,
|
"ref": 0,
|
||||||
"use": 0,
|
"use": 0,
|
||||||
"iface": "ens33",
|
"iface": "ens33",
|
||||||
"mss": 0,
|
"mss": 0,
|
||||||
"window": 0,
|
"window": 0,
|
||||||
"irtt": 0
|
"irtt": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"destination": "172.17.0.0",
|
"destination": "172.17.0.0",
|
||||||
"gateway": "0.0.0.0",
|
"gateway": "0.0.0.0",
|
||||||
"genmask": "255.255.0.0",
|
"genmask": "255.255.0.0",
|
||||||
"flags": "U",
|
"flags": "U",
|
||||||
"metric": 0,
|
"metric": 0,
|
||||||
"ref": 0,
|
"ref": 0,
|
||||||
"use": 0,
|
"use": 0,
|
||||||
"iface": "docker",
|
"iface": "docker",
|
||||||
"mss": 0,
|
"mss": 0,
|
||||||
"window": 0,
|
"window": 0,
|
||||||
"irtt": 0
|
"irtt": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"destination": "192.168.71.0",
|
"destination": "192.168.71.0",
|
||||||
"gateway": "0.0.0.0",
|
"gateway": "0.0.0.0",
|
||||||
"genmask": "255.255.255.0",
|
"genmask": "255.255.255.0",
|
||||||
"flags": "U",
|
"flags": "U",
|
||||||
"metric": 100,
|
"metric": 100,
|
||||||
"ref": 0,
|
"ref": 0,
|
||||||
"use": 0,
|
"use": 0,
|
||||||
"iface": "ens33",
|
"iface": "ens33",
|
||||||
"mss": 0,
|
"mss": 0,
|
||||||
"window": 0,
|
"window": 0,
|
||||||
"irtt": 0
|
"irtt": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ route -ee | jc --route -p -r
|
$ route -ee | jc --route -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"destination": "default",
|
"destination": "default",
|
||||||
"gateway": "gateway",
|
"gateway": "gateway",
|
||||||
"genmask": "0.0.0.0",
|
"genmask": "0.0.0.0",
|
||||||
"flags": "UG",
|
"flags": "UG",
|
||||||
"metric": "100",
|
"metric": "100",
|
||||||
"ref": "0",
|
"ref": "0",
|
||||||
"use": "0",
|
"use": "0",
|
||||||
"iface": "ens33",
|
"iface": "ens33",
|
||||||
"mss": "0",
|
"mss": "0",
|
||||||
"window": "0",
|
"window": "0",
|
||||||
"irtt": "0"
|
"irtt": "0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"destination": "172.17.0.0",
|
"destination": "172.17.0.0",
|
||||||
"gateway": "0.0.0.0",
|
"gateway": "0.0.0.0",
|
||||||
"genmask": "255.255.0.0",
|
"genmask": "255.255.0.0",
|
||||||
"flags": "U",
|
"flags": "U",
|
||||||
"metric": "0",
|
"metric": "0",
|
||||||
"ref": "0",
|
"ref": "0",
|
||||||
"use": "0",
|
"use": "0",
|
||||||
"iface": "docker",
|
"iface": "docker",
|
||||||
"mss": "0",
|
"mss": "0",
|
||||||
"window": "0",
|
"window": "0",
|
||||||
"irtt": "0"
|
"irtt": "0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"destination": "192.168.71.0",
|
"destination": "192.168.71.0",
|
||||||
"gateway": "0.0.0.0",
|
"gateway": "0.0.0.0",
|
||||||
"genmask": "255.255.255.0",
|
"genmask": "255.255.255.0",
|
||||||
"flags": "U",
|
"flags": "U",
|
||||||
"metric": "100",
|
"metric": "100",
|
||||||
"ref": "0",
|
"ref": "0",
|
||||||
"use": "0",
|
"use": "0",
|
||||||
"iface": "ens33",
|
"iface": "ens33",
|
||||||
"mss": "0",
|
"mss": "0",
|
||||||
"window": "0",
|
"window": "0",
|
||||||
"irtt": "0"
|
"irtt": "0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"destination": string,
|
[
|
||||||
"gateway": string,
|
{
|
||||||
"genmask": string,
|
"destination": string,
|
||||||
"flags": string,
|
"gateway": string,
|
||||||
"metric": integer,
|
"genmask": string,
|
||||||
"ref": integer,
|
"flags": string,
|
||||||
"use": integer,
|
"metric": integer,
|
||||||
"mss": integer,
|
"ref": integer,
|
||||||
"window": integer,
|
"use": integer,
|
||||||
"irtt": integer,
|
"mss": integer,
|
||||||
"iface": string
|
"window": integer,
|
||||||
}
|
"irtt": integer,
|
||||||
]
|
"iface": string
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
int_list = ['metric', 'ref', 'use', 'mss', 'window', 'irtt']
|
int_list = ['metric', 'ref', 'use', 'mss', 'window', 'irtt']
|
||||||
for key in int_list:
|
for key in int_list:
|
||||||
@ -126,6 +128,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'aix', 'freebsd']
|
compatible = ['linux', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
@ -8,40 +8,51 @@ Limitations:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ uname -a | jc --uname -p
|
$ uname -a | jc --uname -p
|
||||||
{
|
{
|
||||||
"kernel_name": "Linux",
|
"kernel_name": "Linux",
|
||||||
"node_name": "user-ubuntu",
|
"node_name": "user-ubuntu",
|
||||||
"kernel_release": "4.15.0-65-generic",
|
"kernel_release": "4.15.0-65-generic",
|
||||||
"operating_system": "GNU/Linux",
|
"operating_system": "GNU/Linux",
|
||||||
"hardware_platform": "x86_64",
|
"hardware_platform": "x86_64",
|
||||||
"processor": "x86_64",
|
"processor": "x86_64",
|
||||||
"machine": "x86_64",
|
"machine": "x86_64",
|
||||||
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
{
|
schema:
|
||||||
"kernel_name": string,
|
|
||||||
"node_name": string,
|
{
|
||||||
"kernel_release": string,
|
"kernel_name": string,
|
||||||
"operating_system": string,
|
"node_name": string,
|
||||||
"hardware_platform": string,
|
"kernel_release": string,
|
||||||
"processor": string,
|
"operating_system": string,
|
||||||
"machine": string,
|
"hardware_platform": string,
|
||||||
"kernel_version": string
|
"processor": string,
|
||||||
}
|
"machine": string,
|
||||||
|
"kernel_version": string
|
||||||
|
}
|
||||||
|
|
||||||
no extra processing
|
no extra processing
|
||||||
'''
|
"""
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux']
|
compatible = ['linux']
|
||||||
|
|
||||||
|
@ -5,40 +5,42 @@ Usage:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
$ uptime | jc --uptime -p
|
$ uptime | jc --uptime -p
|
||||||
{
|
{
|
||||||
"time": "11:30:44",
|
"time": "11:30:44",
|
||||||
"uptime": "1 day, 21:17",
|
"uptime": "1 day, 21:17",
|
||||||
"users": 1,
|
"users": 1,
|
||||||
"load_1m": 0.01,
|
"load_1m": 0.01,
|
||||||
"load_5m": 0.04,
|
"load_5m": 0.04,
|
||||||
"load_15m": 0.05
|
"load_15m": 0.05
|
||||||
}
|
}
|
||||||
|
|
||||||
$ uptime | jc --uptime -p -r
|
$ uptime | jc --uptime -p -r
|
||||||
{
|
{
|
||||||
"time": "11:31:09",
|
"time": "11:31:09",
|
||||||
"uptime": "1 day, 21:17",
|
"uptime": "1 day, 21:17",
|
||||||
"users": "1",
|
"users": "1",
|
||||||
"load_1m": "0.00",
|
"load_1m": "0.00",
|
||||||
"load_5m": "0.04",
|
"load_5m": "0.04",
|
||||||
"load_15m": "0.05"
|
"load_15m": "0.05"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
{
|
schema:
|
||||||
"time": string,
|
|
||||||
"uptime": string,
|
{
|
||||||
"users": integer,
|
"time": string,
|
||||||
"load_1m": float,
|
"uptime": string,
|
||||||
"load_5m": float,
|
"users": integer,
|
||||||
"load_15m": float
|
"load_1m": float,
|
||||||
}
|
"load_5m": float,
|
||||||
'''
|
"load_15m": float
|
||||||
|
}
|
||||||
|
"""
|
||||||
int_list = ['users']
|
int_list = ['users']
|
||||||
for key in int_list:
|
for key in int_list:
|
||||||
if key in proc_data:
|
if key in proc_data:
|
||||||
@ -61,6 +63,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
171
jc/parsers/w.py
171
jc/parsers/w.py
@ -5,93 +5,95 @@ Usage:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ w | jc --w -p
|
$ w | jc --w -p
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"tty": "tty1",
|
"tty": "tty1",
|
||||||
"from": null,
|
"from": null,
|
||||||
"login_at": "07:49",
|
"login_at": "07:49",
|
||||||
"idle": "1:15m",
|
"idle": "1:15m",
|
||||||
"jcpu": "0.00s",
|
"jcpu": "0.00s",
|
||||||
"pcpu": "0.00s",
|
"pcpu": "0.00s",
|
||||||
"what": "-bash"
|
"what": "-bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"tty": "ttyS0",
|
"tty": "ttyS0",
|
||||||
"from": null,
|
"from": null,
|
||||||
"login_at": "06:24",
|
"login_at": "06:24",
|
||||||
"idle": "0.00s",
|
"idle": "0.00s",
|
||||||
"jcpu": "0.43s",
|
"jcpu": "0.43s",
|
||||||
"pcpu": "0.00s",
|
"pcpu": "0.00s",
|
||||||
"what": "w"
|
"what": "w"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"tty": "pts/0",
|
"tty": "pts/0",
|
||||||
"from": "192.168.71.1",
|
"from": "192.168.71.1",
|
||||||
"login_at": "06:29",
|
"login_at": "06:29",
|
||||||
"idle": "2:35m",
|
"idle": "2:35m",
|
||||||
"jcpu": "0.00s",
|
"jcpu": "0.00s",
|
||||||
"pcpu": "0.00s",
|
"pcpu": "0.00s",
|
||||||
"what": "-bash"
|
"what": "-bash"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
$ w | jc --w -p -r
|
$ w | jc --w -p -r
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": "kbrazil",
|
"user": "kbrazil",
|
||||||
"tty": "tty1",
|
"tty": "tty1",
|
||||||
"from": "-",
|
"from": "-",
|
||||||
"login_at": "07:49",
|
"login_at": "07:49",
|
||||||
"idle": "1:16m",
|
"idle": "1:16m",
|
||||||
"jcpu": "0.00s",
|
"jcpu": "0.00s",
|
||||||
"pcpu": "0.00s",
|
"pcpu": "0.00s",
|
||||||
"what": "-bash"
|
"what": "-bash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "kbrazil",
|
"user": "kbrazil",
|
||||||
"tty": "ttyS0",
|
"tty": "ttyS0",
|
||||||
"from": "-",
|
"from": "-",
|
||||||
"login_at": "06:24",
|
"login_at": "06:24",
|
||||||
"idle": "2.00s",
|
"idle": "2.00s",
|
||||||
"jcpu": "0.46s",
|
"jcpu": "0.46s",
|
||||||
"pcpu": "0.00s",
|
"pcpu": "0.00s",
|
||||||
"what": "w"
|
"what": "w"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"user": "kbrazil",
|
"user": "kbrazil",
|
||||||
"tty": "pts/0",
|
"tty": "pts/0",
|
||||||
"from": "192.168.71.1",
|
"from": "192.168.71.1",
|
||||||
"login_at": "06:29",
|
"login_at": "06:29",
|
||||||
"idle": "2:36m",
|
"idle": "2:36m",
|
||||||
"jcpu": "0.00s",
|
"jcpu": "0.00s",
|
||||||
"pcpu": "0.00s",
|
"pcpu": "0.00s",
|
||||||
"what": "-bash"
|
"what": "-bash"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import string
|
import string
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
'''schema:
|
"""
|
||||||
[
|
schema:
|
||||||
{
|
|
||||||
"user": string, # '-'' = null
|
[
|
||||||
"tty": string, # '-'' = null
|
{
|
||||||
"from": string, # '-'' = null
|
"user": string, # '-'' = null
|
||||||
"login_at": string, # '-'' = null
|
"tty": string, # '-'' = null
|
||||||
"idle": string, # '-'' = null
|
"from": string, # '-'' = null
|
||||||
"jcpu": string,
|
"login_at": string, # '-'' = null
|
||||||
"pcpu": string,
|
"idle": string, # '-'' = null
|
||||||
"what": string # '-'' = null
|
"jcpu": string,
|
||||||
}
|
"pcpu": string,
|
||||||
]
|
"what": string # '-'' = null
|
||||||
'''
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
null_list = ['user', 'tty', 'from', 'login_at', 'idle', 'what']
|
null_list = ['user', 'tty', 'from', 'login_at', 'idle', 'what']
|
||||||
for key in null_list:
|
for key in null_list:
|
||||||
@ -103,6 +105,15 @@ def process(proc_data):
|
|||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
|
"""
|
||||||
|
Main parsing function
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
raw: (boolean) output preprocessed JSON if True
|
||||||
|
quiet: (boolean) suppress warning messages if True
|
||||||
|
"""
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||||
|
|
||||||
|
11
jc/utils.py
11
jc/utils.py
@ -4,6 +4,8 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def warning_message(message):
|
def warning_message(message):
|
||||||
|
"""Prints a warning message for non-fatal issues"""
|
||||||
|
|
||||||
error_string = f'''
|
error_string = f'''
|
||||||
jc: Warning - {message}
|
jc: Warning - {message}
|
||||||
'''
|
'''
|
||||||
@ -11,6 +13,8 @@ def warning_message(message):
|
|||||||
|
|
||||||
|
|
||||||
def error_message(message):
|
def error_message(message):
|
||||||
|
"""Prints an error message for fatal issues"""
|
||||||
|
|
||||||
error_string = f'''
|
error_string = f'''
|
||||||
jc: Error - {message}
|
jc: Error - {message}
|
||||||
'''
|
'''
|
||||||
@ -18,8 +22,11 @@ def error_message(message):
|
|||||||
|
|
||||||
|
|
||||||
def compatibility(mod_name, compatible):
|
def compatibility(mod_name, compatible):
|
||||||
"""
|
"""Checks for the parser's compatibility with the running OS platform.
|
||||||
compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
|
||||||
|
compatible options:
|
||||||
|
|
||||||
|
linux, darwin, cygwin, win32, aix, freebsd
|
||||||
"""
|
"""
|
||||||
if sys.platform not in compatible:
|
if sys.platform not in compatible:
|
||||||
mod = mod_name.split('.')[-1]
|
mod = mod_name.split('.')[-1]
|
||||||
|
Reference in New Issue
Block a user