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
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
* kellyjonbrazil@gmail.com
|
||||
|
||||
This module serializes standard unix command line output to structured JSON
|
||||
output.
|
||||
This package serializes the output of many standard unix command line tools to JSON format.
|
||||
|
||||
CLI Example:
|
||||
|
||||
$ ls -l /usr/bin | jc --ls -p
|
||||
[
|
||||
$ ls -l /usr/bin | jc --ls -p
|
||||
[
|
||||
{
|
||||
"filename": "apropos",
|
||||
"link_to": "whatis",
|
||||
@ -48,34 +47,34 @@ $ ls -l /usr/bin | jc --ls -p
|
||||
"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'}]
|
||||
>>> 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'}]
|
||||
"""
|
||||
|
||||
name = 'jc'
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ arp | jc --arp -p
|
||||
[
|
||||
$ arp | jc --arp -p
|
||||
[
|
||||
{
|
||||
"address": "192.168.71.254",
|
||||
"hwtype": "ether",
|
||||
@ -21,10 +21,10 @@ $ arp | jc --arp -p
|
||||
"flags_mask": "C",
|
||||
"iface": "ens33"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
$ arp | jc --arp -p -r
|
||||
[
|
||||
$ arp | jc --arp -p -r
|
||||
[
|
||||
{
|
||||
"address": "gateway",
|
||||
"hwtype": "ether",
|
||||
@ -39,10 +39,10 @@ $ arp | jc --arp -p -r
|
||||
"flags_mask": "C",
|
||||
"iface": "ens33"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
$ arp -a | jc --arp -p
|
||||
[
|
||||
$ arp -a | jc --arp -p
|
||||
[
|
||||
{
|
||||
"name": null,
|
||||
"address": "192.168.71.254",
|
||||
@ -57,11 +57,10 @@ $ arp -a | jc --arp -p
|
||||
"hwaddress": "00:50:56:f7:4a:fc",
|
||||
"iface": "ens33"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
$ arp -a | jc --arp -p -r
|
||||
[
|
||||
$ arp -a | jc --arp -p -r
|
||||
[
|
||||
{
|
||||
"name": "?",
|
||||
"address": "192.168.71.254",
|
||||
@ -76,13 +75,15 @@ $ arp -a | jc --arp -p -r
|
||||
"hwaddress": "00:50:56:f7:4a:fc",
|
||||
"iface": "ens33"
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
@ -93,7 +94,7 @@ def process(proc_data):
|
||||
"iface": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
# in BSD style, change name to null if it is a question mark
|
||||
for entry in proc_data:
|
||||
@ -104,6 +105,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ df | jc --df -p
|
||||
[
|
||||
$ df | jc --df -p
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": 1918820,
|
||||
@ -32,10 +32,10 @@ $ df | jc --df -p
|
||||
"mounted_on": "/run"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ df | jc --df -p -r
|
||||
[
|
||||
$ df | jc --df -p -r
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": "1918820",
|
||||
@ -61,13 +61,15 @@ $ df | jc --df -p -r
|
||||
"mounted_on": "/run"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
''' schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
@ -79,7 +81,7 @@ def process(proc_data):
|
||||
"mounted_on": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# change any entry for key with '-blocks' in the name to int
|
||||
for k in entry:
|
||||
@ -108,6 +110,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
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",
|
||||
@ -114,10 +114,10 @@ $ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
|
||||
"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",
|
||||
@ -146,13 +146,15 @@ $ dig -x 1.1.1.1 | jc --dig -p
|
||||
"when": "Wed Oct 30 03:13:48 PDT 2019",
|
||||
"rcvd": "98"
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
''' schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"id": integer,
|
||||
@ -194,7 +196,8 @@ def process(proc_data):
|
||||
"rcvd": integer
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
for entry in proc_data:
|
||||
int_list = ['id', 'query_num', 'answer_num', 'authority_num', 'additional_num', 'rcvd']
|
||||
for key in int_list:
|
||||
@ -312,6 +315,15 @@ def parse_answer(answer):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ env | jc --env -p
|
||||
[
|
||||
$ env | jc --env -p
|
||||
[
|
||||
{
|
||||
"name": "XDG_SESSION_ID",
|
||||
"value": "1"
|
||||
@ -28,10 +28,10 @@ $ env | jc --env -p
|
||||
"value": "1000"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ env | jc --env -p -r
|
||||
{
|
||||
$ env | jc --env -p -r
|
||||
{
|
||||
"TERM": "xterm-256color",
|
||||
"SHELL": "/bin/bash",
|
||||
"USER": "root",
|
||||
@ -41,20 +41,22 @@ $ env | jc --env -p -r
|
||||
"HOME": "/root",
|
||||
"LOGNAME": "root",
|
||||
"_": "/usr/bin/env"
|
||||
}
|
||||
}
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"value": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
# rebuild output for added semantic information
|
||||
processed = []
|
||||
@ -68,6 +70,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,17 +5,19 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ foo | jc --foo -p
|
||||
[]
|
||||
$ foo | jc --foo -p
|
||||
[]
|
||||
|
||||
$ foo | jc --foo -p -r
|
||||
[]
|
||||
$ foo | jc --foo -p -r
|
||||
[]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"foo": string,
|
||||
@ -23,13 +25,22 @@ def process(proc_data):
|
||||
"baz": integer
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
# rebuild output for added semantic information
|
||||
return proc_data
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ free | jc --free -p
|
||||
[
|
||||
$ free | jc --free -p
|
||||
[
|
||||
{
|
||||
"type": "Mem",
|
||||
"total": 3861340,
|
||||
@ -22,10 +22,10 @@ $ free | jc --free -p
|
||||
"used": 0,
|
||||
"free": 2097148
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
$ free | jc --free -p -r
|
||||
[
|
||||
$ free | jc --free -p -r
|
||||
[
|
||||
{
|
||||
"type": "Mem",
|
||||
"total": "2017300",
|
||||
@ -41,13 +41,15 @@ $ free | jc --free -p -r
|
||||
"used": "0",
|
||||
"free": "2097148"
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
@ -59,7 +61,7 @@ def process(proc_data):
|
||||
"available": integer
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
for entry in proc_data:
|
||||
int_list = ['total', 'used', 'free', 'shared', 'buff_cache', 'available']
|
||||
@ -75,6 +77,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ history | jc --history -p
|
||||
[
|
||||
$ history | jc --history -p
|
||||
[
|
||||
{
|
||||
"line": "118",
|
||||
"command": "sleep 100"
|
||||
@ -24,29 +24,31 @@ $ history | jc --history -p
|
||||
"command": "docker images"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ history | jc --history -p -r
|
||||
{
|
||||
$ history | jc --history -p -r
|
||||
{
|
||||
"118": "sleep 100",
|
||||
"119": "ls /bin",
|
||||
"120": "echo \"hello\"",
|
||||
"121": "docker images",
|
||||
...
|
||||
}
|
||||
}
|
||||
"""
|
||||
import jc
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"line": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
# rebuild output for added semantic information
|
||||
processed = []
|
||||
@ -60,6 +62,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
@ -7,8 +7,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ ifconfig | jc --ifconfig -p
|
||||
[
|
||||
$ ifconfig | jc --ifconfig -p
|
||||
[
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
@ -61,11 +61,10 @@ $ ifconfig | jc --ifconfig -p
|
||||
"tx_collisions": 0,
|
||||
"metric": null
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
$ ifconfig | jc --ifconfig -p -r
|
||||
[
|
||||
$ ifconfig | jc --ifconfig -p -r
|
||||
[
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": "4163",
|
||||
@ -118,14 +117,16 @@ $ ifconfig | jc --ifconfig -p -r
|
||||
"tx_collisions": "0",
|
||||
"metric": null
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
from ifconfigparser import IfconfigParser
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
@ -154,7 +155,7 @@ def process(proc_data):
|
||||
"metric": integer
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
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',
|
||||
@ -171,6 +172,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'aix', 'freebsd']
|
||||
|
||||
|
@ -7,8 +7,8 @@ Usage:
|
||||
|
||||
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": [
|
||||
@ -64,10 +64,10 @@ $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ 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": [
|
||||
@ -123,13 +123,15 @@ $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"chain": string,
|
||||
@ -150,7 +152,7 @@ def process(proc_data):
|
||||
]
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
for rule in entry['rules']:
|
||||
int_list = ['num', 'pkts']
|
||||
@ -194,6 +196,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -7,8 +7,8 @@ Usage:
|
||||
|
||||
Example:
|
||||
|
||||
$ jobs -l | jc --jobs -p
|
||||
[
|
||||
$ jobs -l | jc --jobs -p
|
||||
[
|
||||
{
|
||||
"job_number": 1,
|
||||
"pid": 5283,
|
||||
@ -35,10 +35,10 @@ $ jobs -l | jc --jobs -p
|
||||
"status": "Running",
|
||||
"command": "sleep 10112 &"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
$ jobs -l | jc --jobs -p -r
|
||||
[
|
||||
$ jobs -l | jc --jobs -p -r
|
||||
[
|
||||
{
|
||||
"job_number": "1",
|
||||
"pid": "19510",
|
||||
@ -65,14 +65,15 @@ $ jobs -l | jc --jobs -p -r
|
||||
"status": "Running",
|
||||
"command": "sleep 1003 &"
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
@ -82,7 +83,7 @@ def process(proc_data):
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['job_number', 'pid']
|
||||
for key in int_list:
|
||||
@ -97,6 +98,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
@ -12,8 +12,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ ls /usr/bin | jc --ls -p
|
||||
[
|
||||
$ ls /usr/bin | jc --ls -p
|
||||
[
|
||||
{
|
||||
"filename": "apropos"
|
||||
},
|
||||
@ -27,10 +27,10 @@ $ ls /usr/bin | jc --ls -p
|
||||
"filename": "base64"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ ls -l /usr/bin | jc --ls -p
|
||||
[
|
||||
$ ls -l /usr/bin | jc --ls -p
|
||||
[
|
||||
{
|
||||
"filename": "apropos",
|
||||
"link_to": "whatis",
|
||||
@ -60,10 +60,10 @@ $ ls -l /usr/bin | jc --ls -p
|
||||
"date": "Aug 19 23:25"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ ls -l /usr/bin | jc --ls -p -r
|
||||
[
|
||||
$ ls -l /usr/bin | jc --ls -p -r
|
||||
[
|
||||
{
|
||||
"filename": "apropos",
|
||||
"link_to": "whatis",
|
||||
@ -121,10 +121,10 @@ $ ls -l /usr/bin | jc --ls -p -r
|
||||
"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",
|
||||
"flags": "-r-xr-xr-x",
|
||||
"links": 1,
|
||||
@ -132,14 +132,16 @@ $ ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'
|
||||
"group": "wheel",
|
||||
"size": 117164432,
|
||||
"date": "May 3 2019"
|
||||
}
|
||||
}
|
||||
"""
|
||||
import re
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
@ -151,7 +153,8 @@ def process(proc_data):
|
||||
"date": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
|
||||
for entry in proc_data:
|
||||
int_list = ['links', 'size']
|
||||
for key in int_list:
|
||||
@ -166,6 +169,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsblk | jc --lsblk -p
|
||||
[
|
||||
$ lsblk | jc --lsblk -p
|
||||
[
|
||||
{
|
||||
"name": "sda",
|
||||
"maj_min": "8:0",
|
||||
@ -26,10 +26,10 @@ $ lsblk | jc --lsblk -p
|
||||
"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",
|
||||
"maj_min": "8:0",
|
||||
@ -115,10 +115,10 @@ $ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWN
|
||||
"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",
|
||||
"maj_min": "8:0",
|
||||
@ -204,14 +204,16 @@ $ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,STATE,OWN
|
||||
"vendor": null
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
@ -256,7 +258,7 @@ def process(proc_data):
|
||||
"vendor": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# boolean changes
|
||||
bool_list = ['rm', 'ro', 'rota', 'disc_zero', 'rand']
|
||||
@ -282,6 +284,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsmod | jc --lsmod -p
|
||||
[
|
||||
$ lsmod | jc --lsmod -p
|
||||
[
|
||||
...
|
||||
{
|
||||
"module": "nf_nat",
|
||||
@ -48,10 +48,10 @@ $ lsmod | jc --lsmod -p
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ lsmod | jc --lsmod -p -r
|
||||
[
|
||||
$ lsmod | jc --lsmod -p -r
|
||||
[
|
||||
...
|
||||
{
|
||||
"module": "nf_conntrack",
|
||||
@ -95,13 +95,15 @@ $ lsmod | jc --lsmod -p -r
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"module": string,
|
||||
@ -112,7 +114,7 @@ def process(proc_data):
|
||||
]
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# integer changes
|
||||
int_list = ['size', 'used']
|
||||
@ -128,6 +130,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo lsof | jc --lsof -p
|
||||
[
|
||||
$ sudo lsof | jc --lsof -p
|
||||
[
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": 1,
|
||||
@ -44,10 +44,10 @@ $ sudo lsof | jc --lsof -p
|
||||
"name": "/usr/lib/systemd/systemd"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ sudo lsof | jc --lsof -p -r
|
||||
[
|
||||
$ sudo lsof | jc --lsof -p -r
|
||||
[
|
||||
{
|
||||
"command": "systemd",
|
||||
"pid": "1",
|
||||
@ -85,14 +85,16 @@ $ sudo lsof | jc --lsof -p -r
|
||||
"name": "/lib/systemd/systemd"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"command": string,
|
||||
@ -107,7 +109,7 @@ def process(proc_data):
|
||||
"name": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# integer changes
|
||||
int_list = ['pid', 'tid', 'size_off', 'node']
|
||||
@ -122,6 +124,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Example:
|
||||
|
||||
$ mount | jc --mount -p
|
||||
[
|
||||
$ mount | jc --mount -p
|
||||
[
|
||||
{
|
||||
"filesystem": "sysfs",
|
||||
"mount_point": "/sys",
|
||||
@ -45,13 +45,15 @@ $ mount | jc --mount -p
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
@ -64,11 +66,20 @@ def process(proc_data):
|
||||
]
|
||||
|
||||
nothing to process
|
||||
'''
|
||||
"""
|
||||
return proc_data
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo netstat -apee | jc --netstat -p
|
||||
[
|
||||
$ sudo netstat -apee | jc --netstat -p
|
||||
[
|
||||
{
|
||||
"proto": "tcp",
|
||||
"recv_q": 0,
|
||||
@ -153,10 +153,10 @@ $ sudo netstat -apee | jc --netstat -p
|
||||
"pid": 1
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ sudo netstat -apee | jc --netstat -p -r
|
||||
[
|
||||
$ sudo netstat -apee | jc --netstat -p -r
|
||||
[
|
||||
{
|
||||
"proto": "tcp",
|
||||
"recv_q": "0",
|
||||
@ -301,14 +301,16 @@ $ sudo netstat -apee | jc --netstat -p -r
|
||||
"pid": " 1"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"proto": string,
|
||||
@ -335,7 +337,7 @@ def process(proc_data):
|
||||
"kind": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# integer changes
|
||||
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):
|
||||
"""
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -9,8 +9,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ ps -ef | jc --ps -p
|
||||
[
|
||||
$ ps -ef | jc --ps -p
|
||||
[
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": 1,
|
||||
@ -42,10 +42,10 @@ $ ps -ef | jc --ps -p
|
||||
"cmd": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ ps -ef | jc --ps -p -r
|
||||
[
|
||||
$ ps -ef | jc --ps -p -r
|
||||
[
|
||||
{
|
||||
"uid": "root",
|
||||
"pid": "1",
|
||||
@ -77,10 +77,10 @@ $ ps -ef | jc --ps -p -r
|
||||
"cmd": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ ps axu | jc --ps -p
|
||||
[
|
||||
$ ps axu | jc --ps -p
|
||||
[
|
||||
{
|
||||
"user": "root",
|
||||
"pid": 1,
|
||||
@ -121,10 +121,10 @@ $ ps axu | jc --ps -p
|
||||
"command": "[kworker/0:0H]"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
|
||||
$ ps axu | jc --ps -p -r
|
||||
[
|
||||
$ ps axu | jc --ps -p -r
|
||||
[
|
||||
{
|
||||
"user": "root",
|
||||
"pid": "1",
|
||||
@ -178,13 +178,15 @@ $ ps axu | jc --ps -p -r
|
||||
"command": "[ksoftirqd/0]"
|
||||
},
|
||||
...
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"uid": string,
|
||||
@ -205,7 +207,7 @@ def process(proc_data):
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# change to int
|
||||
int_list = ['pid', 'ppid', 'c', 'vsz', 'rss']
|
||||
@ -235,6 +237,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ route -ee | jc --route -p
|
||||
[
|
||||
$ route -ee | jc --route -p
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
@ -46,10 +46,10 @@ $ route -ee | jc --route -p
|
||||
"window": 0,
|
||||
"irtt": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
$ route -ee | jc --route -p -r
|
||||
[
|
||||
$ route -ee | jc --route -p -r
|
||||
[
|
||||
{
|
||||
"destination": "default",
|
||||
"gateway": "gateway",
|
||||
@ -89,13 +89,15 @@ $ route -ee | jc --route -p -r
|
||||
"window": "0",
|
||||
"irtt": "0"
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"destination": string,
|
||||
@ -111,7 +113,7 @@ def process(proc_data):
|
||||
"iface": string
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['metric', 'ref', 'use', 'mss', 'window', 'irtt']
|
||||
for key in int_list:
|
||||
@ -126,6 +128,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'aix', 'freebsd']
|
||||
|
||||
|
@ -8,8 +8,8 @@ Limitations:
|
||||
|
||||
Example:
|
||||
|
||||
$ uname -a | jc --uname -p
|
||||
{
|
||||
$ uname -a | jc --uname -p
|
||||
{
|
||||
"kernel_name": "Linux",
|
||||
"node_name": "user-ubuntu",
|
||||
"kernel_release": "4.15.0-65-generic",
|
||||
@ -18,13 +18,15 @@ $ uname -a | jc --uname -p
|
||||
"processor": "x86_64",
|
||||
"machine": "x86_64",
|
||||
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||
}
|
||||
}
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
{
|
||||
"kernel_name": string,
|
||||
"node_name": string,
|
||||
@ -37,11 +39,20 @@ def process(proc_data):
|
||||
}
|
||||
|
||||
no extra processing
|
||||
'''
|
||||
"""
|
||||
return proc_data
|
||||
|
||||
|
||||
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 = ['linux']
|
||||
|
||||
|
@ -5,31 +5,33 @@ Usage:
|
||||
|
||||
Example:
|
||||
|
||||
$ uptime | jc --uptime -p
|
||||
{
|
||||
$ 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
|
||||
{
|
||||
$ 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"
|
||||
}
|
||||
}
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
{
|
||||
"time": string,
|
||||
"uptime": string,
|
||||
@ -38,7 +40,7 @@ def process(proc_data):
|
||||
"load_5m": float,
|
||||
"load_15m": float
|
||||
}
|
||||
'''
|
||||
"""
|
||||
int_list = ['users']
|
||||
for key in int_list:
|
||||
if key in proc_data:
|
||||
@ -61,6 +63,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
@ -5,8 +5,8 @@ Usage:
|
||||
|
||||
Examples:
|
||||
|
||||
$ w | jc --w -p
|
||||
[
|
||||
$ w | jc --w -p
|
||||
[
|
||||
{
|
||||
"user": "root",
|
||||
"tty": "tty1",
|
||||
@ -37,10 +37,10 @@ $ w | jc --w -p
|
||||
"pcpu": "0.00s",
|
||||
"what": "-bash"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
$ w | jc --w -p -r
|
||||
[
|
||||
$ w | jc --w -p -r
|
||||
[
|
||||
{
|
||||
"user": "kbrazil",
|
||||
"tty": "tty1",
|
||||
@ -71,14 +71,16 @@ $ w | jc --w -p -r
|
||||
"pcpu": "0.00s",
|
||||
"what": "-bash"
|
||||
}
|
||||
]
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
"""
|
||||
schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string, # '-'' = null
|
||||
@ -91,7 +93,7 @@ def process(proc_data):
|
||||
"what": string # '-'' = null
|
||||
}
|
||||
]
|
||||
'''
|
||||
"""
|
||||
for entry in proc_data:
|
||||
null_list = ['user', 'tty', 'from', 'login_at', 'idle', 'what']
|
||||
for key in null_list:
|
||||
@ -103,6 +105,15 @@ def process(proc_data):
|
||||
|
||||
|
||||
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 = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
11
jc/utils.py
11
jc/utils.py
@ -4,6 +4,8 @@ import sys
|
||||
|
||||
|
||||
def warning_message(message):
|
||||
"""Prints a warning message for non-fatal issues"""
|
||||
|
||||
error_string = f'''
|
||||
jc: Warning - {message}
|
||||
'''
|
||||
@ -11,6 +13,8 @@ def warning_message(message):
|
||||
|
||||
|
||||
def error_message(message):
|
||||
"""Prints an error message for fatal issues"""
|
||||
|
||||
error_string = f'''
|
||||
jc: Error - {message}
|
||||
'''
|
||||
@ -18,8 +22,11 @@ def error_message(message):
|
||||
|
||||
|
||||
def compatibility(mod_name, compatible):
|
||||
"""
|
||||
compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
"""Checks for the parser's compatibility with the running OS platform.
|
||||
|
||||
compatible options:
|
||||
|
||||
linux, darwin, cygwin, win32, aix, freebsd
|
||||
"""
|
||||
if sys.platform not in compatible:
|
||||
mod = mod_name.split('.')[-1]
|
||||
|
Reference in New Issue
Block a user