mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
documentation update
This commit is contained in:
55
README.md
55
README.md
@ -68,6 +68,7 @@ jc [parser] [options]
|
|||||||
- `--jobs` enables the `jobs` parser
|
- `--jobs` enables the `jobs` parser
|
||||||
- `--ls` enables the `ls` parser
|
- `--ls` enables the `ls` parser
|
||||||
- `--lsblk` enables the `lsblk` parser
|
- `--lsblk` enables the `lsblk` parser
|
||||||
|
- `--lsmod` enables the `lsmod` parser
|
||||||
- `--lsof` enables the `lsof` parser
|
- `--lsof` enables the `lsof` parser
|
||||||
- `--mount` enables the `mount` parser
|
- `--mount` enables the `mount` parser
|
||||||
- `--netstat` enables the `netstat` parser
|
- `--netstat` enables the `netstat` parser
|
||||||
@ -671,6 +672,60 @@ $ lsblk | jc --lsblk -p
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
### lsmod
|
||||||
|
```
|
||||||
|
$ lsmod | jc --lsmod -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Module": "nf_nat_ipv4",
|
||||||
|
"Size": "14115",
|
||||||
|
"Used": "1",
|
||||||
|
"By": [
|
||||||
|
"iptable_nat"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
### lsof
|
### lsof
|
||||||
```
|
```
|
||||||
$ sudo lsof | jc --lsof -p
|
$ sudo lsof | jc --lsof -p
|
||||||
|
@ -5,7 +5,57 @@ Usage:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
$ lsmod | jc --lsmod -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Module": "nf_nat_ipv4",
|
||||||
|
"Size": "14115",
|
||||||
|
"Used": "1",
|
||||||
|
"By": [
|
||||||
|
"iptable_nat"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -17,10 +67,14 @@ def parse(data):
|
|||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
headers = [h for h in ' '.join(cleandata[0].strip().split()).split() if h]
|
headers = [h for h in ' '.join(cleandata[0].strip().split()).split() if h]
|
||||||
|
|
||||||
|
headers.pop(-1)
|
||||||
|
headers.append('By')
|
||||||
|
|
||||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||||
output = [dict(zip(headers, r)) for r in raw_data]
|
output = [dict(zip(headers, r)) for r in raw_data]
|
||||||
|
|
||||||
for entry in output:
|
for mod in output:
|
||||||
entry['NAME'] = entry['NAME'].encode('ascii', errors='ignore').decode()
|
if 'By' in mod:
|
||||||
|
mod['By'] = mod['By'].split(',')
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='jc',
|
name='jc',
|
||||||
version='0.9.0',
|
version='0.9.1',
|
||||||
author='Kelly Brazil',
|
author='Kelly Brazil',
|
||||||
author_email='kellyjonbrazil@gmail.com',
|
author_email='kellyjonbrazil@gmail.com',
|
||||||
description='This tool serializes the output of popular command line tools to structured JSON output.',
|
description='This tool serializes the output of popular command line tools to structured JSON output.',
|
||||||
|
Reference in New Issue
Block a user