mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
206
README.md
206
README.md
@@ -45,14 +45,12 @@ The `jc` parsers can also be used as python modules. In this case the output wil
|
||||
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 18128,
|
||||
'date': 'May 3 22:26'}]
|
||||
```
|
||||
Two representations of the data are possible. The default representation uses a strict schema per parser and converts known numbers to int/float JSON values. Certain known values of None are converted to JSON Null, known boolean values are converted, and, in some cases, additional semantic context fields are added.
|
||||
Two representations of the data are possible. The default representation uses a strict schema per parser and converts known numbers to int/float JSON values. Certain known values of `None` are converted to JSON `null`, known boolean values are converted, and, in some cases, additional semantic context fields are added.
|
||||
|
||||
To access the raw, pre-processed JSON, use the `-r` cli option or the `raw=True` function parameter in `parse()`.
|
||||
|
||||
Schemas for each parser can be found in the `docs/parsers` folder.
|
||||
|
||||
> ***Note:** Due to the introduction of schemas in version `1.5.1` the output of some parsers will be different than in versions `1.1.1` and below. Now that schemas are defined, the output will be stable for future versions. You can still get similar output to prior versions with the `-r` or `raw=true` options. Though the goal is to keep all output stable, raw output is not guaranteed to stay the same in future releases.*
|
||||
|
||||
## Installation
|
||||
```
|
||||
$ pip3 install --upgrade jc
|
||||
@@ -67,8 +65,10 @@ jc PARSER [OPTIONS]
|
||||
|
||||
### Parsers
|
||||
- `--arp` enables the `arp` parser
|
||||
- `--crontab` enables the `crontab` file parser
|
||||
- `--df` enables the `df` parser
|
||||
- `--dig` enables the `dig` parser
|
||||
- `--du` enables the `du` parser
|
||||
- `--env` enables the `env` parser
|
||||
- `--free` enables the `free` parser
|
||||
- `--fstab` enables the `/etc/fstab` file parser
|
||||
@@ -83,6 +83,8 @@ jc PARSER [OPTIONS]
|
||||
- `--lsof` enables the `lsof` parser
|
||||
- `--mount` enables the `mount` parser
|
||||
- `--netstat` enables the `netstat` parser
|
||||
- `--pip-list` enables the `pip list` parser
|
||||
- `--pip-show` enables the `pip show` parser
|
||||
- `--ps` enables the `ps` parser
|
||||
- `--route` enables the `route` parser
|
||||
- `--ss` enables the `ss` parser
|
||||
@@ -96,6 +98,7 @@ jc PARSER [OPTIONS]
|
||||
- `--w` enables the `w` parser
|
||||
|
||||
### Options
|
||||
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!)
|
||||
- `-d` debug mode. Prints trace messages if parsing issues encountered
|
||||
- `-p` pretty format the JSON output
|
||||
- `-q` quiet mode. Suppresses warning messages
|
||||
@@ -155,13 +158,84 @@ $ arp -a | jc --arp -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### crontab
|
||||
```
|
||||
$ cat /etc/crontab | jc --crontab -p
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": [
|
||||
"5"
|
||||
],
|
||||
"hour": [
|
||||
"10-11",
|
||||
"22"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
"30"
|
||||
],
|
||||
"hour": [
|
||||
"4/2"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
### df
|
||||
```
|
||||
$ df | jc --df -p
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": 1918816,
|
||||
"1k_blocks": 1918816,
|
||||
"used": 0,
|
||||
"available": 1918816,
|
||||
"use_percent": 0,
|
||||
@@ -169,7 +243,7 @@ $ df | jc --df -p
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": 1930664,
|
||||
"1k_blocks": 1930664,
|
||||
"used": 0,
|
||||
"available": 1930664,
|
||||
"use_percent": 0,
|
||||
@@ -336,6 +410,37 @@ $ dig -x 1.1.1.1 | jc --dig -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### du
|
||||
```
|
||||
$ du /usr | jc --du -p
|
||||
[
|
||||
{
|
||||
"size": 104608,
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": 56,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": 1008,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
### env
|
||||
```
|
||||
$ env | jc --env -p
|
||||
@@ -493,22 +598,29 @@ $ ifconfig | jc --ifconfig -p
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"state": [
|
||||
"UP",
|
||||
"BROADCAST",
|
||||
"RUNNING",
|
||||
"MULTICAST"
|
||||
],
|
||||
"mtu": 1500,
|
||||
"ipv4_addr": "192.168.71.138",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"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",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": 6374,
|
||||
"rx_packets": 8061,
|
||||
"rx_bytes": 1514413,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 3707,
|
||||
"tx_packets": 4502,
|
||||
"tx_bytes": 866622,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@@ -519,22 +631,28 @@ $ ifconfig | jc --ifconfig -p
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": 73,
|
||||
"state": "UP,LOOPBACK,RUNNING",
|
||||
"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",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": 81,
|
||||
"rx_packets": 73,
|
||||
"rx_bytes": 6009,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 81,
|
||||
"tx_packets": 73,
|
||||
"tx_bytes": 6009,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@@ -983,6 +1101,56 @@ $ sudo netstat -apee | jc --netstat -p
|
||||
...
|
||||
]
|
||||
```
|
||||
### pip list
|
||||
```
|
||||
$ pip list | jc --pip-list -p
|
||||
[
|
||||
{
|
||||
"package": "ansible",
|
||||
"version": "2.8.5"
|
||||
},
|
||||
{
|
||||
"package": "antlr4-python3-runtime",
|
||||
"version": "4.7.2"
|
||||
},
|
||||
{
|
||||
"package": "asn1crypto",
|
||||
"version": "0.24.0"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
```
|
||||
### pip show
|
||||
```
|
||||
$ pip show wrapt wheel | jc --pip-show -p
|
||||
[
|
||||
{
|
||||
"name": "wrapt",
|
||||
"version": "1.11.2",
|
||||
"summary": "Module for decorators, wrappers and monkey patching.",
|
||||
"home_page": "https://github.com/GrahamDumpleton/wrapt",
|
||||
"author": "Graham Dumpleton",
|
||||
"author_email": "Graham.Dumpleton@gmail.com",
|
||||
"license": "BSD",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": "astroid"
|
||||
},
|
||||
{
|
||||
"name": "wheel",
|
||||
"version": "0.33.4",
|
||||
"summary": "A built-package format for Python.",
|
||||
"home_page": "https://github.com/pypa/wheel",
|
||||
"author": "Daniel Holth",
|
||||
"author_email": "dholth@fastmail.fm",
|
||||
"license": "MIT",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": null
|
||||
}
|
||||
]
|
||||
```
|
||||
### ps
|
||||
```
|
||||
$ ps -ef | jc --ps -p
|
||||
@@ -1433,9 +1601,6 @@ $ w | jc --w -p
|
||||
```
|
||||
## TODO
|
||||
Future parsers:
|
||||
- nslookup
|
||||
- journalctl
|
||||
- crontab files
|
||||
- /proc files
|
||||
- /sys files
|
||||
|
||||
@@ -1443,7 +1608,10 @@ Future parsers:
|
||||
Feel free to add/improve code or parsers! You can use the `jc/parsers/foo.py` parser as a template and submit your parser with a pull request.
|
||||
|
||||
## Compatibility
|
||||
Some parsers like `ls`, `ps`, `dig`, etc. will work on any platform. Other parsers that are platform-specific will generate a warning message if they are used on an unsupported platform. You may still use a parser on an unsupported platform - for example, you may want to parse a file with linux `lsof` output on an OSX laptop. In that case you can suppress the warning message with the `-q` cli option or the `quiet=True` function parameter in `parse()`:
|
||||
Some parsers like `ls`, `ps`, `dig`, etc. will work on any platform. Other parsers that are platform-specific will generate a warning message if they are used on an unsupported platform. To see all parser information, including compatibility, run `jc -a -p`.
|
||||
|
||||
|
||||
You may still use a parser on an unsupported platform - for example, you may want to parse a file with linux `lsof` output on an OSX laptop. In that case you can suppress the warning message with the `-q` cli option or the `quiet=True` function parameter in `parse()`:
|
||||
|
||||
```
|
||||
$ cat lsof.out | jc --lsof -q
|
||||
@@ -1452,6 +1620,8 @@ $ cat lsof.out | jc --lsof -q
|
||||
Tested on:
|
||||
- Centos 7.7
|
||||
- Ubuntu 18.4
|
||||
- OSX 10.11.6
|
||||
- OSX 10.14.6
|
||||
|
||||
## Acknowledgments
|
||||
- `ifconfig-parser` module from https://github.com/KnightWhoSayNi/ifconfig-parser
|
||||
|
@@ -1,5 +1,16 @@
|
||||
jc changelog
|
||||
|
||||
20191217 v1.6.1
|
||||
- Add du parser (tested on linux and OSX)
|
||||
- Add crontab parser (tested on linux and OSX)
|
||||
- Add pip list parser (tested on linux and OSX)
|
||||
- Add pip show parser (tested on linux and OSX)
|
||||
- Add OSX support for the ifconfig, arp, df, mount, and uname parsers
|
||||
- Add tests for ls, dig, ps, w, uptime on OSX
|
||||
- Add about option
|
||||
- Add universal parsers to refactor repetitive code
|
||||
- Updated ifconfig parser to output 'state' as an array
|
||||
|
||||
20191117 v1.5.1
|
||||
- Add ss parser
|
||||
- Add stat parser
|
||||
|
@@ -5,8 +5,10 @@ cd jc
|
||||
pydocmd simple jc+ > ../docs/readme.md
|
||||
pydocmd simple utils+ > ../docs/utils.md
|
||||
pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md
|
||||
pydocmd simple jc.parsers.crontab+ > ../docs/parsers/crontab.md
|
||||
pydocmd simple jc.parsers.df+ > ../docs/parsers/df.md
|
||||
pydocmd simple jc.parsers.dig+ > ../docs/parsers/dig.md
|
||||
pydocmd simple jc.parsers.du+ > ../docs/parsers/du.md
|
||||
pydocmd simple jc.parsers.env+ > ../docs/parsers/env.md
|
||||
pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md
|
||||
pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md
|
||||
@@ -21,6 +23,8 @@ 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.pip_list+ > ../docs/parsers/pip_list.md
|
||||
pydocmd simple jc.parsers.pip_show+ > ../docs/parsers/pip_show.md
|
||||
pydocmd simple jc.parsers.ps+ > ../docs/parsers/ps.md
|
||||
pydocmd simple jc.parsers.route+ > ../docs/parsers/route.md
|
||||
pydocmd simple jc.parsers.ss+ > ../docs/parsers/ss.md
|
||||
|
@@ -2,7 +2,16 @@
|
||||
jc - JSON CLI output utility arp Parser
|
||||
|
||||
Usage:
|
||||
specify --arp as the first argument if the piped input is coming from arp
|
||||
|
||||
specify --arp as the first argument if the piped input is coming from:
|
||||
|
||||
arp
|
||||
or
|
||||
arp -a
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'aix', 'freebsd', 'darwin'
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -78,6 +87,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -91,7 +105,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -119,5 +133,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
197
docs/parsers/crontab.md
Normal file
197
docs/parsers/crontab.md
Normal file
@@ -0,0 +1,197 @@
|
||||
# jc.parsers.crontab
|
||||
jc - JSON CLI output utility crontab file Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --crontab as the first argument if the piped input is coming from a crontab file
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/crontab | jc --crontab -p
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": [
|
||||
"5"
|
||||
],
|
||||
"hour": [
|
||||
"10-11",
|
||||
"22"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
"30"
|
||||
],
|
||||
"hour": [
|
||||
"4/2"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
$ cat /etc/crontab | jc --crontab -p -r
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": "5",
|
||||
"hour": "10-11,22",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": "30",
|
||||
"hour": "4/2",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"variables": [
|
||||
"name": string,
|
||||
"value": string
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"occurrence" string,
|
||||
"minute": [
|
||||
string
|
||||
],
|
||||
"hour": [
|
||||
string
|
||||
],
|
||||
"day_of_month": [
|
||||
string
|
||||
],
|
||||
"month": [
|
||||
string
|
||||
],
|
||||
"day_of_week": [
|
||||
string
|
||||
],
|
||||
"occurrence": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
@@ -2,15 +2,20 @@
|
||||
jc - JSON CLI output utility df Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --df as the first argument if the piped input is coming from df
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin'
|
||||
|
||||
Examples:
|
||||
|
||||
$ df | jc --df -p
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": 1918820,
|
||||
"1k_blocks": 1918820,
|
||||
"used": 0,
|
||||
"available": 1918820,
|
||||
"use_percent": 0,
|
||||
@@ -18,7 +23,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": 1930668,
|
||||
"1k_blocks": 1930668,
|
||||
"used": 0,
|
||||
"available": 1930668,
|
||||
"use_percent": 0,
|
||||
@@ -26,7 +31,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": 1930668,
|
||||
"1k_blocks": 1930668,
|
||||
"used": 11800,
|
||||
"available": 1918868,
|
||||
"use_percent": 1,
|
||||
@@ -39,7 +44,7 @@ Examples:
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": "1918820",
|
||||
"1k_blocks": "1918820",
|
||||
"used": "0",
|
||||
"available": "1918820",
|
||||
"use_percent": "0%",
|
||||
@@ -47,7 +52,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": "1930668",
|
||||
"1k_blocks": "1930668",
|
||||
"used": "0",
|
||||
"available": "1930668",
|
||||
"use_percent": "0%",
|
||||
@@ -55,7 +60,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": "1930668",
|
||||
"1k_blocks": "1930668",
|
||||
"used": "11800",
|
||||
"available": "1918868",
|
||||
"use_percent": "1%",
|
||||
@@ -64,6 +69,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -77,17 +87,22 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"size": string,
|
||||
"1k-blocks": integer,
|
||||
"used": integer,
|
||||
"available": integer,
|
||||
"use_percent": integer,
|
||||
"mounted_on": string
|
||||
"filesystem": string,
|
||||
"size": string,
|
||||
"1k_blocks": integer,
|
||||
"512_blocks": integer,
|
||||
"used": integer,
|
||||
"available": integer,
|
||||
"capacity_percent": integer,
|
||||
"ifree": integer,
|
||||
"iused": integer,
|
||||
"use_percent": integer,
|
||||
"iused_percent": integer,
|
||||
"mounted_on": string
|
||||
}
|
||||
]
|
||||
|
||||
@@ -106,5 +121,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility dig Parser
|
||||
|
||||
Usage:
|
||||
|
||||
Specify --dig as the first argument if the piped input is coming from dig
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
|
||||
@@ -316,6 +321,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -329,7 +339,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -388,5 +398,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
115
docs/parsers/du.md
Normal file
115
docs/parsers/du.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# jc.parsers.du
|
||||
jc - JSON CLI output utility du Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --du as the first argument if the piped input is coming from du
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ du /usr | jc --du -p
|
||||
[
|
||||
{
|
||||
"size": 104608,
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": 56,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": 1008,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ du /usr | jc --du -p -r
|
||||
[
|
||||
{
|
||||
"size": "104608",
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": "56",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": "1008",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"size": integer,
|
||||
"name": string
|
||||
}
|
||||
]
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility env Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --env as the first argument if the piped input is coming from env
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ env | jc --env -p
|
||||
@@ -44,6 +49,11 @@ Examples:
|
||||
"_": "/usr/bin/env"
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -57,7 +67,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -81,5 +91,6 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility free Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --free as the first argument if the piped input is coming from free
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ free | jc --free -p
|
||||
@@ -44,6 +49,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -57,7 +67,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -86,5 +96,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility fstab Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --fstab as the first argument if the piped input is coming from a fstab file
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/fstab | jc --fstab -p
|
||||
@@ -62,6 +67,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -75,7 +85,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -103,5 +113,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility history Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --history as the first argument if the piped input is coming from history
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ history | jc --history -p
|
||||
@@ -36,6 +41,11 @@ Examples:
|
||||
...
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -49,7 +59,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -73,5 +83,6 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility hosts Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --hosts as the first argument if the piped input is coming from a hosts file
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/hosts | jc --hosts -p
|
||||
@@ -53,6 +58,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -66,7 +76,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -92,5 +102,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,10 +2,15 @@
|
||||
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.
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'aix', 'freebsd', 'darwin'
|
||||
|
||||
Examples:
|
||||
|
||||
$ ifconfig | jc --ifconfig -p
|
||||
@@ -13,22 +18,29 @@ Examples:
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"state": [
|
||||
"UP",
|
||||
"BROADCAST",
|
||||
"RUNNING",
|
||||
"MULTICAST"
|
||||
],
|
||||
"mtu": 1500,
|
||||
"ipv4_addr": "192.168.71.138",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"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",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": 6374,
|
||||
"rx_packets": 8061,
|
||||
"rx_bytes": 1514413,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 3707,
|
||||
"tx_packets": 4502,
|
||||
"tx_bytes": 866622,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@@ -39,22 +51,28 @@ Examples:
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": 73,
|
||||
"state": "UP,LOOPBACK,RUNNING",
|
||||
"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",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": 81,
|
||||
"rx_packets": 73,
|
||||
"rx_bytes": 6009,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 81,
|
||||
"tx_packets": 73,
|
||||
"tx_bytes": 6009,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@@ -71,20 +89,22 @@ Examples:
|
||||
"flags": "4163",
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"mtu": "1500",
|
||||
"ipv4_addr": "192.168.71.135",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"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",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": "26348",
|
||||
"rx_packets": "8061",
|
||||
"rx_bytes": "1514413",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "5308",
|
||||
"tx_packets": "4502",
|
||||
"tx_bytes": "866622",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
@@ -102,15 +122,17 @@ Examples:
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": "128",
|
||||
"ipv6_scope": "host",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": "64",
|
||||
"rx_packets": "73",
|
||||
"rx_bytes": "6009",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "64",
|
||||
"tx_packets": "73",
|
||||
"tx_bytes": "6009",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
@@ -120,6 +142,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -133,13 +160,15 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"flags": integer,
|
||||
"state": string,
|
||||
"state": [
|
||||
string
|
||||
],
|
||||
"mtu": integer,
|
||||
"ipv4_addr": string,
|
||||
"ipv4_mask": string,
|
||||
@@ -150,11 +179,13 @@ Returns:
|
||||
"mac_addr": string,
|
||||
"type": string,
|
||||
"rx_packets": integer,
|
||||
"rx_bytes": integer,
|
||||
"rx_errors": integer,
|
||||
"rx_dropped": integer,
|
||||
"rx_overruns": integer,
|
||||
"rx_frame": integer,
|
||||
"tx_packets": integer,
|
||||
"tx_bytes": integer,
|
||||
"tx_errors": integer,
|
||||
"tx_dropped": integer,
|
||||
"tx_overruns": integer,
|
||||
@@ -179,5 +210,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,10 +2,15 @@
|
||||
jc - JSON CLI output utility ipables Parser
|
||||
|
||||
Usage:
|
||||
|
||||
Specify --iptables as the first argument if the piped input is coming from iptables
|
||||
|
||||
Supports -vLn and --line-numbers for all tables
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||
@@ -126,6 +131,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -139,7 +149,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -177,5 +187,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,10 +2,15 @@
|
||||
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
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Example:
|
||||
|
||||
$ jobs -l | jc --jobs -p
|
||||
@@ -68,6 +73,11 @@ Example:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -81,7 +91,8 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
@@ -107,5 +118,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,14 +2,19 @@
|
||||
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.
|
||||
- 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.
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -135,6 +140,11 @@ Examples:
|
||||
"date": "May 3 2019"
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -148,7 +158,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -177,5 +187,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility lsblk Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --lsblk as the first argument if the piped input is coming from lsblk
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsblk | jc --lsblk -p
|
||||
@@ -207,6 +212,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -220,7 +230,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -282,5 +292,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility lsmod Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --lsmod as the first argument if the piped input is coming from lsmod
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsmod | jc --lsmod -p
|
||||
@@ -98,6 +103,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -111,7 +121,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -139,5 +149,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility lsof Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --lsof as the first argument if the piped input is coming from lsof
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo lsof | jc --lsof -p
|
||||
@@ -88,6 +93,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -101,7 +111,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -133,5 +143,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility mount Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --mount as the first argument if the piped input is coming from mount
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin'
|
||||
|
||||
Example:
|
||||
|
||||
$ mount | jc --mount -p
|
||||
@@ -48,6 +53,11 @@ Example:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -61,7 +71,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -89,5 +99,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility netstat Parser
|
||||
|
||||
Usage:
|
||||
|
||||
Specify --netstat as the first argument if the piped input is coming from netstat
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo netstat -apee | jc --netstat -p
|
||||
@@ -304,6 +309,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -317,7 +327,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -361,5 +371,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
75
docs/parsers/pip_list.md
Normal file
75
docs/parsers/pip_list.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# jc.parsers.pip_list
|
||||
jc - JSON CLI output utility pip-list Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --pip-list as the first argument if the piped input is coming from pip list
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ pip list | jc --pip-list -p
|
||||
[
|
||||
{
|
||||
"package": "ansible",
|
||||
"version": "2.8.5"
|
||||
},
|
||||
{
|
||||
"package": "antlr4-python3-runtime",
|
||||
"version": "4.7.2"
|
||||
},
|
||||
{
|
||||
"package": "asn1crypto",
|
||||
"version": "0.24.0"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"location": string
|
||||
}
|
||||
]
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
94
docs/parsers/pip_show.md
Normal file
94
docs/parsers/pip_show.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# jc.parsers.pip_show
|
||||
jc - JSON CLI output utility pip-show Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --pip-show as the first argument if the piped input is coming from pip show
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ pip show wrapt jc wheel | jc --pip-show -p
|
||||
[
|
||||
{
|
||||
"name": "wrapt",
|
||||
"version": "1.11.2",
|
||||
"summary": "Module for decorators, wrappers and monkey patching.",
|
||||
"home_page": "https://github.com/GrahamDumpleton/wrapt",
|
||||
"author": "Graham Dumpleton",
|
||||
"author_email": "Graham.Dumpleton@gmail.com",
|
||||
"license": "BSD",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": "astroid"
|
||||
},
|
||||
{
|
||||
"name": "wheel",
|
||||
"version": "0.33.4",
|
||||
"summary": "A built-package format for Python.",
|
||||
"home_page": "https://github.com/pypa/wheel",
|
||||
"author": "Daniel Holth",
|
||||
"author_email": "dholth@fastmail.fm",
|
||||
"license": "MIT",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": null
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
```
|
||||
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"version": string,
|
||||
"summary": string,
|
||||
"home_page": string,
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"license": string,
|
||||
"location": string,
|
||||
"requires": string,
|
||||
"required_by": string
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
## parse
|
||||
```python
|
||||
parse(data, raw=False, quiet=False)
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
@@ -2,12 +2,17 @@
|
||||
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
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ ps -ef | jc --ps -p
|
||||
@@ -168,6 +173,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -181,7 +191,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -190,7 +200,8 @@ Returns:
|
||||
"ppid": integer,
|
||||
"c": integer,
|
||||
"stime": string,
|
||||
"tty": string, # ? = Null
|
||||
"tty": string, # ? or ?? = Null
|
||||
"tt": string, # ?? = Null
|
||||
"time": string,
|
||||
"cmd": string,
|
||||
"user": string,
|
||||
@@ -219,5 +230,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility route Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --route as the first argument if the piped input is coming from route
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ route -ee | jc --route -p
|
||||
@@ -92,6 +97,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -105,7 +115,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -138,5 +148,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,11 +2,17 @@
|
||||
jc - JSON CLI output utility ss Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --ss as the first argument if the piped input is coming from ss
|
||||
|
||||
Limitations:
|
||||
|
||||
Extended information options like -e and -p are not supported and may cause parsing irregularities
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo ss -a | jc --ss -p
|
||||
@@ -241,6 +247,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -254,7 +265,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -293,5 +304,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -1,8 +1,13 @@
|
||||
# jc.parsers.stat
|
||||
jc - JSON CLI output utility stats Parser
|
||||
jc - JSON CLI output utility stat Parser
|
||||
|
||||
Usage:
|
||||
specify --stats as the first argument if the piped input is coming from stats
|
||||
|
||||
specify --stat as the first argument if the piped input is coming from stat
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -96,6 +101,11 @@ Examples:
|
||||
..
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -109,7 +119,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -150,5 +160,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility systemctl Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl as the first argument if the piped input is coming from systemctl
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl -a | jc --systemctl -p
|
||||
@@ -32,6 +37,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -45,7 +55,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -72,5 +82,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility systemctl-lj Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl-lj as the first argument if the piped input is coming from systemctl list-jobs
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-jobs| jc --systemctl-lj -p
|
||||
@@ -51,6 +56,11 @@ Examples:
|
||||
]
|
||||
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -64,7 +74,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -90,5 +100,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility systemctl-ls Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl-ls as the first argument if the piped input is coming from systemctl list-sockets
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-sockets | jc --systemctl-ls -p
|
||||
@@ -26,6 +31,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -39,7 +49,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -64,5 +74,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility systemctl-luf Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl-luf as the first argument if the piped input is coming from systemctl list-unit-files
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-unit-files | jc --systemctl-luf -p
|
||||
@@ -23,6 +28,11 @@ Examples:
|
||||
...
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -36,7 +46,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -60,5 +70,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,11 +2,17 @@
|
||||
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'
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin'
|
||||
|
||||
Example:
|
||||
|
||||
$ uname -a | jc --uname -p
|
||||
@@ -21,6 +27,11 @@ Example:
|
||||
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -34,7 +45,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"kernel_name": string,
|
||||
@@ -62,5 +73,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility uptime Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --uptime as the first argument if the piped input is coming from uptime
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Example:
|
||||
|
||||
$ uptime | jc --uptime -p
|
||||
@@ -26,6 +31,11 @@ Example:
|
||||
"load_15m": "0.05"
|
||||
}
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -39,7 +49,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"time": string,
|
||||
@@ -65,5 +75,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary. Raw or processed structured data
|
||||
|
||||
|
@@ -2,8 +2,13 @@
|
||||
jc - JSON CLI output utility w Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --w as the first argument if the piped input is coming from w
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ w | jc --w -p
|
||||
@@ -74,6 +79,11 @@ Examples:
|
||||
}
|
||||
]
|
||||
|
||||
## info
|
||||
```python
|
||||
info(self, /, *args, **kwargs)
|
||||
```
|
||||
|
||||
## process
|
||||
```python
|
||||
process(proc_data)
|
||||
@@ -87,7 +97,7 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -117,5 +127,5 @@ Parameters:
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
|
||||
|
180
jc/cli.py
180
jc/cli.py
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""jc - JSON CLI output utility
|
||||
|
||||
JC cli module
|
||||
"""
|
||||
import sys
|
||||
@@ -9,8 +8,10 @@ import signal
|
||||
import json
|
||||
import jc.utils
|
||||
import jc.parsers.arp
|
||||
import jc.parsers.crontab
|
||||
import jc.parsers.df
|
||||
import jc.parsers.dig
|
||||
import jc.parsers.du
|
||||
import jc.parsers.env
|
||||
import jc.parsers.free
|
||||
import jc.parsers.fstab
|
||||
@@ -25,6 +26,8 @@ import jc.parsers.lsmod
|
||||
import jc.parsers.lsof
|
||||
import jc.parsers.mount
|
||||
import jc.parsers.netstat
|
||||
import jc.parsers.pip_list
|
||||
import jc.parsers.pip_show
|
||||
import jc.parsers.ps
|
||||
import jc.parsers.route
|
||||
import jc.parsers.ss
|
||||
@@ -37,48 +40,101 @@ import jc.parsers.uname
|
||||
import jc.parsers.uptime
|
||||
import jc.parsers.w
|
||||
|
||||
parser_map = {
|
||||
'--arp': jc.parsers.arp,
|
||||
'--crontab': jc.parsers.crontab,
|
||||
'--df': jc.parsers.df,
|
||||
'--dig': jc.parsers.dig,
|
||||
'--du': jc.parsers.du,
|
||||
'--env': jc.parsers.env,
|
||||
'--free': jc.parsers.free,
|
||||
'--fstab': jc.parsers.fstab,
|
||||
'--history': jc.parsers.history,
|
||||
'--hosts': jc.parsers.hosts,
|
||||
'--ifconfig': jc.parsers.ifconfig,
|
||||
'--iptables': jc.parsers.iptables,
|
||||
'--jobs': jc.parsers.jobs,
|
||||
'--ls': jc.parsers.ls,
|
||||
'--lsblk': jc.parsers.lsblk,
|
||||
'--lsmod': jc.parsers.lsmod,
|
||||
'--lsof': jc.parsers.lsof,
|
||||
'--mount': jc.parsers.mount,
|
||||
'--netstat': jc.parsers.netstat,
|
||||
'--pip-list': jc.parsers.pip_list,
|
||||
'--pip-show': jc.parsers.pip_show,
|
||||
'--ps': jc.parsers.ps,
|
||||
'--route': jc.parsers.route,
|
||||
'--ss': jc.parsers.ss,
|
||||
'--stat': jc.parsers.stat,
|
||||
'--systemctl': jc.parsers.systemctl,
|
||||
'--systemctl-lj': jc.parsers.systemctl_lj,
|
||||
'--systemctl-ls': jc.parsers.systemctl_ls,
|
||||
'--systemctl-luf': jc.parsers.systemctl_luf,
|
||||
'--uname': jc.parsers.uname,
|
||||
'--uptime': jc.parsers.uptime,
|
||||
'--w': jc.parsers.w
|
||||
}
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.6.1'
|
||||
description = 'jc cli output JSON conversion tool'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
|
||||
def ctrlc(signum, frame):
|
||||
exit()
|
||||
|
||||
|
||||
def parsers_text():
|
||||
ptext = ''
|
||||
for parser in parser_map:
|
||||
if hasattr(parser_map[parser], 'info'):
|
||||
padding = 16 - len(parser)
|
||||
padding_char = ' '
|
||||
padding_text = padding_char * padding
|
||||
ptext += ' ' + parser + padding_text + parser_map[parser].info.description + '\n'
|
||||
|
||||
return ptext
|
||||
|
||||
|
||||
def about_jc():
|
||||
parser_list = []
|
||||
for parser in parser_map:
|
||||
if hasattr(parser_map[parser], 'info'):
|
||||
info_dict = {}
|
||||
info_dict['name'] = parser_map[parser].__name__.split('.')[-1]
|
||||
info_dict['argument'] = parser
|
||||
parser_entry = vars(parser_map[parser].info)
|
||||
for k, v in parser_entry.items():
|
||||
if not k.startswith('__'):
|
||||
info_dict[k] = v
|
||||
parser_list.append(info_dict)
|
||||
|
||||
return {
|
||||
'name': 'jc',
|
||||
'version': info.version,
|
||||
'description': info.description,
|
||||
'author': info.author,
|
||||
'author_email': info.author_email,
|
||||
'parser_count': len(parser_list),
|
||||
'parsers': parser_list
|
||||
}
|
||||
|
||||
|
||||
def helptext(message):
|
||||
parsers_string = parsers_text()
|
||||
|
||||
helptext_string = f'''
|
||||
jc: {message}
|
||||
|
||||
Usage: jc PARSER [OPTIONS]
|
||||
|
||||
Parsers:
|
||||
--arp arp parser
|
||||
--df df parser
|
||||
--dig dig parser
|
||||
--env env parser
|
||||
--free free parser
|
||||
--fstab /etc/fstab file parser
|
||||
--history history parser
|
||||
--hosts /etc/hosts file parser
|
||||
--ifconfig iconfig parser
|
||||
--iptables iptables parser
|
||||
--jobs jobs parser
|
||||
--ls ls parser
|
||||
--lsblk lsblk parser
|
||||
--lsmod lsmod parser
|
||||
--lsof lsof parser
|
||||
--mount mount parser
|
||||
--netstat netstat parser
|
||||
--ps ps parser
|
||||
--route route parser
|
||||
--ss ss parser
|
||||
--stat stat parser
|
||||
--systemctl systemctl parser
|
||||
--systemctl-lj systemctl list-jobs parser
|
||||
--systemctl-ls systemctl list-sockets parser
|
||||
--systemctl-luf systemctl list-unit-files parser
|
||||
--uname uname -a parser
|
||||
--uptime uptime parser
|
||||
--w w parser
|
||||
|
||||
{parsers_string}
|
||||
Options:
|
||||
-a about jc
|
||||
-d debug - show trace messages
|
||||
-p pretty print output
|
||||
-q quiet - suppress warnings
|
||||
@@ -90,14 +146,16 @@ def helptext(message):
|
||||
print(textwrap.dedent(helptext_string), file=sys.stderr)
|
||||
|
||||
|
||||
def json_out(data, pretty=False):
|
||||
if pretty:
|
||||
print(json.dumps(data, indent=2))
|
||||
else:
|
||||
print(json.dumps(data))
|
||||
|
||||
|
||||
def main():
|
||||
signal.signal(signal.SIGINT, ctrlc)
|
||||
|
||||
if sys.stdin.isatty():
|
||||
helptext('missing piped data')
|
||||
exit()
|
||||
|
||||
data = sys.stdin.read()
|
||||
debug = False
|
||||
pretty = False
|
||||
quiet = False
|
||||
@@ -116,55 +174,33 @@ def main():
|
||||
if '-r' in sys.argv:
|
||||
raw = True
|
||||
|
||||
# parsers
|
||||
parser_map = {
|
||||
'--arp': jc.parsers.arp.parse,
|
||||
'--df': jc.parsers.df.parse,
|
||||
'--dig': jc.parsers.dig.parse,
|
||||
'--env': jc.parsers.env.parse,
|
||||
'--free': jc.parsers.free.parse,
|
||||
'--fstab': jc.parsers.fstab.parse,
|
||||
'--history': jc.parsers.history.parse,
|
||||
'--hosts': jc.parsers.hosts.parse,
|
||||
'--ifconfig': jc.parsers.ifconfig.parse,
|
||||
'--iptables': jc.parsers.iptables.parse,
|
||||
'--jobs': jc.parsers.jobs.parse,
|
||||
'--ls': jc.parsers.ls.parse,
|
||||
'--lsblk': jc.parsers.lsblk.parse,
|
||||
'--lsmod': jc.parsers.lsmod.parse,
|
||||
'--lsof': jc.parsers.lsof.parse,
|
||||
'--mount': jc.parsers.mount.parse,
|
||||
'--netstat': jc.parsers.netstat.parse,
|
||||
'--ps': jc.parsers.ps.parse,
|
||||
'--route': jc.parsers.route.parse,
|
||||
'--ss': jc.parsers.ss.parse,
|
||||
'--stat': jc.parsers.stat.parse,
|
||||
'--systemctl': jc.parsers.systemctl.parse,
|
||||
'--systemctl-lj': jc.parsers.systemctl_lj.parse,
|
||||
'--systemctl-ls': jc.parsers.systemctl_ls.parse,
|
||||
'--systemctl-luf': jc.parsers.systemctl_luf.parse,
|
||||
'--uname': jc.parsers.uname.parse,
|
||||
'--uptime': jc.parsers.uptime.parse,
|
||||
'--w': jc.parsers.w.parse
|
||||
}
|
||||
if '-a' in sys.argv:
|
||||
json_out(about_jc(), pretty=pretty)
|
||||
exit()
|
||||
|
||||
if sys.stdin.isatty():
|
||||
helptext('missing piped data')
|
||||
exit()
|
||||
|
||||
data = sys.stdin.read()
|
||||
|
||||
found = False
|
||||
|
||||
if debug:
|
||||
for arg in sys.argv:
|
||||
if arg in parser_map:
|
||||
result = parser_map[arg](data, raw=raw, quiet=quiet)
|
||||
result = parser_map[arg].parse(data, raw=raw, quiet=quiet)
|
||||
found = True
|
||||
break
|
||||
else:
|
||||
for arg in sys.argv:
|
||||
if arg in parser_map:
|
||||
try:
|
||||
result = parser_map[arg](data, raw=raw, quiet=quiet)
|
||||
result = parser_map[arg].parse(data, raw=raw, quiet=quiet)
|
||||
found = True
|
||||
break
|
||||
except:
|
||||
parser_name = arg.lstrip('--')
|
||||
parser_name = parser_map[arg].__name__.split('.')[-1]
|
||||
jc.utils.error_message(f'{parser_name} parser could not parse the input data. Did you use the correct parser?\n For details use the -d option.')
|
||||
exit(1)
|
||||
|
||||
@@ -172,11 +208,7 @@ def main():
|
||||
helptext('missing or incorrect arguments')
|
||||
exit()
|
||||
|
||||
# output resulting dictionary as json
|
||||
if pretty:
|
||||
print(json.dumps(result, indent=2))
|
||||
else:
|
||||
print(json.dumps(result))
|
||||
json_out(result, pretty=pretty)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@@ -1,7 +1,16 @@
|
||||
"""jc - JSON CLI output utility arp Parser
|
||||
|
||||
Usage:
|
||||
specify --arp as the first argument if the piped input is coming from arp
|
||||
|
||||
specify --arp as the first argument if the piped input is coming from:
|
||||
|
||||
arp
|
||||
or
|
||||
arp -a
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'aix', 'freebsd', 'darwin'
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -78,6 +87,17 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'arp parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -90,7 +110,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -124,39 +144,50 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
# code adapted from Conor Heine at:
|
||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# remove final Entries row if -v was used
|
||||
if cleandata[-1].find("Entries:") == 0:
|
||||
if cleandata[-1].find('Entries:') == 0:
|
||||
cleandata.pop(-1)
|
||||
|
||||
# detect if linux or bsd style was used
|
||||
if cleandata[0].find('Address') == 0:
|
||||
|
||||
# fix header row to change Flags Mask to flags_mask
|
||||
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
||||
|
||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
# detect if osx style was used
|
||||
if cleandata[0].find(' ifscope ') != -1:
|
||||
raw_output = []
|
||||
for line in cleandata:
|
||||
line = line.split()
|
||||
output_line = {}
|
||||
output_line['name'] = line[0]
|
||||
output_line['address'] = line[1].lstrip('(').rstrip(')')
|
||||
output_line['hwtype'] = line[-1].lstrip('[').rstrip(']')
|
||||
output_line['hwaddress'] = line[3]
|
||||
output_line['iface'] = line[5]
|
||||
raw_output.append(output_line)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
|
||||
# detect if linux style was used
|
||||
elif cleandata[0].find('Address') == 0:
|
||||
|
||||
# fix header row to change Flags Mask to flags_mask
|
||||
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
|
||||
# otherwise, try bsd style
|
||||
else:
|
||||
raw_output = []
|
||||
for line in cleandata:
|
||||
|
266
jc/parsers/crontab.py
Normal file
266
jc/parsers/crontab.py
Normal file
@@ -0,0 +1,266 @@
|
||||
"""jc - JSON CLI output utility crontab file Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --crontab as the first argument if the piped input is coming from a crontab file
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/crontab | jc --crontab -p
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": [
|
||||
"5"
|
||||
],
|
||||
"hour": [
|
||||
"10-11",
|
||||
"22"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": [
|
||||
"30"
|
||||
],
|
||||
"hour": [
|
||||
"4/2"
|
||||
],
|
||||
"day_of_month": [
|
||||
"*"
|
||||
],
|
||||
"month": [
|
||||
"*"
|
||||
],
|
||||
"day_of_week": [
|
||||
"*"
|
||||
],
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
$ cat /etc/crontab | jc --crontab -p -r
|
||||
{
|
||||
"variables": [
|
||||
{
|
||||
"name": "MAILTO",
|
||||
"value": "root"
|
||||
},
|
||||
{
|
||||
"name": "PATH",
|
||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
},
|
||||
{
|
||||
"name": "SHELL",
|
||||
"value": "/bin/bash"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"minute": "5",
|
||||
"hour": "10-11,22",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||
},
|
||||
{
|
||||
"minute": "30",
|
||||
"hour": "4/2",
|
||||
"day_of_month": "*",
|
||||
"month": "*",
|
||||
"day_of_week": "*",
|
||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||
},
|
||||
{
|
||||
"occurrence": "yearly",
|
||||
"command": "/home/maverick/bin/annual-maintenance"
|
||||
},
|
||||
{
|
||||
"occurrence": "reboot",
|
||||
"command": "/home/cleanup"
|
||||
},
|
||||
{
|
||||
"occurrence": "monthly",
|
||||
"command": "/home/maverick/bin/tape-backup"
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'crontab file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
# details = 'enter any other details here'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"variables": [
|
||||
"name": string,
|
||||
"value": string
|
||||
],
|
||||
"schedule": [
|
||||
{
|
||||
"occurrence" string,
|
||||
"minute": [
|
||||
string
|
||||
],
|
||||
"hour": [
|
||||
string
|
||||
],
|
||||
"day_of_month": [
|
||||
string
|
||||
],
|
||||
"month": [
|
||||
string
|
||||
],
|
||||
"day_of_week": [
|
||||
string
|
||||
],
|
||||
"occurrence": string,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
"""
|
||||
# put itmes in lists
|
||||
try:
|
||||
for entry in proc_data['schedule']:
|
||||
entry['minute'] = entry['minute'].split(',')
|
||||
entry['hour'] = entry['hour'].split(',')
|
||||
entry['day_of_month'] = entry['day_of_month'].split(',')
|
||||
entry['month'] = entry['month'].split(',')
|
||||
entry['day_of_week'] = entry['day_of_week'].split(',')
|
||||
except (KeyError):
|
||||
pass
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
# Clear any commented lines
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().find('#') == 0:
|
||||
cleandata.pop(i)
|
||||
|
||||
# Pop any variable assignment lines
|
||||
cron_var = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.find('=') != -1:
|
||||
var_line = cleandata.pop(i)
|
||||
var_name = var_line.split('=', maxsplit=1)[0].strip()
|
||||
var_value = var_line.split('=', maxsplit=1)[1].strip()
|
||||
cron_var.append({'name': var_name,
|
||||
'value': var_value})
|
||||
|
||||
raw_output['variables'] = cron_var
|
||||
|
||||
# Pop any shortcut lines
|
||||
shortcut_list = []
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.strip().startswith('@'):
|
||||
shortcut_line = cleandata.pop(i)
|
||||
occurrence = shortcut_line.split(maxsplit=1)[0].strip().lstrip('@')
|
||||
cmd = shortcut_line.split(maxsplit=1)[1].strip()
|
||||
shortcut_list.append({'occurrence': occurrence,
|
||||
'command': cmd})
|
||||
|
||||
# Add header row for parsing
|
||||
cleandata[0] = 'minute hour day_of_month month day_of_week command'
|
||||
|
||||
if len(cleandata) > 1:
|
||||
cron_list = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
raw_output['schedule'] = cron_list
|
||||
|
||||
# Add shortcut entries back in
|
||||
for item in shortcut_list:
|
||||
raw_output['schedule'].append(item)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
102
jc/parsers/df.py
102
jc/parsers/df.py
@@ -1,15 +1,20 @@
|
||||
"""jc - JSON CLI output utility df Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --df as the first argument if the piped input is coming from df
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin'
|
||||
|
||||
Examples:
|
||||
|
||||
$ df | jc --df -p
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": 1918820,
|
||||
"1k_blocks": 1918820,
|
||||
"used": 0,
|
||||
"available": 1918820,
|
||||
"use_percent": 0,
|
||||
@@ -17,7 +22,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": 1930668,
|
||||
"1k_blocks": 1930668,
|
||||
"used": 0,
|
||||
"available": 1930668,
|
||||
"use_percent": 0,
|
||||
@@ -25,7 +30,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": 1930668,
|
||||
"1k_blocks": 1930668,
|
||||
"used": 11800,
|
||||
"available": 1918868,
|
||||
"use_percent": 1,
|
||||
@@ -38,7 +43,7 @@ Examples:
|
||||
[
|
||||
{
|
||||
"filesystem": "devtmpfs",
|
||||
"1k-blocks": "1918820",
|
||||
"1k_blocks": "1918820",
|
||||
"used": "0",
|
||||
"available": "1918820",
|
||||
"use_percent": "0%",
|
||||
@@ -46,7 +51,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": "1930668",
|
||||
"1k_blocks": "1930668",
|
||||
"used": "0",
|
||||
"available": "1930668",
|
||||
"use_percent": "0%",
|
||||
@@ -54,7 +59,7 @@ Examples:
|
||||
},
|
||||
{
|
||||
"filesystem": "tmpfs",
|
||||
"1k-blocks": "1930668",
|
||||
"1k_blocks": "1930668",
|
||||
"used": "11800",
|
||||
"available": "1918868",
|
||||
"use_percent": "1%",
|
||||
@@ -64,6 +69,17 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'df parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -76,36 +92,64 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
"size": string,
|
||||
"1k-blocks": integer,
|
||||
"used": integer,
|
||||
"available": integer,
|
||||
"use_percent": integer,
|
||||
"mounted_on": string
|
||||
"filesystem": string,
|
||||
"size": string,
|
||||
"1k_blocks": integer,
|
||||
"512_blocks": integer,
|
||||
"used": integer,
|
||||
"available": integer,
|
||||
"capacity_percent": integer,
|
||||
"ifree": integer,
|
||||
"iused": integer,
|
||||
"use_percent": integer,
|
||||
"iused_percent": integer,
|
||||
"mounted_on": string
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
for entry in proc_data:
|
||||
# change any entry for key with '-blocks' in the name to int
|
||||
# change 'avail' to 'available'
|
||||
if 'avail' in entry:
|
||||
entry['available'] = entry.pop('avail')
|
||||
|
||||
# change 'use%' to 'use_percent'
|
||||
if 'use%' in entry:
|
||||
entry['use_percent'] = entry.pop('use%')
|
||||
|
||||
# change 'capacity' to 'capacity_percent'
|
||||
if 'capacity' in entry:
|
||||
entry['capacity_percent'] = entry.pop('capacity')
|
||||
|
||||
# change '%iused' to 'iused_percent'
|
||||
if '%iused' in entry:
|
||||
entry['iused_percent'] = entry.pop('%iused')
|
||||
|
||||
# change any entry for key with '_blocks' in the name to int
|
||||
for k in entry:
|
||||
if str(k).find('-blocks') != -1:
|
||||
if str(k).find('_blocks') != -1:
|
||||
try:
|
||||
blocks_int = int(entry[k])
|
||||
entry[k] = blocks_int
|
||||
except (ValueError):
|
||||
entry[k] = None
|
||||
|
||||
# remove percent sign from 'use_percent'
|
||||
# remove percent sign from 'use_percent', 'capacity_percent', and 'iused_percent'
|
||||
if 'use_percent' in entry:
|
||||
entry['use_percent'] = entry['use_percent'].rstrip('%')
|
||||
|
||||
# change used, available, and use_percent to int
|
||||
int_list = ['used', 'available', 'use_percent']
|
||||
if 'capacity_percent' in entry:
|
||||
entry['capacity_percent'] = entry['capacity_percent'].rstrip('%')
|
||||
|
||||
if 'iused_percent' in entry:
|
||||
entry['iused_percent'] = entry['iused_percent'].rstrip('%')
|
||||
|
||||
# change used, available, use_percent, capacity_percent, ifree, iused, iused_percent to int
|
||||
int_list = ['used', 'available', 'use_percent', 'capacity_percent', 'ifree', 'iused', 'iused_percent']
|
||||
for key in int_list:
|
||||
if key in entry:
|
||||
try:
|
||||
@@ -129,23 +173,21 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
fix_headers = cleandata[0].lower().replace('avail ', 'available ')
|
||||
fix_headers = fix_headers.replace('use%', 'use_percent')
|
||||
fix_headers = fix_headers.replace('mounted on', 'mounted_on')
|
||||
headers = [h for h in ' '.join(fix_headers.strip().split()).split() if h]
|
||||
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
# fix headers
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
cleandata[0] = cleandata[0].replace('mounted on', 'mounted_on')
|
||||
|
||||
# parse the data
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility dig Parser
|
||||
|
||||
Usage:
|
||||
|
||||
Specify --dig as the first argument if the piped input is coming from dig
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p
|
||||
@@ -318,6 +323,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'dig parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -328,7 +343,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -501,14 +516,11 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
148
jc/parsers/du.py
Normal file
148
jc/parsers/du.py
Normal file
@@ -0,0 +1,148 @@
|
||||
"""jc - JSON CLI output utility du Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --du as the first argument if the piped input is coming from du
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ du /usr | jc --du -p
|
||||
[
|
||||
{
|
||||
"size": 104608,
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": 56,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": 0,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": 1008,
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ du /usr | jc --du -p -r
|
||||
[
|
||||
{
|
||||
"size": "104608",
|
||||
"name": "/usr/bin"
|
||||
},
|
||||
{
|
||||
"size": "56",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
|
||||
},
|
||||
{
|
||||
"size": "0",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
|
||||
},
|
||||
{
|
||||
"size": "1008",
|
||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'du parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
# details = 'enter any other details here'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"size": integer,
|
||||
"name": string
|
||||
}
|
||||
]
|
||||
"""
|
||||
int_list = ['size']
|
||||
for entry in proc_data:
|
||||
for key in int_list:
|
||||
if key in entry:
|
||||
try:
|
||||
key_int = int(entry[key])
|
||||
entry[key] = key_int
|
||||
except (ValueError):
|
||||
entry[key] = None
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
cleandata.insert(0, 'size name')
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility env Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --env as the first argument if the piped input is coming from env
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ env | jc --env -p
|
||||
@@ -46,6 +51,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'env parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -56,7 +71,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -89,14 +104,11 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility foo Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --foo as the first argument if the piped input is coming from foo
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ foo | jc --foo -p
|
||||
@@ -14,6 +19,17 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'foo parser'
|
||||
author = 'John Doe'
|
||||
author_email = 'johndoe@gmail.com'
|
||||
# details = 'enter any other details here'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -24,7 +40,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -51,14 +67,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility free Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --free as the first argument if the piped input is coming from free
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ free | jc --free -p
|
||||
@@ -44,6 +49,17 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'free parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -56,7 +72,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -96,28 +112,17 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
# code adapted from Conor Heine at:
|
||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||
headers.insert(0, "type")
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('buff/cache', 'buff_cache')
|
||||
cleandata[0] = 'type ' + cleandata[0]
|
||||
|
||||
# clean up 'buff/cache' header
|
||||
# even though forward slash in a key is valid json, it can make things difficult
|
||||
headers = ['buff_cache' if x == 'buff/cache' else x for x in headers]
|
||||
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
for entry in raw_output:
|
||||
entry['type'] = entry['type'].rstrip(':')
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility fstab Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --fstab as the first argument if the piped input is coming from a fstab file
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/fstab | jc --fstab -p
|
||||
@@ -64,6 +69,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = '/etc/fstab file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -74,7 +89,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -112,14 +127,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility history Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --history as the first argument if the piped input is coming from history
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ history | jc --history -p
|
||||
@@ -38,6 +43,16 @@ Examples:
|
||||
import jc
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'history parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -48,7 +63,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -81,14 +96,11 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary of raw structured data or
|
||||
list of dictionaries of processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility hosts Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --hosts as the first argument if the piped input is coming from a hosts file
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ cat /etc/hosts | jc --hosts -p
|
||||
@@ -55,6 +60,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = '/etc/hosts file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -65,7 +80,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -93,14 +108,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@@ -1,10 +1,15 @@
|
||||
"""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.
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'aix', 'freebsd', 'darwin'
|
||||
|
||||
Examples:
|
||||
|
||||
$ ifconfig | jc --ifconfig -p
|
||||
@@ -12,22 +17,29 @@ Examples:
|
||||
{
|
||||
"name": "ens33",
|
||||
"flags": 4163,
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"state": [
|
||||
"UP",
|
||||
"BROADCAST",
|
||||
"RUNNING",
|
||||
"MULTICAST"
|
||||
],
|
||||
"mtu": 1500,
|
||||
"ipv4_addr": "192.168.71.138",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"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",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": 6374,
|
||||
"rx_packets": 8061,
|
||||
"rx_bytes": 1514413,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 3707,
|
||||
"tx_packets": 4502,
|
||||
"tx_bytes": 866622,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@@ -38,22 +50,28 @@ Examples:
|
||||
{
|
||||
"name": "lo",
|
||||
"flags": 73,
|
||||
"state": "UP,LOOPBACK,RUNNING",
|
||||
"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",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": 81,
|
||||
"rx_packets": 73,
|
||||
"rx_bytes": 6009,
|
||||
"rx_errors": 0,
|
||||
"rx_dropped": 0,
|
||||
"rx_overruns": 0,
|
||||
"rx_frame": 0,
|
||||
"tx_packets": 81,
|
||||
"tx_packets": 73,
|
||||
"tx_bytes": 6009,
|
||||
"tx_errors": 0,
|
||||
"tx_dropped": 0,
|
||||
"tx_overruns": 0,
|
||||
@@ -70,20 +88,22 @@ Examples:
|
||||
"flags": "4163",
|
||||
"state": "UP,BROADCAST,RUNNING,MULTICAST",
|
||||
"mtu": "1500",
|
||||
"ipv4_addr": "192.168.71.135",
|
||||
"ipv4_addr": "192.168.71.137",
|
||||
"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",
|
||||
"ipv6_scope": "0x20",
|
||||
"mac_addr": "00:0c:29:3b:58:0e",
|
||||
"type": "Ethernet",
|
||||
"rx_packets": "26348",
|
||||
"rx_packets": "8061",
|
||||
"rx_bytes": "1514413",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "5308",
|
||||
"tx_packets": "4502",
|
||||
"tx_bytes": "866622",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
@@ -101,15 +121,17 @@ Examples:
|
||||
"ipv4_bcast": null,
|
||||
"ipv6_addr": "::1",
|
||||
"ipv6_mask": "128",
|
||||
"ipv6_scope": "host",
|
||||
"ipv6_scope": "0x10",
|
||||
"mac_addr": null,
|
||||
"type": "Local Loopback",
|
||||
"rx_packets": "64",
|
||||
"rx_packets": "73",
|
||||
"rx_bytes": "6009",
|
||||
"rx_errors": "0",
|
||||
"rx_dropped": "0",
|
||||
"rx_overruns": "0",
|
||||
"rx_frame": "0",
|
||||
"tx_packets": "64",
|
||||
"tx_packets": "73",
|
||||
"tx_bytes": "6009",
|
||||
"tx_errors": "0",
|
||||
"tx_dropped": "0",
|
||||
"tx_overruns": "0",
|
||||
@@ -123,6 +145,17 @@ import jc.utils
|
||||
from ifconfigparser import IfconfigParser
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.5'
|
||||
description = 'ifconfig parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Using ifconfig-parser package from https://github.com/KnightWhoSayNi/ifconfig-parser'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -133,13 +166,15 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"flags": integer,
|
||||
"state": string,
|
||||
"state": [
|
||||
string
|
||||
],
|
||||
"mtu": integer,
|
||||
"ipv4_addr": string,
|
||||
"ipv4_mask": string,
|
||||
@@ -150,11 +185,13 @@ def process(proc_data):
|
||||
"mac_addr": string,
|
||||
"type": string,
|
||||
"rx_packets": integer,
|
||||
"rx_bytes": integer,
|
||||
"rx_errors": integer,
|
||||
"rx_dropped": integer,
|
||||
"rx_overruns": integer,
|
||||
"rx_frame": integer,
|
||||
"tx_packets": integer,
|
||||
"tx_bytes": integer,
|
||||
"tx_errors": integer,
|
||||
"tx_dropped": integer,
|
||||
"tx_overruns": integer,
|
||||
@@ -165,8 +202,8 @@ def process(proc_data):
|
||||
]
|
||||
"""
|
||||
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',
|
||||
int_list = ['flags', 'mtu', 'ipv6_mask', 'rx_packets', 'rx_bytes', 'rx_errors', 'rx_dropped', 'rx_overruns',
|
||||
'rx_frame', 'tx_packets', 'tx_bytes', 'tx_errors', 'tx_dropped', 'tx_overruns', 'tx_carrier',
|
||||
'tx_collisions', 'metric']
|
||||
for key in int_list:
|
||||
if key in entry:
|
||||
@@ -176,6 +213,25 @@ def process(proc_data):
|
||||
except (ValueError, TypeError):
|
||||
entry[key] = None
|
||||
|
||||
# convert OSX-style subnet mask to dotted quad
|
||||
if 'ipv4_mask' in entry:
|
||||
try:
|
||||
if entry['ipv4_mask'].find('0x') == 0:
|
||||
new_mask = entry['ipv4_mask']
|
||||
new_mask = new_mask.lstrip('0x')
|
||||
new_mask = '.'.join(str(int(i, 16)) for i in [new_mask[i:i + 2] for i in range(0, len(new_mask), 2)])
|
||||
entry['ipv4_mask'] = new_mask
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
# convert state value to an array
|
||||
if 'state' in entry:
|
||||
try:
|
||||
new_state = entry['state'].split(',')
|
||||
entry['state'] = new_state
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
@@ -184,21 +240,17 @@ def parse(data, raw=False, quiet=False):
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@@ -1,10 +1,15 @@
|
||||
"""jc - JSON CLI output utility ipables Parser
|
||||
|
||||
Usage:
|
||||
|
||||
Specify --iptables as the first argument if the piped input is coming from iptables
|
||||
|
||||
Supports -vLn and --line-numbers for all tables
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||
@@ -128,6 +133,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'iptables parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -138,8 +153,8 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"chain": string,
|
||||
@@ -215,14 +230,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
chain = {}
|
||||
|
@@ -1,10 +1,15 @@
|
||||
"""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
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Example:
|
||||
|
||||
$ jobs -l | jc --jobs -p
|
||||
@@ -71,6 +76,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'jobs parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -81,7 +96,8 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"job_number": integer,
|
||||
@@ -117,14 +133,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@@ -1,14 +1,19 @@
|
||||
"""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.
|
||||
- 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.
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -138,6 +143,16 @@ import re
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'ls parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -148,7 +163,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -188,14 +203,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility lsblk Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --lsblk as the first argument if the piped input is coming from lsblk
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsblk | jc --lsblk -p
|
||||
@@ -206,8 +211,18 @@ Examples:
|
||||
...
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
description = 'lsblk parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -220,7 +235,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -303,82 +318,25 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
# unicode \u2063 = invisible separator and should not be seen in lsblk output
|
||||
delim = '\u2063'
|
||||
|
||||
raw_output = []
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
cleandata = data.splitlines()
|
||||
|
||||
header_text = cleandata.pop(0).lower()
|
||||
header_text = header_text.replace(':', '_')
|
||||
header_text = header_text.replace('-', '_')
|
||||
header_text = header_text + ' '
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace(':', '_')
|
||||
cleandata[0] = cleandata[0].replace('-', '_')
|
||||
|
||||
header_list = header_text.split()
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
|
||||
# find each column index and end position
|
||||
header_search = [header_list[0]]
|
||||
for h in header_list[1:]:
|
||||
header_search.append(' ' + h + ' ')
|
||||
|
||||
header_spec_list = []
|
||||
for i, column in enumerate(header_list[0:len(header_list) - 1]):
|
||||
header_spec = {
|
||||
'name': column,
|
||||
'end': header_text.find(header_search[i + 1])
|
||||
}
|
||||
|
||||
header_spec_list.append(header_spec)
|
||||
|
||||
# parse lines
|
||||
if cleandata:
|
||||
for entry in cleandata:
|
||||
output_line = {}
|
||||
|
||||
# insert new separator since data can contain spaces
|
||||
for col in reversed(header_list):
|
||||
# find the right header_spec
|
||||
for h_spec in header_spec_list:
|
||||
if h_spec['name'] == col:
|
||||
h_end = h_spec['end']
|
||||
# check if the location contains whitespace. if not
|
||||
# then move to the left until a space is found
|
||||
while h_end > 0 and entry[h_end] not in string.whitespace:
|
||||
h_end -= 1
|
||||
|
||||
# insert custom delimiter
|
||||
entry = entry[:h_end] + delim + entry[h_end + 1:]
|
||||
|
||||
# create the entry list from the new custom delimiter
|
||||
entry_list = entry.split(delim, maxsplit=len(header_list) - 1)
|
||||
|
||||
# clean up leading and trailing spaces in entry
|
||||
clean_entry_list = []
|
||||
for col in entry_list:
|
||||
clean_entry = col.strip().rstrip()
|
||||
if clean_entry == '':
|
||||
clean_entry = None
|
||||
|
||||
clean_entry_list.append(clean_entry)
|
||||
|
||||
output_line = dict(zip(header_list, clean_entry_list))
|
||||
raw_output.append(output_line)
|
||||
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in raw_output:
|
||||
entry['name'] = entry['name'].encode('ascii', errors='ignore').decode()
|
||||
# clean up non-ascii characters, if any
|
||||
for entry in raw_output:
|
||||
entry['name'] = entry['name'].encode('ascii', errors='ignore').decode()
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility lsmod Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --lsmod as the first argument if the piped input is coming from lsmod
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ lsmod | jc --lsmod -p
|
||||
@@ -98,6 +103,17 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'lsmod parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -110,7 +126,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -149,23 +165,15 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
# code adapted from Conor Heine at:
|
||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
for mod in raw_output:
|
||||
if 'by' in mod:
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility lsof Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --lsof as the first argument if the piped input is coming from lsof
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo lsof | jc --lsof -p
|
||||
@@ -87,8 +92,18 @@ Examples:
|
||||
...
|
||||
]
|
||||
"""
|
||||
import string
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'lsof parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -101,7 +116,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -143,14 +158,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
@@ -160,7 +171,12 @@ def parse(data, raw=False, quiet=False):
|
||||
cleandata = list(filter(None, linedata))
|
||||
|
||||
if cleandata:
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
cleandata[0] = cleandata[0].replace('/', '_')
|
||||
|
||||
raw_output = jc.parsers.universal.sparse_table_parse(cleandata)
|
||||
|
||||
'''
|
||||
# find column value of last character of each header
|
||||
header_text = cleandata.pop(0).lower()
|
||||
|
||||
@@ -199,6 +215,7 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
output_line = dict(zip(headers, fixed_line))
|
||||
raw_output.append(output_line)
|
||||
'''
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility mount Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --mount as the first argument if the piped input is coming from mount
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin'
|
||||
|
||||
Example:
|
||||
|
||||
$ mount | jc --mount -p
|
||||
@@ -50,6 +55,16 @@ Example:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'mount parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -60,8 +75,8 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filesystem": string,
|
||||
@@ -77,6 +92,51 @@ def process(proc_data):
|
||||
return proc_data
|
||||
|
||||
|
||||
def osx_parse(data):
|
||||
output = []
|
||||
|
||||
for entry in data:
|
||||
output_line = {}
|
||||
|
||||
filesystem = entry.split(' on ')
|
||||
filesystem = filesystem[0]
|
||||
output_line['filesystem'] = filesystem
|
||||
|
||||
mount_point = entry.split(' on ')
|
||||
mount_point = mount_point[1].split(' (')
|
||||
mount_point = mount_point[0]
|
||||
output_line['mount_point'] = mount_point
|
||||
|
||||
options = entry.split('(', maxsplit=1)
|
||||
options = options[1].rstrip(')')
|
||||
options = options.split(', ')
|
||||
output_line['options'] = options
|
||||
|
||||
output.append(output_line)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def linux_parse(data):
|
||||
output = []
|
||||
|
||||
for entry in data:
|
||||
output_line = {}
|
||||
parsed_line = entry.split()
|
||||
|
||||
output_line['filesystem'] = parsed_line[0]
|
||||
output_line['mount_point'] = parsed_line[2]
|
||||
output_line['type'] = parsed_line[4]
|
||||
|
||||
options = parsed_line[5].lstrip('(').rstrip(')').split(',')
|
||||
|
||||
output_line['options'] = options
|
||||
|
||||
output.append(output_line)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
@@ -89,16 +149,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
raw_output = []
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
@@ -106,19 +160,12 @@ def parse(data, raw=False, quiet=False):
|
||||
cleandata = list(filter(None, linedata))
|
||||
|
||||
if cleandata:
|
||||
for entry in cleandata:
|
||||
output_line = {}
|
||||
parsed_line = entry.split()
|
||||
# check for OSX output
|
||||
if cleandata[0].find(' type ') == -1:
|
||||
raw_output = osx_parse(cleandata)
|
||||
|
||||
output_line['filesystem'] = parsed_line[0]
|
||||
output_line['mount_point'] = parsed_line[2]
|
||||
output_line['type'] = parsed_line[4]
|
||||
|
||||
access = parsed_line[5].lstrip('(').rstrip(')').split(',')
|
||||
|
||||
output_line['options'] = access
|
||||
|
||||
raw_output.append(output_line)
|
||||
else:
|
||||
raw_output = linux_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility netstat Parser
|
||||
|
||||
Usage:
|
||||
|
||||
Specify --netstat as the first argument if the piped input is coming from netstat
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo netstat -apee | jc --netstat -p
|
||||
@@ -307,6 +312,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
description = 'netstat parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -317,7 +332,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -506,14 +521,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
113
jc/parsers/pip_list.py
Normal file
113
jc/parsers/pip_list.py
Normal file
@@ -0,0 +1,113 @@
|
||||
"""jc - JSON CLI output utility pip-list Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --pip-list as the first argument if the piped input is coming from pip list
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ pip list | jc --pip-list -p
|
||||
[
|
||||
{
|
||||
"package": "ansible",
|
||||
"version": "2.8.5"
|
||||
},
|
||||
{
|
||||
"package": "antlr4-python3-runtime",
|
||||
"version": "4.7.2"
|
||||
},
|
||||
{
|
||||
"package": "asn1crypto",
|
||||
"version": "0.24.0"
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'pip-list parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"location": string
|
||||
}
|
||||
]
|
||||
"""
|
||||
# no further processing
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
|
||||
# detect legacy output type
|
||||
if cleandata[0].find(' (') != -1:
|
||||
for row in cleandata:
|
||||
raw_output.append({'package': row.split(' (')[0],
|
||||
'version': row.split(' (')[1].rstrip(')')})
|
||||
|
||||
# otherwise normal table output
|
||||
else:
|
||||
# clear separator line
|
||||
for i, line in reversed(list(enumerate(cleandata))):
|
||||
if line.find('---') != -1:
|
||||
cleandata.pop(i)
|
||||
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
if cleandata:
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
131
jc/parsers/pip_show.py
Normal file
131
jc/parsers/pip_show.py
Normal file
@@ -0,0 +1,131 @@
|
||||
"""jc - JSON CLI output utility pip-show Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --pip-show as the first argument if the piped input is coming from pip show
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ pip show wrapt jc wheel | jc --pip-show -p
|
||||
[
|
||||
{
|
||||
"name": "wrapt",
|
||||
"version": "1.11.2",
|
||||
"summary": "Module for decorators, wrappers and monkey patching.",
|
||||
"home_page": "https://github.com/GrahamDumpleton/wrapt",
|
||||
"author": "Graham Dumpleton",
|
||||
"author_email": "Graham.Dumpleton@gmail.com",
|
||||
"license": "BSD",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": "astroid"
|
||||
},
|
||||
{
|
||||
"name": "wheel",
|
||||
"version": "0.33.4",
|
||||
"summary": "A built-package format for Python.",
|
||||
"home_page": "https://github.com/pypa/wheel",
|
||||
"author": "Daniel Holth",
|
||||
"author_email": "dholth@fastmail.fm",
|
||||
"license": "MIT",
|
||||
"location": "/usr/local/lib/python3.7/site-packages",
|
||||
"requires": null,
|
||||
"required_by": null
|
||||
}
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'pip-show parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
Parameters:
|
||||
|
||||
proc_data: (dictionary) raw structured data to process
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"name": string,
|
||||
"version": string,
|
||||
"summary": string,
|
||||
"home_page": string,
|
||||
"author": string,
|
||||
"author_email": string,
|
||||
"license": string,
|
||||
"location": string,
|
||||
"requires": string,
|
||||
"required_by": string
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
# no further processing
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
"""
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) output preprocessed JSON if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
package = {}
|
||||
|
||||
linedata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, linedata))
|
||||
|
||||
if cleandata:
|
||||
for row in cleandata:
|
||||
if row.startswith('---'):
|
||||
raw_output.append(package)
|
||||
package = {}
|
||||
continue
|
||||
|
||||
item_key = row.split(': ', maxsplit=1)[0].lower().replace('-', '_')
|
||||
item_value = row.split(': ', maxsplit=1)[1]
|
||||
|
||||
if item_value == '':
|
||||
item_value = None
|
||||
|
||||
package.update({item_key: item_value})
|
||||
|
||||
raw_output.append(package)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
@@ -1,12 +1,17 @@
|
||||
"""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
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ ps -ef | jc --ps -p
|
||||
@@ -168,6 +173,17 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'ps parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -180,7 +196,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -189,7 +205,8 @@ def process(proc_data):
|
||||
"ppid": integer,
|
||||
"c": integer,
|
||||
"stime": string,
|
||||
"tty": string, # ? = Null
|
||||
"tty": string, # ? or ?? = Null
|
||||
"tt": string, # ?? = Null
|
||||
"time": string,
|
||||
"cmd": string,
|
||||
"user": string,
|
||||
@@ -204,6 +221,14 @@ def process(proc_data):
|
||||
]
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# change key name '%cpu' to 'cpu_percent'
|
||||
if '%cpu' in entry:
|
||||
entry['cpu_percent'] = entry.pop('%cpu')
|
||||
|
||||
# change key name '%mem' to 'mem_percent'
|
||||
if '%mem' in entry:
|
||||
entry['mem_percent'] = entry.pop('%mem')
|
||||
|
||||
# change to int
|
||||
int_list = ['pid', 'ppid', 'c', 'vsz', 'rss']
|
||||
for key in int_list:
|
||||
@@ -225,9 +250,13 @@ def process(proc_data):
|
||||
entry[key] = None
|
||||
|
||||
if 'tty' in entry:
|
||||
if entry['tty'] == '?':
|
||||
if entry['tty'] == '?' or entry['tty'] == '??':
|
||||
entry['tty'] = None
|
||||
|
||||
if 'tt' in entry:
|
||||
if entry['tt'] == '??':
|
||||
entry['tt'] = None
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
@@ -243,28 +272,15 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
# code adapted from Conor Heine at:
|
||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
# clean up '%cpu' and '%mem' headers
|
||||
# even though % in a key is valid json, it can make things difficult
|
||||
headers = ['cpu_percent' if x == '%cpu' else x for x in headers]
|
||||
headers = ['mem_percent' if x == '%mem' else x for x in headers]
|
||||
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility route Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --route as the first argument if the piped input is coming from route
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ route -ee | jc --route -p
|
||||
@@ -92,6 +97,17 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'route parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
@@ -104,7 +120,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -147,22 +163,15 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
# code adapted from Conor Heine at:
|
||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
cleandata[0] = cleandata[0].lower()
|
||||
|
||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
@@ -1,11 +1,17 @@
|
||||
"""jc - JSON CLI output utility ss Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --ss as the first argument if the piped input is coming from ss
|
||||
|
||||
Limitations:
|
||||
|
||||
Extended information options like -e and -p are not supported and may cause parsing irregularities
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ sudo ss -a | jc --ss -p
|
||||
@@ -244,6 +250,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'ss parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -254,7 +270,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -315,14 +331,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6']
|
||||
raw_output = []
|
||||
|
@@ -1,7 +1,12 @@
|
||||
"""jc - JSON CLI output utility stats Parser
|
||||
"""jc - JSON CLI output utility stat Parser
|
||||
|
||||
Usage:
|
||||
specify --stats as the first argument if the piped input is coming from stats
|
||||
|
||||
specify --stat as the first argument if the piped input is coming from stat
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -98,6 +103,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'stat parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -108,7 +123,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -167,14 +182,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility systemctl Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl as the first argument if the piped input is coming from systemctl
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl -a | jc --systemctl -p
|
||||
@@ -34,6 +39,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -44,7 +59,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -72,14 +87,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility systemctl-lj Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl-lj as the first argument if the piped input is coming from systemctl list-jobs
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-jobs| jc --systemctl-lj -p
|
||||
@@ -53,6 +58,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl list-jobs parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -63,7 +78,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -98,14 +113,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility systemctl-ls Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl-ls as the first argument if the piped input is coming from systemctl list-sockets
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-sockets | jc --systemctl-ls -p
|
||||
@@ -28,6 +33,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl list-sockets parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -38,7 +53,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -64,14 +79,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility systemctl-luf Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --systemctl-luf as the first argument if the piped input is coming from systemctl list-unit-files
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
|
||||
Examples:
|
||||
|
||||
$ systemctl list-unit-files | jc --systemctl-luf -p
|
||||
@@ -25,6 +30,16 @@ Examples:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'systemctl list-unit-files parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -35,7 +50,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -60,14 +75,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, systemctlbsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
linedata = data.splitlines()
|
||||
# Clear any blank lines
|
||||
|
@@ -1,11 +1,17 @@
|
||||
"""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'
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin'
|
||||
|
||||
Example:
|
||||
|
||||
$ uname -a | jc --uname -p
|
||||
@@ -23,6 +29,16 @@ Example:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.1'
|
||||
description = 'uname -a parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -33,7 +49,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"kernel_name": string,
|
||||
@@ -62,32 +78,39 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
parsed_line = data.split(maxsplit=3)
|
||||
split_line = data.split()
|
||||
|
||||
if len(parsed_line) > 1:
|
||||
if len(split_line) > 1:
|
||||
# check for OSX output
|
||||
if data.startswith('Darwin'):
|
||||
parsed_line = data.split()
|
||||
raw_output['machine'] = parsed_line.pop(-1)
|
||||
raw_output['kernel_name'] = parsed_line.pop(0)
|
||||
raw_output['node_name'] = parsed_line.pop(0)
|
||||
raw_output['kernel_release'] = parsed_line.pop(0)
|
||||
raw_output['kernel_version'] = ' '.join(parsed_line)
|
||||
|
||||
raw_output['kernel_name'] = parsed_line.pop(0)
|
||||
raw_output['node_name'] = parsed_line.pop(0)
|
||||
raw_output['kernel_release'] = parsed_line.pop(0)
|
||||
# otherwise use linux parser
|
||||
else:
|
||||
parsed_line = data.split(maxsplit=3)
|
||||
raw_output['kernel_name'] = parsed_line.pop(0)
|
||||
raw_output['node_name'] = parsed_line.pop(0)
|
||||
raw_output['kernel_release'] = parsed_line.pop(0)
|
||||
|
||||
parsed_line = parsed_line[-1].rsplit(maxsplit=4)
|
||||
parsed_line = parsed_line[-1].rsplit(maxsplit=4)
|
||||
|
||||
raw_output['operating_system'] = parsed_line.pop(-1)
|
||||
raw_output['hardware_platform'] = parsed_line.pop(-1)
|
||||
raw_output['processor'] = parsed_line.pop(-1)
|
||||
raw_output['machine'] = parsed_line.pop(-1)
|
||||
raw_output['operating_system'] = parsed_line.pop(-1)
|
||||
raw_output['hardware_platform'] = parsed_line.pop(-1)
|
||||
raw_output['processor'] = parsed_line.pop(-1)
|
||||
raw_output['machine'] = parsed_line.pop(-1)
|
||||
|
||||
raw_output['kernel_version'] = parsed_line.pop(0)
|
||||
raw_output['kernel_version'] = parsed_line.pop(0)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
|
110
jc/parsers/universal.py
Normal file
110
jc/parsers/universal.py
Normal file
@@ -0,0 +1,110 @@
|
||||
"""jc - JSON CLI output utility universal Parsers"""
|
||||
|
||||
|
||||
import string
|
||||
|
||||
|
||||
def simple_table_parse(data):
|
||||
"""
|
||||
Parse simple tables. The last column may contain data with spaces
|
||||
|
||||
code adapted from Conor Heine at:
|
||||
https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (list) Text data to parse that has been split into lines via .splitlines().
|
||||
Item 0 must be the header row. Any spaces in header names should be
|
||||
changed to underscore '_'. You should also ensure headers are
|
||||
lowercase by using .lower().
|
||||
|
||||
Also, ensure there are no blank lines (list items) in the data.
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw structured data
|
||||
"""
|
||||
headers = [h for h in ' '.join(data[0].strip().split()).split() if h]
|
||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), data[1:])
|
||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
||||
|
||||
return raw_output
|
||||
|
||||
|
||||
def sparse_table_parse(data, delim='\u2063'):
|
||||
"""
|
||||
Parse tables with missing column data or with spaces in column data.
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (list) Text data to parse that has been split into lines via .splitlines().
|
||||
Item 0 must be the header row. Any spaces in header names should be
|
||||
changed to underscore '_'. You should also ensure headers are
|
||||
lowercase by using .lower(). Do not change the position of header
|
||||
names as the positions are used to find the data.
|
||||
|
||||
Also, ensure there are no blank lines (list items) in the data.
|
||||
|
||||
delim: (string) Delimiter to use. By default 'u\2063' (invisible separator) is used
|
||||
since this is unlikely to ever be seen in terminal output. You can
|
||||
change this for troubleshooting purposes or if there is a delimiter
|
||||
conflict with your data.
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw structured data
|
||||
"""
|
||||
output = []
|
||||
header_text = data.pop(0)
|
||||
header_text = header_text + ' '
|
||||
header_list = header_text.split()
|
||||
|
||||
# find each column index and end position
|
||||
header_search = [header_list[0]]
|
||||
for h in header_list[1:]:
|
||||
header_search.append(' ' + h + ' ')
|
||||
|
||||
header_spec_list = []
|
||||
for i, column in enumerate(header_list[0:len(header_list) - 1]):
|
||||
header_spec = {
|
||||
'name': column,
|
||||
'end': header_text.find(header_search[i + 1])
|
||||
}
|
||||
|
||||
header_spec_list.append(header_spec)
|
||||
|
||||
# parse lines
|
||||
if data:
|
||||
for entry in data:
|
||||
output_line = {}
|
||||
|
||||
# insert new separator since data can contain spaces
|
||||
for col in reversed(header_list):
|
||||
# find the right header_spec
|
||||
for h_spec in header_spec_list:
|
||||
if h_spec['name'] == col:
|
||||
h_end = h_spec['end']
|
||||
# check if the location contains whitespace. if not
|
||||
# then move to the left until a space is found
|
||||
while h_end > 0 and entry[h_end] not in string.whitespace:
|
||||
h_end -= 1
|
||||
|
||||
# insert custom delimiter
|
||||
entry = entry[:h_end] + delim + entry[h_end + 1:]
|
||||
|
||||
# create the entry list from the new custom delimiter
|
||||
entry_list = entry.split(delim, maxsplit=len(header_list) - 1)
|
||||
|
||||
# clean up leading and trailing spaces in entry
|
||||
clean_entry_list = []
|
||||
for col in entry_list:
|
||||
clean_entry = col.strip()
|
||||
if clean_entry == '':
|
||||
clean_entry = None
|
||||
|
||||
clean_entry_list.append(clean_entry)
|
||||
|
||||
output_line = dict(zip(header_list, clean_entry_list))
|
||||
output.append(output_line)
|
||||
|
||||
return output
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility uptime Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --uptime as the first argument if the piped input is coming from uptime
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Example:
|
||||
|
||||
$ uptime | jc --uptime -p
|
||||
@@ -28,6 +33,16 @@ Example:
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'uptime parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -38,7 +53,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"time": string,
|
||||
@@ -82,14 +97,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
Dictionary. Raw or processed structured data
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@@ -1,8 +1,13 @@
|
||||
"""jc - JSON CLI output utility w Parser
|
||||
|
||||
Usage:
|
||||
|
||||
specify --w as the first argument if the piped input is coming from w
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
|
||||
Examples:
|
||||
|
||||
$ w | jc --w -p
|
||||
@@ -77,6 +82,16 @@ import string
|
||||
import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
description = 'w parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
@@ -87,7 +102,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary structured data with the following schema:
|
||||
List of dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
@@ -124,14 +139,10 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Returns:
|
||||
|
||||
dictionary raw or processed structured data
|
||||
List of dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
jc.utils.compatibility(__name__, info.compatible)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
header_text = cleandata[0].lower()
|
||||
|
@@ -34,7 +34,7 @@ def error_message(message):
|
||||
|
||||
no return, just prints output to STDERR
|
||||
"""
|
||||
|
||||
|
||||
error_string = f'''
|
||||
jc: Error - {message}
|
||||
'''
|
||||
@@ -43,13 +43,13 @@ def error_message(message):
|
||||
|
||||
def compatibility(mod_name, compatible):
|
||||
"""Checks for the parser's compatibility with the running OS platform.
|
||||
|
||||
|
||||
Parameters:
|
||||
|
||||
mod_name: (string) __name__ of the calling module
|
||||
|
||||
|
||||
compatible: (list) sys.platform name(s) compatible with the parser
|
||||
compatible options:
|
||||
compatible options:
|
||||
linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Returns:
|
||||
|
6
setup.py
6
setup.py
@@ -5,17 +5,17 @@ with open('README.md', 'r') as f:
|
||||
|
||||
setuptools.setup(
|
||||
name='jc',
|
||||
version='1.5.1',
|
||||
version='1.6.1',
|
||||
author='Kelly Brazil',
|
||||
author_email='kellyjonbrazil@gmail.com',
|
||||
description='This tool serializes the output of popular command line tools to structured JSON output.',
|
||||
install_requires=[
|
||||
'ifconfig-parser'
|
||||
'ifconfig-parser>=0.0.5'
|
||||
],
|
||||
license='MIT',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
python_requires='~=3.6',
|
||||
python_requires='>=3.6',
|
||||
url='https://github.com/kellyjonbrazil/jc',
|
||||
packages=setuptools.find_packages(),
|
||||
entry_points={
|
||||
|
1
tests/fixtures/centos-7.7/crontab.json
vendored
Normal file
1
tests/fixtures/centos-7.7/crontab.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"variables": [{"name": "MAILTO", "value": "root"}, {"name": "PATH", "value": "/sbin:/bin:/usr/sbin:/usr/bin"}, {"name": "SHELL", "value": "/bin/bash"}], "schedule": [{"minute": ["*"], "hour": ["*"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/devdaily.com/bin/check-apache.sh"}, {"minute": ["5"], "hour": ["10-11", "22"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/devdaily.com/bin/mk-new-links.php"}, {"minute": ["30"], "hour": ["4/2"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/devdaily.com/bin/create-all-backups.sh"}, {"minute": ["5"], "hour": ["0", "4", "10", "16"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/devdaily.com/bin/create-cat-list.sh"}, {"minute": ["5"], "hour": ["0"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/devdaily.com/bin/resetContactForm.sh"}, {"minute": ["0", "20", "40"], "hour": ["*"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/bin/ads/freshMint.sh"}, {"minute": ["5", "25", "45"], "hour": ["*"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/bin/ads/greenTaffy.sh"}, {"minute": ["10", "30", "50"], "hour": ["*"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/bin/ads/raspberry.sh"}, {"minute": ["15", "35", "55"], "hour": ["*"], "day_of_month": ["*"], "month": ["*"], "day_of_week": ["*"], "command": "/var/www/bin/ads/robinsEgg.sh"}, {"occurrence": "yearly", "command": "/home/maverick/bin/annual-maintenance"}, {"occurrence": "reboot", "command": "/home/cleanup"}, {"occurrence": "monthly", "command": "/home/maverick/bin/tape-backup"}]}
|
48
tests/fixtures/centos-7.7/crontab.out
vendored
Normal file
48
tests/fixtures/centos-7.7/crontab.out
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
SHELL=/bin/bash
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
MAILTO=root
|
||||
|
||||
#--------------------------------------------------
|
||||
# example unix/linux crontab file format:
|
||||
#--------------------------------------------------
|
||||
# min,hour,dayOfMonth,month,dayOfWeek command
|
||||
#
|
||||
# field allowed values
|
||||
# ----- --------------
|
||||
# minute 0-59
|
||||
# hour 0-23
|
||||
# day of month 1-31
|
||||
# month 1-12 (or names, see below)
|
||||
# day of week 0-7 (0 or 7 is Sun, or use names)
|
||||
#
|
||||
#--------------------------------------------------
|
||||
|
||||
# run the drupal cron process every hour of every day
|
||||
0 * * * * /usr/bin/wget -O - -q -t 1 http://localhost/cron.php
|
||||
|
||||
# run this apache kludge every minute of every day
|
||||
* * * * * /var/www/devdaily.com/bin/check-apache.sh
|
||||
|
||||
# generate links to new blog posts twice a day
|
||||
5 10-11,22 * * * /var/www/devdaily.com/bin/mk-new-links.php
|
||||
|
||||
# run the backup scripts at 4:30am
|
||||
30 4/2 * * * /var/www/devdaily.com/bin/create-all-backups.sh
|
||||
|
||||
# re-generate the blog "categories" list (four times a day)
|
||||
5 0,4,10,16 * * * /var/www/devdaily.com/bin/create-cat-list.sh
|
||||
|
||||
# reset the contact form just after midnight
|
||||
5 0 * * * /var/www/devdaily.com/bin/resetContactForm.sh
|
||||
|
||||
# example of shortcut versions
|
||||
@monthly /home/maverick/bin/tape-backup
|
||||
@reboot /home/cleanup
|
||||
@yearly /home/maverick/bin/annual-maintenance
|
||||
|
||||
# rotate the ad banners every five minutes
|
||||
|
||||
0,20,40 * * * * /var/www/bin/ads/freshMint.sh
|
||||
5,25,45 * * * * /var/www/bin/ads/greenTaffy.sh
|
||||
10,30,50 * * * * /var/www/bin/ads/raspberry.sh
|
||||
15,35,55 * * * * /var/www/bin/ads/robinsEgg.sh
|
2
tests/fixtures/centos-7.7/df.json
vendored
2
tests/fixtures/centos-7.7/df.json
vendored
@@ -1 +1 @@
|
||||
[{"filesystem": "devtmpfs", "1k-blocks": 1918816, "used": 0, "available": 1918816, "use_percent": 0, "mounted_on": "/dev"}, {"filesystem": "tmpfs", "1k-blocks": 1930664, "used": 0, "available": 1930664, "use_percent": 0, "mounted_on": "/dev/shm"}, {"filesystem": "tmpfs", "1k-blocks": 1930664, "used": 11832, "available": 1918832, "use_percent": 1, "mounted_on": "/run"}, {"filesystem": "tmpfs", "1k-blocks": 1930664, "used": 0, "available": 1930664, "use_percent": 0, "mounted_on": "/sys/fs/cgroup"}, {"filesystem": "/dev/mapper/centos-root", "1k-blocks": 17811456, "used": 1805580, "available": 16005876, "use_percent": 11, "mounted_on": "/"}, {"filesystem": "/dev/sda1", "1k-blocks": 1038336, "used": 237600, "available": 800736, "use_percent": 23, "mounted_on": "/boot"}, {"filesystem": "tmpfs", "1k-blocks": 386136, "used": 0, "available": 386136, "use_percent": 0, "mounted_on": "/run/user/1000"}]
|
||||
[{"filesystem": "devtmpfs", "1k_blocks": 1918816, "used": 0, "available": 1918816, "use_percent": 0, "mounted_on": "/dev"}, {"filesystem": "tmpfs", "1k_blocks": 1930664, "used": 0, "available": 1930664, "use_percent": 0, "mounted_on": "/dev/shm"}, {"filesystem": "tmpfs", "1k_blocks": 1930664, "used": 11832, "available": 1918832, "use_percent": 1, "mounted_on": "/run"}, {"filesystem": "tmpfs", "1k_blocks": 1930664, "used": 0, "available": 1930664, "use_percent": 0, "mounted_on": "/sys/fs/cgroup"}, {"filesystem": "/dev/mapper/centos-root", "1k_blocks": 17811456, "used": 1805580, "available": 16005876, "use_percent": 11, "mounted_on": "/"}, {"filesystem": "/dev/sda1", "1k_blocks": 1038336, "used": 237600, "available": 800736, "use_percent": 23, "mounted_on": "/boot"}, {"filesystem": "tmpfs", "1k_blocks": 386136, "used": 0, "available": 386136, "use_percent": 0, "mounted_on": "/run/user/1000"}]
|
||||
|
1
tests/fixtures/centos-7.7/du.json
vendored
Normal file
1
tests/fixtures/centos-7.7/du.json
vendored
Normal file
File diff suppressed because one or more lines are too long
5199
tests/fixtures/centos-7.7/du.out
vendored
Normal file
5199
tests/fixtures/centos-7.7/du.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
tests/fixtures/centos-7.7/ifconfig.json
vendored
2
tests/fixtures/centos-7.7/ifconfig.json
vendored
@@ -1 +1 @@
|
||||
[{"name": "docker0", "flags": 4099, "state": "UP,BROADCAST,MULTICAST", "mtu": 1500, "ipv4_addr": "172.17.0.1", "ipv4_mask": "255.255.0.0", "ipv4_bcast": "0.0.0.0", "mac_addr": "02:42:b1:9a:ea:02", "type": "Ethernet", "rx_packets": 0, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 0, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null}, {"name": "ens33", "flags": 4163, "state": "UP,BROADCAST,RUNNING,MULTICAST", "mtu": 1500, "ipv4_addr": "192.168.71.137", "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": 8061, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 4502, "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": 73, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 73, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
||||
[{"name": "docker0", "flags": 4099, "state": ["UP", "BROADCAST", "MULTICAST"], "mtu": 1500, "ipv4_addr": "172.17.0.1", "ipv4_mask": "255.255.0.0", "ipv4_bcast": "0.0.0.0", "mac_addr": "02:42:b1:9a:ea:02", "type": "Ethernet", "rx_packets": 0, "rx_bytes": 0, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 0, "tx_bytes": 0, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null}, {"name": "ens33", "flags": 4163, "state": ["UP", "BROADCAST", "RUNNING", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.71.137", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.71.255", "ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0", "ipv6_mask": 64, "ipv6_scope": "0x20", "mac_addr": "00:0c:29:3b:58:0e", "type": "Ethernet", "rx_packets": 8061, "rx_bytes": 1514413, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 4502, "tx_bytes": 866622, "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": "0x10", "mac_addr": null, "type": "Local Loopback", "rx_packets": 73, "rx_bytes": 6009, "rx_errors": 0, "rx_dropped": 0, "rx_overruns": 0, "rx_frame": 0, "tx_packets": 73, "tx_bytes": 6009, "tx_errors": 0, "tx_dropped": 0, "tx_overruns": 0, "tx_carrier": 0, "tx_collisions": 0, "metric": null}]
|
||||
|
1
tests/fixtures/centos-7.7/pip-list.json
vendored
Normal file
1
tests/fixtures/centos-7.7/pip-list.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"package": "bleach", "version": "3.1.0"}, {"package": "certifi", "version": "2019.9.11"}, {"package": "chardet", "version": "3.0.4"}, {"package": "docutils", "version": "0.15.2"}, {"package": "idna", "version": "2.8"}, {"package": "ifconfig-parser", "version": "0.0.5"}, {"package": "jc", "version": "1.5.1"}, {"package": "pip", "version": "19.3.1"}, {"package": "pkginfo", "version": "1.5.0.1"}, {"package": "Pygments", "version": "2.4.2"}, {"package": "readme-renderer", "version": "24.0"}, {"package": "requests", "version": "2.22.0"}, {"package": "requests-toolbelt", "version": "0.9.1"}, {"package": "setuptools", "version": "39.2.0"}, {"package": "six", "version": "1.12.0"}, {"package": "tqdm", "version": "4.36.1"}, {"package": "twine", "version": "2.0.0"}, {"package": "urllib3", "version": "1.25.6"}, {"package": "webencodings", "version": "0.5.1"}, {"package": "wheel", "version": "0.33.6"}]
|
22
tests/fixtures/centos-7.7/pip-list.out
vendored
Normal file
22
tests/fixtures/centos-7.7/pip-list.out
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Package Version
|
||||
----------------- ---------
|
||||
bleach 3.1.0
|
||||
certifi 2019.9.11
|
||||
chardet 3.0.4
|
||||
docutils 0.15.2
|
||||
idna 2.8
|
||||
ifconfig-parser 0.0.5
|
||||
jc 1.5.1
|
||||
pip 19.3.1
|
||||
pkginfo 1.5.0.1
|
||||
Pygments 2.4.2
|
||||
readme-renderer 24.0
|
||||
requests 2.22.0
|
||||
requests-toolbelt 0.9.1
|
||||
setuptools 39.2.0
|
||||
six 1.12.0
|
||||
tqdm 4.36.1
|
||||
twine 2.0.0
|
||||
urllib3 1.25.6
|
||||
webencodings 0.5.1
|
||||
wheel 0.33.6
|
1
tests/fixtures/centos-7.7/pip-show.json
vendored
Normal file
1
tests/fixtures/centos-7.7/pip-show.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"name": "setuptools", "version": "39.2.0", "summary": "Easily download, build, install, upgrade, and uninstall Python packages", "home_page": "https://github.com/pypa/setuptools", "author": "Python Packaging Authority", "author_email": "distutils-sig@python.org", "license": "UNKNOWN", "location": "/usr/lib/python3.6/site-packages", "requires": null, "required_by": "twine"}, {"name": "pkginfo", "version": "1.5.0.1", "summary": "Query metadatdata from sdists / bdists / installed packages.", "home_page": "https://code.launchpad.net/~tseaver/pkginfo/trunk", "author": "Tres Seaver, Agendaless Consulting", "author_email": "tseaver@agendaless.com", "license": "MIT", "location": "/home/kbrazil/.local/lib/python3.6/site-packages", "requires": null, "required_by": "twine"}, {"name": "six", "version": "1.12.0", "summary": "Python 2 and 3 compatibility utilities", "home_page": "https://github.com/benjaminp/six", "author": "Benjamin Peterson", "author_email": "benjamin@python.org", "license": "MIT", "location": "/home/kbrazil/.local/lib/python3.6/site-packages", "requires": null, "required_by": "readme-renderer, bleach"}]
|
32
tests/fixtures/centos-7.7/pip-show.out
vendored
Normal file
32
tests/fixtures/centos-7.7/pip-show.out
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
Name: setuptools
|
||||
Version: 39.2.0
|
||||
Summary: Easily download, build, install, upgrade, and uninstall Python packages
|
||||
Home-page: https://github.com/pypa/setuptools
|
||||
Author: Python Packaging Authority
|
||||
Author-email: distutils-sig@python.org
|
||||
License: UNKNOWN
|
||||
Location: /usr/lib/python3.6/site-packages
|
||||
Requires:
|
||||
Required-by: twine
|
||||
---
|
||||
Name: pkginfo
|
||||
Version: 1.5.0.1
|
||||
Summary: Query metadatdata from sdists / bdists / installed packages.
|
||||
Home-page: https://code.launchpad.net/~tseaver/pkginfo/trunk
|
||||
Author: Tres Seaver, Agendaless Consulting
|
||||
Author-email: tseaver@agendaless.com
|
||||
License: MIT
|
||||
Location: /home/kbrazil/.local/lib/python3.6/site-packages
|
||||
Requires:
|
||||
Required-by: twine
|
||||
---
|
||||
Name: six
|
||||
Version: 1.12.0
|
||||
Summary: Python 2 and 3 compatibility utilities
|
||||
Home-page: https://github.com/benjaminp/six
|
||||
Author: Benjamin Peterson
|
||||
Author-email: benjamin@python.org
|
||||
License: MIT
|
||||
Location: /home/kbrazil/.local/lib/python3.6/site-packages
|
||||
Requires:
|
||||
Required-by: readme-renderer, bleach
|
4
tests/fixtures/create_fixtures.sh
vendored
4
tests/fixtures/create_fixtures.sh
vendored
@@ -64,3 +64,7 @@ systemctl -a > systemctl.out
|
||||
systemctl -a list-unit-files > systemctl-luf.out
|
||||
systemctl -a list-sockets > systemctl-ls.out
|
||||
systemctl -a list-jobs > systemctl-jobs.out
|
||||
|
||||
du /usr > du.out
|
||||
pip3 list > pip-list.out
|
||||
pip3 show wheel pip jc > pip-show.out
|
||||
|
1
tests/fixtures/osx-10.11.6/arp-a.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/arp-a.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"name": "dev.attlocal.net", "address": "192.168.1.63", "hwtype": "ethernet", "hwaddress": "e0:33:8e:67:38:d6", "iface": "en0"}, {"name": "air.attlocal.net", "address": "192.168.1.66", "hwtype": "ethernet", "hwaddress": "60:c5:47:b:cf:a", "iface": "en0"}, {"name": "ipad.attlocal.net", "address": "192.168.1.76", "hwtype": "ethernet", "hwaddress": "4c:56:9d:6f:b7:4c", "iface": "en0"}, {"name": "storage.attlocal.net", "address": "192.168.1.81", "hwtype": "ethernet", "hwaddress": "0:90:a9:fd:e4:35", "iface": "en0"}, {"name": "family-room.attlocal.net", "address": "192.168.1.89", "hwtype": "ethernet", "hwaddress": "c8:d0:83:cd:f3:2d", "iface": "en0"}, {"name": "bedroom.attlocal.net", "address": "192.168.1.80", "hwtype": "ethernet", "hwaddress": "d0:3:4b:3b:29:d5", "iface": "en0"}, {"name": "upstairs.attlocal.net", "address": "192.168.1.187", "hwtype": "ethernet", "hwaddress": "50:32:37:e7:f5:9b", "iface": "en0"}, {"name": "rb.attlocal.net", "address": "192.168.1.218", "hwtype": "ethernet", "hwaddress": "3c:37:86:15:bd:f7", "iface": "en0"}, {"name": "mac.attlocal.net", "address": "192.168.1.220", "hwtype": "ethernet", "hwaddress": "a4:83:f7:2d:62:8f", "iface": "en0"}, {"name": "rbs.attlocal.net", "address": "192.168.1.252", "hwtype": "ethernet", "hwaddress": "3c:37:86:15:de:b3", "iface": "en0"}, {"name": "dev1.attlocal.net", "address": "192.168.1.253", "hwtype": "ethernet", "hwaddress": "fc:ae:34:a1:3b:80", "iface": "en0"}, {"name": null, "address": "224.0.0.251", "hwtype": "ethernet", "hwaddress": "1:0:5e:0:0:fb", "iface": "en0"}, {"name": null, "address": "239.255.255.250", "hwtype": "ethernet", "hwaddress": "1:0:5e:7f:ff:fa", "iface": "en0"}]
|
13
tests/fixtures/osx-10.11.6/arp-a.out
vendored
Executable file
13
tests/fixtures/osx-10.11.6/arp-a.out
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
dev.attlocal.net (192.168.1.63) at e0:33:8e:67:38:d6 on en0 ifscope [ethernet]
|
||||
air.attlocal.net (192.168.1.66) at 60:c5:47:b:cf:a on en0 ifscope [ethernet]
|
||||
ipad.attlocal.net (192.168.1.76) at 4c:56:9d:6f:b7:4c on en0 ifscope [ethernet]
|
||||
storage.attlocal.net (192.168.1.81) at 0:90:a9:fd:e4:35 on en0 ifscope [ethernet]
|
||||
family-room.attlocal.net (192.168.1.89) at c8:d0:83:cd:f3:2d on en0 ifscope [ethernet]
|
||||
bedroom.attlocal.net (192.168.1.80) at d0:3:4b:3b:29:d5 on en0 ifscope [ethernet]
|
||||
upstairs.attlocal.net (192.168.1.187) at 50:32:37:e7:f5:9b on en0 ifscope [ethernet]
|
||||
rb.attlocal.net (192.168.1.218) at 3c:37:86:15:bd:f7 on en0 ifscope [ethernet]
|
||||
mac.attlocal.net (192.168.1.220) at a4:83:f7:2d:62:8f on en0 ifscope [ethernet]
|
||||
rbs.attlocal.net (192.168.1.252) at 3c:37:86:15:de:b3 on en0 ifscope [ethernet]
|
||||
dev1.attlocal.net (192.168.1.253) at fc:ae:34:a1:3b:80 on en0 ifscope [ethernet]
|
||||
? (224.0.0.251) at 1:0:5e:0:0:fb on en0 ifscope permanent [ethernet]
|
||||
? (239.255.255.250) at 1:0:5e:7f:ff:fa on en0 ifscope permanent [ethernet]
|
1
tests/fixtures/osx-10.11.6/df-h.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/df-h.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"filesystem": "/dev/disk1s1", "size": "466Gi", "used": null, "iused": 674413, "ifree": 9223372036854101394, "mounted_on": "/", "available": null, "capacity_percent": 30, "iused_percent": 0}, {"filesystem": "devfs", "size": "188Ki", "used": null, "iused": 650, "ifree": 0, "mounted_on": "/dev", "available": null, "capacity_percent": 100, "iused_percent": 100}, {"filesystem": "/dev/disk1s4", "size": "466Gi", "used": null, "iused": 2, "ifree": 9223372036854775805, "mounted_on": "/private/var/vm", "available": null, "capacity_percent": 1, "iused_percent": 0}, {"filesystem": "map -hosts", "size": "0Bi", "used": null, "iused": 0, "ifree": 0, "mounted_on": "/net", "available": null, "capacity_percent": 100, "iused_percent": 100}, {"filesystem": "map auto_home", "size": "0Bi", "used": null, "iused": 0, "ifree": 0, "mounted_on": "/home", "available": null, "capacity_percent": 100, "iused_percent": 100}, {"filesystem": "//brazil@MyCloudEX2Ultra._afpovertcp._tcp.local/brazil", "size": "3.5Ti", "used": null, "iused": 301134832, "ifree": 649465741, "mounted_on": "/Volumes/brazil", "available": null, "capacity_percent": 32, "iused_percent": 32}]
|
7
tests/fixtures/osx-10.11.6/df-h.out
vendored
Executable file
7
tests/fixtures/osx-10.11.6/df-h.out
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
|
||||
/dev/disk1s1 466Gi 137Gi 326Gi 30% 674413 9223372036854101394 0% /
|
||||
devfs 188Ki 188Ki 0Bi 100% 650 0 100% /dev
|
||||
/dev/disk1s4 466Gi 2.0Gi 326Gi 1% 2 9223372036854775805 0% /private/var/vm
|
||||
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
|
||||
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
|
||||
//brazil@MyCloudEX2Ultra._afpovertcp._tcp.local/brazil 3.5Ti 1.1Ti 2.4Ti 32% 301134832 649465741 32% /Volumes/brazil
|
1
tests/fixtures/osx-10.11.6/df.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/df.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"filesystem": "/dev/disk1s1", "512_blocks": 976490576, "used": 286747768, "available": 684150392, "iused": 674410, "ifree": 9223372036854101397, "mounted_on": "/", "capacity_percent": 30, "iused_percent": 0}, {"filesystem": "devfs", "512_blocks": 375, "used": 375, "available": 0, "iused": 650, "ifree": 0, "mounted_on": "/dev", "capacity_percent": 100, "iused_percent": 100}, {"filesystem": "/dev/disk1s4", "512_blocks": 976490576, "used": 4194344, "available": 684150392, "iused": 2, "ifree": 9223372036854775805, "mounted_on": "/private/var/vm", "capacity_percent": 1, "iused_percent": 0}, {"filesystem": "map -hosts", "512_blocks": 0, "used": 0, "available": 0, "iused": 0, "ifree": 0, "mounted_on": "/net", "capacity_percent": 100, "iused_percent": 100}, {"filesystem": "map auto_home", "512_blocks": 0, "used": 0, "available": 0, "iused": 0, "ifree": 0, "mounted_on": "/home", "capacity_percent": 100, "iused_percent": 100}, {"filesystem": "//brazil@MyCloudEX2Ultra._afpovertcp._tcp.local/brazil", "512_blocks": 7604804600, "used": 2409078672, "available": 5195725928, "iused": 301134832, "ifree": 649465741, "mounted_on": "/Volumes/brazil", "capacity_percent": 32, "iused_percent": 32}]
|
7
tests/fixtures/osx-10.11.6/df.out
vendored
Executable file
7
tests/fixtures/osx-10.11.6/df.out
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
|
||||
/dev/disk1s1 976490576 286747768 684150392 30% 674410 9223372036854101397 0% /
|
||||
devfs 375 375 0 100% 650 0 100% /dev
|
||||
/dev/disk1s4 976490576 4194344 684150392 1% 2 9223372036854775805 0% /private/var/vm
|
||||
map -hosts 0 0 0 100% 0 0 100% /net
|
||||
map auto_home 0 0 0 100% 0 0 100% /home
|
||||
//brazil@MyCloudEX2Ultra._afpovertcp._tcp.local/brazil 7604804600 2409078672 5195725928 32% 301134832 649465741 32% /Volumes/brazil
|
1
tests/fixtures/osx-10.11.6/dig-aaaa.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/dig-aaaa.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"id": 41369, "opcode": "QUERY", "status": "NOERROR", "flags": ["qr", "rd", "ra"], "query_num": 1, "answer_num": 1, "authority_num": 0, "additional_num": 1, "question": {"name": "www.google.com.", "class": "IN", "type": "AAAA"}, "answer": [{"name": "www.google.com.", "class": "IN", "type": "AAAA", "ttl": 197, "data": "2607:f8b0:4000:817::2004"}], "query_time": 30, "server": "2600", "when": "Wed Dec 11 16:57:37 PST 2019", "rcvd": 71}]
|
20
tests/fixtures/osx-10.11.6/dig-aaaa.out
vendored
Executable file
20
tests/fixtures/osx-10.11.6/dig-aaaa.out
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
|
||||
; <<>> DiG 9.10.6 <<>> www.google.com AAAA
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41369
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;www.google.com. IN AAAA
|
||||
|
||||
;; ANSWER SECTION:
|
||||
www.google.com. 197 IN AAAA 2607:f8b0:4000:817::2004
|
||||
|
||||
;; Query time: 30 msec
|
||||
;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
|
||||
;; WHEN: Wed Dec 11 16:57:37 PST 2019
|
||||
;; MSG SIZE rcvd: 71
|
||||
|
1
tests/fixtures/osx-10.11.6/dig-x.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/dig-x.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"id": 15549, "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": 1800, "data": "one.one.one.one."}], "query_time": 34, "server": "2600", "when": "Wed Dec 11 16:57:37 PST 2019", "rcvd": 78}]
|
20
tests/fixtures/osx-10.11.6/dig-x.out
vendored
Executable file
20
tests/fixtures/osx-10.11.6/dig-x.out
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
|
||||
; <<>> DiG 9.10.6 <<>> -x 1.1.1.1
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15549
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;1.1.1.1.in-addr.arpa. IN PTR
|
||||
|
||||
;; ANSWER SECTION:
|
||||
1.1.1.1.in-addr.arpa. 1800 IN PTR one.one.one.one.
|
||||
|
||||
;; Query time: 34 msec
|
||||
;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
|
||||
;; WHEN: Wed Dec 11 16:57:37 PST 2019
|
||||
;; MSG SIZE rcvd: 78
|
||||
|
1
tests/fixtures/osx-10.11.6/dig.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/dig.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"id": 57483, "opcode": "QUERY", "status": "NOERROR", "flags": ["qr", "rd", "ra"], "query_num": 1, "answer_num": 5, "authority_num": 0, "additional_num": 1, "question": {"name": "www.cnn.com.", "class": "IN", "type": "A"}, "answer": [{"name": "www.cnn.com.", "class": "IN", "type": "CNAME", "ttl": 199, "data": "turner-tls.map.fastly.net."}, {"name": "turner-tls.map.fastly.net.", "class": "IN", "type": "A", "ttl": 13, "data": "151.101.193.67"}, {"name": "turner-tls.map.fastly.net.", "class": "IN", "type": "A", "ttl": 13, "data": "151.101.65.67"}, {"name": "turner-tls.map.fastly.net.", "class": "IN", "type": "A", "ttl": 13, "data": "151.101.1.67"}, {"name": "turner-tls.map.fastly.net.", "class": "IN", "type": "A", "ttl": 13, "data": "151.101.129.67"}], "query_time": 30, "server": "2600", "when": "Wed Dec 11 16:57:37 PST 2019", "rcvd": 143}, {"id": 53268, "opcode": "QUERY", "status": "NOERROR", "flags": ["qr", "rd", "ra"], "query_num": 1, "answer_num": 1, "authority_num": 0, "additional_num": 1, "question": {"name": "www.google.com.", "class": "IN", "type": "A"}, "answer": [{"name": "www.google.com.", "class": "IN", "type": "A", "ttl": 194, "data": "172.217.9.164"}], "query_time": 30, "server": "2600", "when": "Wed Dec 11 16:57:37 PST 2019", "rcvd": 59}]
|
41
tests/fixtures/osx-10.11.6/dig.out
vendored
Executable file
41
tests/fixtures/osx-10.11.6/dig.out
vendored
Executable file
@@ -0,0 +1,41 @@
|
||||
|
||||
; <<>> DiG 9.10.6 <<>> www.cnn.com www.google.com
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57483
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;www.cnn.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
www.cnn.com. 199 IN CNAME turner-tls.map.fastly.net.
|
||||
turner-tls.map.fastly.net. 13 IN A 151.101.193.67
|
||||
turner-tls.map.fastly.net. 13 IN A 151.101.65.67
|
||||
turner-tls.map.fastly.net. 13 IN A 151.101.1.67
|
||||
turner-tls.map.fastly.net. 13 IN A 151.101.129.67
|
||||
|
||||
;; Query time: 30 msec
|
||||
;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
|
||||
;; WHEN: Wed Dec 11 16:57:37 PST 2019
|
||||
;; MSG SIZE rcvd: 143
|
||||
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53268
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;www.google.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
www.google.com. 194 IN A 172.217.9.164
|
||||
|
||||
;; Query time: 30 msec
|
||||
;; SERVER: 2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)
|
||||
;; WHEN: Wed Dec 11 16:57:37 PST 2019
|
||||
;; MSG SIZE rcvd: 59
|
||||
|
1
tests/fixtures/osx-10.11.6/du.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/du.json
vendored
Normal file
File diff suppressed because one or more lines are too long
2471
tests/fixtures/osx-10.11.6/du.out
vendored
Executable file
2471
tests/fixtures/osx-10.11.6/du.out
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/osx-10.11.6/ifconfig.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/ifconfig.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"name": "lo0", "flags": 8049, "state": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": ["POINTOPOINT", "MULTICAST"], "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.1.81", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::6aa8:6dff:fe12:f575", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "68:a8:6d:12:f5:75", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "PROMISC", "SIMPLEX"], "mtu": 1500, "mac_addr": "b2:00:19:cb:f5:50", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 2304, "mac_addr": "0a:a8:6d:12:f5:75", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "mac_addr": "6a:a8:6d:21:38:00", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
40
tests/fixtures/osx-10.11.6/ifconfig.out
vendored
Executable file
40
tests/fixtures/osx-10.11.6/ifconfig.out
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
|
||||
options=3<RXCSUM,TXCSUM>
|
||||
inet6 ::1 prefixlen 128
|
||||
inet 127.0.0.1 netmask 0xff000000
|
||||
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
|
||||
nd6 options=1<PERFORMNUD>
|
||||
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
|
||||
stf0: flags=0<> mtu 1280
|
||||
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
||||
ether 68:a8:6d:12:f5:75
|
||||
inet6 fe80::6aa8:6dff:fe12:f575%en0 prefixlen 64 scopeid 0x4
|
||||
inet6 2600:1700:bab0:d40:6aa8:6dff:fe12:f575 prefixlen 64 autoconf
|
||||
inet6 2600:1700:bab0:d40:c0d1:97f7:a613:3ed3 prefixlen 64 autoconf temporary
|
||||
inet 192.168.1.81 netmask 0xffffff00 broadcast 192.168.1.255
|
||||
inet6 2600:1700:bab0:d40::26 prefixlen 64 dynamic
|
||||
nd6 options=1<PERFORMNUD>
|
||||
media: autoselect
|
||||
status: active
|
||||
en1: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
|
||||
options=60<TSO4,TSO6>
|
||||
ether b2:00:19:cb:f5:50
|
||||
media: autoselect <full-duplex>
|
||||
status: inactive
|
||||
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
|
||||
ether 0a:a8:6d:12:f5:75
|
||||
media: autoselect
|
||||
status: inactive
|
||||
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
||||
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
|
||||
ether 6a:a8:6d:21:38:00
|
||||
Configuration:
|
||||
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
|
||||
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
|
||||
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
|
||||
ipfilter disabled flags 0x2
|
||||
member: en1 flags=3<LEARNING,DISCOVER>
|
||||
ifmaxaddr 0 port 5 priority 0 path cost 0
|
||||
nd6 options=1<PERFORMNUD>
|
||||
media: <unknown type>
|
||||
status: inactive
|
1
tests/fixtures/osx-10.11.6/ifconfig2.json
vendored
Normal file
1
tests/fixtures/osx-10.11.6/ifconfig2.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[{"name": "lo0", "flags": 8049, "state": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "mtu": 16384, "ipv4_addr": "127.0.0.1", "ipv4_mask": "255.0.0.0", "ipv4_bcast": null, "ipv6_addr": "fe80::1", "ipv6_mask": 64, "ipv6_scope": "0x1", "type": null, "mac_addr": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "gif0", "flags": 8010, "state": ["POINTOPOINT", "MULTICAST"], "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "stf0", "flags": 0, "state": null, "mtu": 1280, "type": null, "mac_addr": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "ipv4_addr": "192.168.1.65", "ipv4_mask": "255.255.255.0", "ipv4_bcast": "192.168.1.255", "ipv6_addr": "fe80::62c5:47ff:fe0a:ce0b", "ipv6_mask": 64, "ipv6_scope": "0x4", "mac_addr": "60:c5:47:0a:ce:0b", "type": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "en1", "flags": 963, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "PROMISC", "SIMPLEX"], "mtu": 1500, "mac_addr": "b2:00:14:06:39:21", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "p2p0", "flags": 8843, "state": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 2304, "mac_addr": "02:c5:47:0a:ce:0b", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}, {"name": "bridge0", "flags": 8863, "state": ["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "mtu": 1500, "mac_addr": "62:c5:47:a0:f7:10", "type": null, "ipv4_addr": null, "ipv4_bcast": null, "ipv4_mask": null, "ipv6_addr": null, "ipv6_mask": null, "ipv6_scope": null, "metric": null, "rx_packets": null, "rx_errors": null, "rx_dropped": null, "rx_overruns": null, "rx_frame": null, "tx_packets": null, "tx_errors": null, "tx_dropped": null, "tx_overruns": null, "tx_carrier": null, "tx_collisions": null, "rx_bytes": null, "tx_bytes": null}]
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user