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

documentation update

This commit is contained in:
Kelly Brazil
2019-10-23 18:30:55 -07:00
parent 66772392ae
commit 58ae976db0
3 changed files with 113 additions and 4 deletions

View File

@ -68,6 +68,7 @@ jc [parser] [options]
- `--jobs` enables the `jobs` parser
- `--ls` enables the `ls` parser
- `--lsblk` enables the `lsblk` parser
- `--lsmod` enables the `lsmod` parser
- `--lsof` enables the `lsof` parser
- `--mount` enables the `mount` 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
```
$ sudo lsof | jc --lsof -p

View File

@ -5,7 +5,57 @@ Usage:
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()
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:])
output = [dict(zip(headers, r)) for r in raw_data]
for entry in output:
entry['NAME'] = entry['NAME'].encode('ascii', errors='ignore').decode()
for mod in output:
if 'By' in mod:
mod['By'] = mod['By'].split(',')
return output

View File

@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
setuptools.setup(
name='jc',
version='0.9.0',
version='0.9.1',
author='Kelly Brazil',
author_email='kellyjonbrazil@gmail.com',
description='This tool serializes the output of popular command line tools to structured JSON output.',