mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-21 00:19:42 +02:00
try new markdown conversion
This commit is contained in:
@ -236,6 +236,8 @@ option.
|
|||||||
- `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml))
|
- `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml))
|
||||||
- `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml))
|
- `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml))
|
||||||
- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo))
|
- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo))
|
||||||
|
- `--testing-two` enables the test parser 2 ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/testing_two))
|
||||||
|
- `--testing` enables the test parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/testing))
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of
|
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of
|
||||||
|
12
docgen.sh
12
docgen.sh
@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
cd jc
|
cd jc
|
||||||
echo Building docs for: package
|
echo Building docs for: package
|
||||||
pydocmd simple jc+ > ../docs/readme.md
|
pydoc-markdown -m jc > ../docs/readme.md
|
||||||
|
|
||||||
echo Building docs for: lib
|
echo Building docs for: lib
|
||||||
pydocmd simple lib+ > ../docs/lib.md
|
pydoc-markdown -m jc.lib > ../docs/lib.md
|
||||||
|
|
||||||
echo Building docs for: utils
|
echo Building docs for: utils
|
||||||
pydocmd simple utils+ > ../docs/utils.md
|
pydoc-markdown -m jc.utils > ../docs/utils.md
|
||||||
|
|
||||||
echo Building docs for: universal parser
|
echo Building docs for: universal parser
|
||||||
pydocmd simple jc.parsers.universal+ > ../docs/parsers/universal.md
|
pydoc-markdown -m jc.parsers.universal > ../docs/parsers/universal.md
|
||||||
|
|
||||||
# a bit of inception here... jc is being used to help
|
# a bit of inception here... jc is being used to help
|
||||||
# automate the generation of its own documentation. :)
|
# automate the generation of its own documentation. :)
|
||||||
@ -23,7 +23,7 @@ parsers=()
|
|||||||
while read -r value
|
while read -r value
|
||||||
do
|
do
|
||||||
parsers+=("$value")
|
parsers+=("$value")
|
||||||
done < <(jc -a | jq -c '.parsers[]')
|
done < <(jc -a | jq -c '.parsers[] | select(.plugin != true)')
|
||||||
|
|
||||||
# iterate over the bash array
|
# iterate over the bash array
|
||||||
for parser in "${parsers[@]}"
|
for parser in "${parsers[@]}"
|
||||||
@ -36,7 +36,7 @@ do
|
|||||||
|
|
||||||
echo "Building docs for: ${parser_name}"
|
echo "Building docs for: ${parser_name}"
|
||||||
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
|
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
|
||||||
pydocmd simple jc.parsers."${parser_name}"+ >> ../docs/parsers/"${parser_name}".md
|
pydoc-markdown -m jc.parsers."${parser_name}" >> ../docs/parsers/"${parser_name}".md
|
||||||
echo "## Parser Information" >> ../docs/parsers/"${parser_name}".md
|
echo "## Parser Information" >> ../docs/parsers/"${parser_name}".md
|
||||||
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
|
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
|
||||||
echo >> ../docs/parsers/"${parser_name}".md
|
echo >> ../docs/parsers/"${parser_name}".md
|
||||||
|
44
docgen.sh.old
Executable file
44
docgen.sh.old
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Generate docs.md
|
||||||
|
# requires pydoc-markdown 2.1.0.post1
|
||||||
|
|
||||||
|
cd jc
|
||||||
|
echo Building docs for: package
|
||||||
|
pydocmd simple jc+ > ../docs/readme.md
|
||||||
|
|
||||||
|
echo Building docs for: lib
|
||||||
|
pydocmd simple lib+ > ../docs/lib.md
|
||||||
|
|
||||||
|
echo Building docs for: utils
|
||||||
|
pydocmd simple utils+ > ../docs/utils.md
|
||||||
|
|
||||||
|
echo Building docs for: universal parser
|
||||||
|
pydocmd simple jc.parsers.universal+ > ../docs/parsers/universal.md
|
||||||
|
|
||||||
|
# a bit of inception here... jc is being used to help
|
||||||
|
# automate the generation of its own documentation. :)
|
||||||
|
|
||||||
|
# pull jc parser objects into a bash array from jq
|
||||||
|
parsers=()
|
||||||
|
while read -r value
|
||||||
|
do
|
||||||
|
parsers+=("$value")
|
||||||
|
done < <(jc -a | jq -c '.parsers[] | select(.plugin != true)')
|
||||||
|
|
||||||
|
# iterate over the bash array
|
||||||
|
for parser in "${parsers[@]}"
|
||||||
|
do
|
||||||
|
parser_name=$(jq -r '.name' <<< "$parser")
|
||||||
|
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
|
||||||
|
version=$(jq -r '.version' <<< "$parser")
|
||||||
|
author=$(jq -r '.author' <<< "$parser")
|
||||||
|
author_email=$(jq -r '.author_email' <<< "$parser")
|
||||||
|
|
||||||
|
echo "Building docs for: ${parser_name}"
|
||||||
|
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
|
||||||
|
pydocmd simple jc.parsers."${parser_name}"+ >> ../docs/parsers/"${parser_name}".md
|
||||||
|
echo "## Parser Information" >> ../docs/parsers/"${parser_name}".md
|
||||||
|
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
|
||||||
|
echo >> ../docs/parsers/"${parser_name}".md
|
||||||
|
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
|
||||||
|
done
|
145
docs/lib.md
145
docs/lib.md
@ -1,17 +1,18 @@
|
|||||||
|
<a id="jc.lib"></a>
|
||||||
|
|
||||||
|
# jc.lib
|
||||||
|
|
||||||
# lib
|
|
||||||
jc - JSON CLI output utility
|
jc - JSON CLI output utility
|
||||||
JC lib module
|
JC lib module
|
||||||
|
|
||||||
|
<a id="jc.lib.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
## parse
|
|
||||||
```python
|
```python
|
||||||
parse(parser_mod_name,
|
def parse(parser_mod_name: str, data: Union[str, Iterable[str]], quiet: Optional[bool] = False, raw: Optional[bool] = False, ignore_exceptions: Optional[Union[None, bool]] = None, **kwargs: Any, ,) -> Union[Dict[str, Any],
|
||||||
data,
|
List[Dict[str, Any]],
|
||||||
quiet=False,
|
Iterator[Dict[str, Any]]]
|
||||||
raw=False,
|
|
||||||
ignore_exceptions=None,
|
|
||||||
**kwargs)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Parse the string data using the supplied parser module.
|
Parse the string data using the supplied parser module.
|
||||||
@ -19,72 +20,106 @@ Parse the string data using the supplied parser module.
|
|||||||
This function provides a high-level API to simplify parser use. This
|
This function provides a high-level API to simplify parser use. This
|
||||||
function will call built-in parsers and custom plugin parsers.
|
function will call built-in parsers and custom plugin parsers.
|
||||||
|
|
||||||
Example:
|
**Example**:
|
||||||
|
|
||||||
>>> import jc
|
|
||||||
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
|
>>> import jc
|
||||||
{'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...}
|
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
|
||||||
|
- `{'year'` - 2022, 'month': 'Jan', 'month_num': 1, 'day'...}
|
||||||
|
|
||||||
|
To get a list of available parser module names, use `parser_mod_list()`
|
||||||
|
or `plugin_parser_mod_list()`. `plugin_parser_mod_list()` is a subset
|
||||||
|
of `parser_mod_list()`.
|
||||||
|
|
||||||
|
You can also use the lower-level parser modules directly:
|
||||||
|
|
||||||
|
>>> import jc.parsers.date
|
||||||
|
>>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
|
||||||
|
|
||||||
|
Though, accessing plugin parsers directly is a bit more cumbersome, so
|
||||||
|
this higher-level API is recommended. Here is how you can access plugin
|
||||||
|
parsers without this API:
|
||||||
|
|
||||||
|
>>> import os
|
||||||
|
>>> import sys
|
||||||
|
>>> import jc.appdirs
|
||||||
|
>>> data_dir = jc.appdirs.user_data_dir('jc', 'jc')
|
||||||
|
>>> local_parsers_dir = os.path.join(data_dir, 'jcparsers')
|
||||||
|
>>> sys.path.append(local_parsers_dir)
|
||||||
|
>>> import my_custom_parser
|
||||||
|
>>> my_custom_parser.parse('command_data')
|
||||||
|
|
||||||
|
|
||||||
To get a list of available parser module names, use `parser_mod_list()`
|
**Arguments**:
|
||||||
or `plugin_parser_mod_list()`. `plugin_parser_mod_list()` is a subset
|
|
||||||
of `parser_mod_list()`.
|
|
||||||
|
|
||||||
You can also use the lower-level parser modules directly:
|
|
||||||
|
- `parser_mod_name` - (string) name of the parser module. This
|
||||||
|
function will accept module_name,
|
||||||
|
cli-name, and --argument-name
|
||||||
|
variants of the module name.
|
||||||
|
|
||||||
|
- `data` - (string or data to parse (string for normal
|
||||||
|
iterator) parsers, iterator of strings for
|
||||||
|
streaming parsers)
|
||||||
|
|
||||||
|
- `raw` - (boolean) output preprocessed JSON if True
|
||||||
|
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
(streaming parsers only)
|
||||||
|
|
||||||
|
|
||||||
>>> import jc.parsers.date
|
**Returns**:
|
||||||
>>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022')
|
|
||||||
|
|
||||||
Though, accessing plugin parsers directly is a bit more cumbersome, so
|
|
||||||
this higher-level API is recommended. Here is how you can access plugin
|
Standard Parsers: Dictionary or List of Dictionaries
|
||||||
parsers without this API:
|
Streaming Parsers: Generator Object containing Dictionaries
|
||||||
|
|
||||||
>>> import os
|
<a id="jc.lib.parser_mod_list"></a>
|
||||||
>>> import sys
|
|
||||||
>>> import jc.appdirs
|
|
||||||
>>> data_dir = jc.appdirs.user_data_dir('jc', 'jc')
|
|
||||||
>>> local_parsers_dir = os.path.join(data_dir, 'jcparsers')
|
|
||||||
>>> sys.path.append(local_parsers_dir)
|
|
||||||
>>> import my_custom_parser
|
|
||||||
>>> my_custom_parser.parse('command_data')
|
|
||||||
|
|
||||||
Parameters:
|
#### parser\_mod\_list
|
||||||
|
|
||||||
parser_mod_name: (string) name of the parser module
|
|
||||||
|
|
||||||
data: (string or data to parse (string for normal
|
|
||||||
iterator) parsers, iterator of strings for
|
|
||||||
streaming parsers)
|
|
||||||
|
|
||||||
raw: (boolean) output preprocessed JSON if True
|
|
||||||
|
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
(streaming parsers only)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Standard Parsers: Dictionary or List of Dictionaries
|
|
||||||
Streaming Parsers: Generator Object containing Dictionaries
|
|
||||||
|
|
||||||
|
|
||||||
## parser_mod_list
|
|
||||||
```python
|
```python
|
||||||
parser_mod_list()
|
def parser_mod_list() -> List[str]
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a list of all available parser module names.
|
Returns a list of all available parser module names.
|
||||||
|
|
||||||
## plugin_parser_mod_list
|
<a id="jc.lib.plugin_parser_mod_list"></a>
|
||||||
|
|
||||||
|
#### plugin\_parser\_mod\_list
|
||||||
|
|
||||||
```python
|
```python
|
||||||
plugin_parser_mod_list()
|
def plugin_parser_mod_list() -> List[str]
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a list of plugin parser module names. This function is a
|
Returns a list of plugin parser module names. This function is a
|
||||||
subset of `parser_mod_list()`.
|
subset of `parser_mod_list()`.
|
||||||
|
|
||||||
|
<a id="jc.lib.parser_info"></a>
|
||||||
|
|
||||||
|
#### parser\_info
|
||||||
|
|
||||||
## get_help
|
|
||||||
```python
|
```python
|
||||||
get_help(parser_mod_name)
|
def parser_info(parser_mod_name: str) -> Dict[str, Any]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Returns a dictionary that includes the module metadata.
|
||||||
|
|
||||||
|
This function will accept module_name, cli-name, and --argument-name
|
||||||
|
variants of the module name string.
|
||||||
|
|
||||||
|
<a id="jc.lib.get_help"></a>
|
||||||
|
|
||||||
|
#### get\_help
|
||||||
|
|
||||||
|
```python
|
||||||
|
def get_help(parser_mod_name: str) -> None
|
||||||
|
```
|
||||||
|
|
||||||
Show help screen for the selected parser.
|
Show help screen for the selected parser.
|
||||||
|
|
||||||
|
This function will accept module_name, cli-name, and --argument-name
|
||||||
|
variants of the module name string.
|
||||||
|
|
||||||
|
@ -1,258 +1,270 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.acpi"></a>
|
||||||
|
|
||||||
# jc.parsers.acpi
|
# jc.parsers.acpi
|
||||||
|
|
||||||
jc - JSON CLI output utility `acpi` command output parser
|
jc - JSON CLI output utility `acpi` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ acpi -V | jc --acpi
|
$ acpi -V | jc --acpi
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc acpi -V
|
$ jc acpi -V
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('acpi', acpi_command_output)
|
result = jc.parse('acpi', acpi_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.acpi
|
import jc.parsers.acpi
|
||||||
result = jc.parsers.acpi.parse(acpi_command_output)
|
result = jc.parsers.acpi.parse(acpi_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": string,
|
"type": string,
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"state": string,
|
"state": string,
|
||||||
"charge_percent": integer,
|
"charge_percent": integer,
|
||||||
"until_charged": string,
|
"until_charged": string,
|
||||||
"until_charged_hours": integer,
|
"until_charged_hours": integer,
|
||||||
"until_charged_minuts": integer,
|
"until_charged_minuts": integer,
|
||||||
"until_charged_seconds": integer,
|
"until_charged_seconds": integer,
|
||||||
"until_charged_total_seconds": integer,
|
"until_charged_total_seconds": integer,
|
||||||
"charge_remaining": string,
|
"charge_remaining": string,
|
||||||
"charge_remaining_hours": integer,
|
"charge_remaining_hours": integer,
|
||||||
"charge_remaining_minutes": integer,
|
"charge_remaining_minutes": integer,
|
||||||
"charge_remaining_seconds": integer,
|
"charge_remaining_seconds": integer,
|
||||||
"charge_remaining_total_seconds": integer,
|
"charge_remaining_total_seconds": integer,
|
||||||
"design_capacity_mah": integer,
|
"design_capacity_mah": integer,
|
||||||
"last_full_capacity": integer,
|
"last_full_capacity": integer,
|
||||||
"last_full_capacity_percent": integer,
|
"last_full_capacity_percent": integer,
|
||||||
"on-line": boolean,
|
"on-line": boolean,
|
||||||
"mode": string,
|
"mode": string,
|
||||||
"temperature": float,
|
"temperature": float,
|
||||||
"temperature_unit": string,
|
"temperature_unit": string,
|
||||||
"trip_points": [
|
"trip_points": [
|
||||||
{
|
{
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"switches_to_mode": string,
|
"switches_to_mode": string,
|
||||||
"temperature": float,
|
"temperature": float,
|
||||||
"temperature_unit": string
|
"temperature_unit": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"messages": [
|
"messages": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ acpi -V | jc --acpi -p
|
|
||||||
[
|
$ acpi -V | jc --acpi -p
|
||||||
{
|
[
|
||||||
"type": "Battery",
|
{
|
||||||
"id": 0,
|
- `"type"` - "Battery",
|
||||||
"state": "Charging",
|
- `"id"` - 0,
|
||||||
"charge_percent": 71,
|
- `"state"` - "Charging",
|
||||||
"until_charged": "00:29:20",
|
- `"charge_percent"` - 71,
|
||||||
"design_capacity_mah": 2110,
|
- `"until_charged"` - "00:29:20",
|
||||||
"last_full_capacity": 2271,
|
- `"design_capacity_mah"` - 2110,
|
||||||
"last_full_capacity_percent": 100,
|
- `"last_full_capacity"` - 2271,
|
||||||
"until_charged_hours": 0,
|
- `"last_full_capacity_percent"` - 100,
|
||||||
"until_charged_minutes": 29,
|
- `"until_charged_hours"` - 0,
|
||||||
"until_charged_seconds": 20,
|
- `"until_charged_minutes"` - 29,
|
||||||
"until_charged_total_seconds": 1760
|
- `"until_charged_seconds"` - 20,
|
||||||
},
|
- `"until_charged_total_seconds"` - 1760
|
||||||
{
|
},
|
||||||
"type": "Adapter",
|
{
|
||||||
"id": 0,
|
- `"type"` - "Adapter",
|
||||||
"on-line": true
|
- `"id"` - 0,
|
||||||
},
|
- `"on-line"` - true
|
||||||
{
|
},
|
||||||
"type": "Thermal",
|
{
|
||||||
"id": 0,
|
- `"type"` - "Thermal",
|
||||||
"mode": "ok",
|
- `"id"` - 0,
|
||||||
"temperature": 46.0,
|
- `"mode"` - "ok",
|
||||||
"temperature_unit": "C",
|
- `"temperature"` - 46.0,
|
||||||
"trip_points": [
|
- `"temperature_unit"` - "C",
|
||||||
{
|
- `"trip_points"` - [
|
||||||
"id": 0,
|
{
|
||||||
"switches_to_mode": "critical",
|
- `"id"` - 0,
|
||||||
"temperature": 127.0,
|
- `"switches_to_mode"` - "critical",
|
||||||
"temperature_unit": "C"
|
- `"temperature"` - 127.0,
|
||||||
},
|
- `"temperature_unit"` - "C"
|
||||||
{
|
},
|
||||||
"id": 1,
|
{
|
||||||
"switches_to_mode": "hot",
|
- `"id"` - 1,
|
||||||
"temperature": 127.0,
|
- `"switches_to_mode"` - "hot",
|
||||||
"temperature_unit": "C"
|
- `"temperature"` - 127.0,
|
||||||
}
|
- `"temperature_unit"` - "C"
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "Cooling",
|
{
|
||||||
"id": 0,
|
- `"type"` - "Cooling",
|
||||||
"messages": [
|
- `"id"` - 0,
|
||||||
"Processor 0 of 10"
|
- `"messages"` - [
|
||||||
]
|
"Processor 0 of 10"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "Cooling",
|
{
|
||||||
"id": 1,
|
- `"type"` - "Cooling",
|
||||||
"messages": [
|
- `"id"` - 1,
|
||||||
"Processor 0 of 10"
|
- `"messages"` - [
|
||||||
]
|
"Processor 0 of 10"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "Cooling",
|
{
|
||||||
"id": 2,
|
- `"type"` - "Cooling",
|
||||||
"messages": [
|
- `"id"` - 2,
|
||||||
"x86_pkg_temp no state information available"
|
- `"messages"` - [
|
||||||
]
|
"x86_pkg_temp no state information available"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "Cooling",
|
{
|
||||||
"id": 3,
|
- `"type"` - "Cooling",
|
||||||
"messages": [
|
- `"id"` - 3,
|
||||||
"Processor 0 of 10"
|
- `"messages"` - [
|
||||||
]
|
"Processor 0 of 10"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "Cooling",
|
{
|
||||||
"id": 4,
|
- `"type"` - "Cooling",
|
||||||
"messages": [
|
- `"id"` - 4,
|
||||||
"intel_powerclamp no state information available"
|
- `"messages"` - [
|
||||||
]
|
"intel_powerclamp no state information available"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"type": "Cooling",
|
{
|
||||||
"id": 5,
|
- `"type"` - "Cooling",
|
||||||
"messages": [
|
- `"id"` - 5,
|
||||||
"Processor 0 of 10"
|
- `"messages"` - [
|
||||||
]
|
"Processor 0 of 10"
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ acpi -V | jc --acpi -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"type"` - "Battery",
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"state"` - "Charging",
|
||||||
|
- `"charge_percent"` - "71",
|
||||||
|
- `"until_charged"` - "00:29:20",
|
||||||
|
- `"design_capacity_mah"` - "2110",
|
||||||
|
- `"last_full_capacity"` - "2271",
|
||||||
|
- `"last_full_capacity_percent"` - "100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Adapter",
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"on-line"` - true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Thermal",
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"mode"` - "ok",
|
||||||
|
- `"temperature"` - "46.0",
|
||||||
|
- `"temperature_unit"` - "C",
|
||||||
|
- `"trip_points"` - [
|
||||||
|
{
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"switches_to_mode"` - "critical",
|
||||||
|
- `"temperature"` - "127.0",
|
||||||
|
- `"temperature_unit"` - "C"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"id"` - "1",
|
||||||
|
- `"switches_to_mode"` - "hot",
|
||||||
|
- `"temperature"` - "127.0",
|
||||||
|
- `"temperature_unit"` - "C"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Cooling",
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"messages"` - [
|
||||||
|
"Processor 0 of 10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Cooling",
|
||||||
|
- `"id"` - "1",
|
||||||
|
- `"messages"` - [
|
||||||
|
"Processor 0 of 10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Cooling",
|
||||||
|
- `"id"` - "2",
|
||||||
|
- `"messages"` - [
|
||||||
|
"x86_pkg_temp no state information available"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Cooling",
|
||||||
|
- `"id"` - "3",
|
||||||
|
- `"messages"` - [
|
||||||
|
"Processor 0 of 10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Cooling",
|
||||||
|
- `"id"` - "4",
|
||||||
|
- `"messages"` - [
|
||||||
|
"intel_powerclamp no state information available"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Cooling",
|
||||||
|
- `"id"` - "5",
|
||||||
|
- `"messages"` - [
|
||||||
|
"Processor 0 of 10"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ acpi -V | jc --acpi -p -r
|
<a id="jc.parsers.acpi.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"type": "Battery",
|
|
||||||
"id": "0",
|
|
||||||
"state": "Charging",
|
|
||||||
"charge_percent": "71",
|
|
||||||
"until_charged": "00:29:20",
|
|
||||||
"design_capacity_mah": "2110",
|
|
||||||
"last_full_capacity": "2271",
|
|
||||||
"last_full_capacity_percent": "100"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Adapter",
|
|
||||||
"id": "0",
|
|
||||||
"on-line": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Thermal",
|
|
||||||
"id": "0",
|
|
||||||
"mode": "ok",
|
|
||||||
"temperature": "46.0",
|
|
||||||
"temperature_unit": "C",
|
|
||||||
"trip_points": [
|
|
||||||
{
|
|
||||||
"id": "0",
|
|
||||||
"switches_to_mode": "critical",
|
|
||||||
"temperature": "127.0",
|
|
||||||
"temperature_unit": "C"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1",
|
|
||||||
"switches_to_mode": "hot",
|
|
||||||
"temperature": "127.0",
|
|
||||||
"temperature_unit": "C"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Cooling",
|
|
||||||
"id": "0",
|
|
||||||
"messages": [
|
|
||||||
"Processor 0 of 10"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Cooling",
|
|
||||||
"id": "1",
|
|
||||||
"messages": [
|
|
||||||
"Processor 0 of 10"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Cooling",
|
|
||||||
"id": "2",
|
|
||||||
"messages": [
|
|
||||||
"x86_pkg_temp no state information available"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Cooling",
|
|
||||||
"id": "3",
|
|
||||||
"messages": [
|
|
||||||
"Processor 0 of 10"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Cooling",
|
|
||||||
"id": "4",
|
|
||||||
"messages": [
|
|
||||||
"intel_powerclamp no state information available"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Cooling",
|
|
||||||
"id": "5",
|
|
||||||
"messages": [
|
|
||||||
"Processor 0 of 10"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.acpi.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,111 +1,123 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.airport"></a>
|
||||||
|
|
||||||
# jc.parsers.airport
|
# jc.parsers.airport
|
||||||
|
|
||||||
jc - JSON CLI output utility `airport -I` command output parser
|
jc - JSON CLI output utility `airport -I` command output parser
|
||||||
|
|
||||||
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ airport -I | jc --airport
|
$ airport -I | jc --airport
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc airport -I
|
$ jc airport -I
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('airport', airport_command_output)
|
result = jc.parse('airport', airport_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.airport
|
import jc.parsers.airport
|
||||||
result = jc.parsers.airport.parse(airport_command_output)
|
result = jc.parsers.airport.parse(airport_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"agrctlrssi": integer,
|
"agrctlrssi": integer,
|
||||||
"agrextrssi": integer,
|
"agrextrssi": integer,
|
||||||
"agrctlnoise": integer,
|
"agrctlnoise": integer,
|
||||||
"agrextnoise": integer,
|
"agrextnoise": integer,
|
||||||
"state": string,
|
"state": string,
|
||||||
"op_mode": string,
|
"op_mode": string,
|
||||||
"lasttxrate": integer,
|
"lasttxrate": integer,
|
||||||
"maxrate": integer,
|
"maxrate": integer,
|
||||||
"lastassocstatus": integer,
|
"lastassocstatus": integer,
|
||||||
"802_11_auth": string,
|
"802_11_auth": string,
|
||||||
"link_auth": string,
|
"link_auth": string,
|
||||||
"bssid": string,
|
"bssid": string,
|
||||||
"ssid": string,
|
"ssid": string,
|
||||||
"mcs": integer,
|
"mcs": integer,
|
||||||
"channel": string
|
"channel": string
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ airport -I | jc --airport -p
|
|
||||||
{
|
$ airport -I | jc --airport -p
|
||||||
"agrctlrssi": -66,
|
{
|
||||||
"agrextrssi": 0,
|
- `"agrctlrssi"` - -66,
|
||||||
"agrctlnoise": -90,
|
- `"agrextrssi"` - 0,
|
||||||
"agrextnoise": 0,
|
- `"agrctlnoise"` - -90,
|
||||||
"state": "running",
|
- `"agrextnoise"` - 0,
|
||||||
"op_mode": "station",
|
- `"state"` - "running",
|
||||||
"lasttxrate": 195,
|
- `"op_mode"` - "station",
|
||||||
"maxrate": 867,
|
- `"lasttxrate"` - 195,
|
||||||
"lastassocstatus": 0,
|
- `"maxrate"` - 867,
|
||||||
"802_11_auth": "open",
|
- `"lastassocstatus"` - 0,
|
||||||
"link_auth": "wpa2-psk",
|
- `"802_11_auth"` - "open",
|
||||||
"bssid": "3c:37:86:15:ad:f9",
|
- `"link_auth"` - "wpa2-psk",
|
||||||
"ssid": "SnazzleDazzle",
|
- `"bssid"` - "3c:37:86:15:ad:f9",
|
||||||
"mcs": 0,
|
- `"ssid"` - "SnazzleDazzle",
|
||||||
"channel": "48,80"
|
- `"mcs"` - 0,
|
||||||
}
|
- `"channel"` - "48,80"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ airport -I | jc --airport -p -r
|
||||||
|
{
|
||||||
|
- `"agrctlrssi"` - "-66",
|
||||||
|
- `"agrextrssi"` - "0",
|
||||||
|
- `"agrctlnoise"` - "-90",
|
||||||
|
- `"agrextnoise"` - "0",
|
||||||
|
- `"state"` - "running",
|
||||||
|
- `"op_mode"` - "station",
|
||||||
|
- `"lasttxrate"` - "195",
|
||||||
|
- `"maxrate"` - "867",
|
||||||
|
- `"lastassocstatus"` - "0",
|
||||||
|
- `"802_11_auth"` - "open",
|
||||||
|
- `"link_auth"` - "wpa2-psk",
|
||||||
|
- `"bssid"` - "3c:37:86:15:ad:f9",
|
||||||
|
- `"ssid"` - "SnazzleDazzle",
|
||||||
|
- `"mcs"` - "0",
|
||||||
|
- `"channel"` - "48,80"
|
||||||
|
}
|
||||||
|
|
||||||
$ airport -I | jc --airport -p -r
|
<a id="jc.parsers.airport.info"></a>
|
||||||
{
|
|
||||||
"agrctlrssi": "-66",
|
|
||||||
"agrextrssi": "0",
|
|
||||||
"agrctlnoise": "-90",
|
|
||||||
"agrextnoise": "0",
|
|
||||||
"state": "running",
|
|
||||||
"op_mode": "station",
|
|
||||||
"lasttxrate": "195",
|
|
||||||
"maxrate": "867",
|
|
||||||
"lastassocstatus": "0",
|
|
||||||
"802_11_auth": "open",
|
|
||||||
"link_auth": "wpa2-psk",
|
|
||||||
"bssid": "3c:37:86:15:ad:f9",
|
|
||||||
"ssid": "SnazzleDazzle",
|
|
||||||
"mcs": "0",
|
|
||||||
"channel": "48,80"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.airport.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: darwin
|
Compatibility: darwin
|
||||||
|
@ -1,139 +1,151 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.airport_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.airport\_s
|
||||||
|
|
||||||
# jc.parsers.airport_s
|
|
||||||
jc - JSON CLI output utility `airport -s` command output parser
|
jc - JSON CLI output utility `airport -s` command output parser
|
||||||
|
|
||||||
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ airport -s | jc --airport-s
|
$ airport -s | jc --airport-s
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc airport -s
|
$ jc airport -s
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('airport_s', airport_s_command_output)
|
result = jc.parse('airport_s', airport_s_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.airport_s
|
import jc.parsers.airport_s
|
||||||
result = jc.parsers.airport_s.parse(airport_s_command_output)
|
result = jc.parsers.airport_s.parse(airport_s_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"ssid": string,
|
"ssid": string,
|
||||||
"bssid": string,
|
"bssid": string,
|
||||||
"rssi": integer,
|
"rssi": integer,
|
||||||
"channel": string,
|
"channel": string,
|
||||||
"ht": boolean,
|
"ht": boolean,
|
||||||
"cc": string,
|
"cc": string,
|
||||||
"security": [
|
"security": [
|
||||||
string,
|
string,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ airport -s | jc --airport-s -p
|
|
||||||
[
|
$ airport -s | jc --airport-s -p
|
||||||
{
|
[
|
||||||
"ssid": "DIRECT-4A-HP OfficeJet 3830",
|
{
|
||||||
"bssid": "00:67:eb:2a:a7:3b",
|
- `"ssid"` - "DIRECT-4A-HP OfficeJet 3830",
|
||||||
"rssi": -90,
|
- `"bssid"` - "00:67:eb:2a:a7:3b",
|
||||||
"channel": "6",
|
- `"rssi"` - -90,
|
||||||
"ht": true,
|
- `"channel"` - "6",
|
||||||
"cc": "--",
|
- `"ht"` - true,
|
||||||
"security": [
|
- `"cc"` - "--",
|
||||||
"WPA2(PSK/AES/AES)"
|
- `"security"` - [
|
||||||
]
|
"WPA2(PSK/AES/AES)"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ssid": "Latitude38",
|
{
|
||||||
"bssid": "c0:ff:d5:d2:7a:f3",
|
- `"ssid"` - "Latitude38",
|
||||||
"rssi": -85,
|
- `"bssid"` - "c0:ff:d5:d2:7a:f3",
|
||||||
"channel": "11",
|
- `"rssi"` - -85,
|
||||||
"ht": true,
|
- `"channel"` - "11",
|
||||||
"cc": "US",
|
- `"ht"` - true,
|
||||||
"security": [
|
- `"cc"` - "US",
|
||||||
"WPA2(PSK/AES/AES)"
|
- `"security"` - [
|
||||||
]
|
"WPA2(PSK/AES/AES)"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ssid": "xfinitywifi",
|
{
|
||||||
"bssid": "6e:e3:0e:b8:45:99",
|
- `"ssid"` - "xfinitywifi",
|
||||||
"rssi": -83,
|
- `"bssid"` - "6e:e3:0e:b8:45:99",
|
||||||
"channel": "11",
|
- `"rssi"` - -83,
|
||||||
"ht": true,
|
- `"channel"` - "11",
|
||||||
"cc": "US",
|
- `"ht"` - true,
|
||||||
"security": [
|
- `"cc"` - "US",
|
||||||
"NONE"
|
- `"security"` - [
|
||||||
]
|
"NONE"
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ airport -s | jc --airport -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"ssid"` - "DIRECT-F3-HP ENVY 5660 series",
|
||||||
|
- `"bssid"` - "b0:5a:da:6f:0a:d4",
|
||||||
|
- `"rssi"` - "-93",
|
||||||
|
- `"channel"` - "1",
|
||||||
|
- `"ht"` - "Y",
|
||||||
|
- `"cc"` - "--",
|
||||||
|
- `"security"` - "WPA2(PSK/AES/AES)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"ssid"` - "YouAreInfected-5",
|
||||||
|
- `"bssid"` - "5c:e3:0e:c2:85:da",
|
||||||
|
- `"rssi"` - "-85",
|
||||||
|
- `"channel"` - "36",
|
||||||
|
- `"ht"` - "Y",
|
||||||
|
- `"cc"` - "US",
|
||||||
|
- `"security"` - "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"ssid"` - "YuanFamily",
|
||||||
|
- `"bssid"` - "5c:e3:0e:b8:5f:9a",
|
||||||
|
- `"rssi"` - "-84",
|
||||||
|
- `"channel"` - "11",
|
||||||
|
- `"ht"` - "Y",
|
||||||
|
- `"cc"` - "US",
|
||||||
|
- `"security"` - "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ airport -s | jc --airport -p -r
|
<a id="jc.parsers.airport_s.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"ssid": "DIRECT-F3-HP ENVY 5660 series",
|
|
||||||
"bssid": "b0:5a:da:6f:0a:d4",
|
|
||||||
"rssi": "-93",
|
|
||||||
"channel": "1",
|
|
||||||
"ht": "Y",
|
|
||||||
"cc": "--",
|
|
||||||
"security": "WPA2(PSK/AES/AES)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ssid": "YouAreInfected-5",
|
|
||||||
"bssid": "5c:e3:0e:c2:85:da",
|
|
||||||
"rssi": "-85",
|
|
||||||
"channel": "36",
|
|
||||||
"ht": "Y",
|
|
||||||
"cc": "US",
|
|
||||||
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ssid": "YuanFamily",
|
|
||||||
"bssid": "5c:e3:0e:b8:5f:9a",
|
|
||||||
"rssi": "-84",
|
|
||||||
"channel": "11",
|
|
||||||
"ht": "Y",
|
|
||||||
"cc": "US",
|
|
||||||
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.airport_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: darwin
|
Compatibility: darwin
|
||||||
|
@ -1,148 +1,160 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.arp"></a>
|
||||||
|
|
||||||
# jc.parsers.arp
|
# jc.parsers.arp
|
||||||
|
|
||||||
jc - JSON CLI output utility `arp` command output parser
|
jc - JSON CLI output utility `arp` command output parser
|
||||||
|
|
||||||
Supports `arp` and `arp -a` output.
|
Supports `arp` and `arp -a` output.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ arp | jc --arp
|
$ arp | jc --arp
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc arp
|
$ jc arp
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('arp', arp_command_output)
|
result = jc.parse('arp', arp_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.arp
|
import jc.parsers.arp
|
||||||
result = jc.parsers.arp.parse(arp_command_output)
|
result = jc.parsers.arp.parse(arp_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"address": string,
|
"address": string,
|
||||||
"hwtype": string,
|
"hwtype": string,
|
||||||
"hwaddress": string,
|
"hwaddress": string,
|
||||||
"flags_mask": string,
|
"flags_mask": string,
|
||||||
"iface": string,
|
"iface": string,
|
||||||
"permanent": boolean,
|
"permanent": boolean,
|
||||||
"expires": integer
|
"expires": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ arp | jc --arp -p
|
|
||||||
[
|
$ arp | jc --arp -p
|
||||||
{
|
[
|
||||||
"address": "192.168.71.254",
|
{
|
||||||
"hwtype": "ether",
|
- `"address"` - "192.168.71.254",
|
||||||
"hwaddress": "00:50:56:f0:98:26",
|
- `"hwtype"` - "ether",
|
||||||
"flags_mask": "C",
|
- `"hwaddress"` - "00:50:56:f0:98:26",
|
||||||
"iface": "ens33"
|
- `"flags_mask"` - "C",
|
||||||
},
|
- `"iface"` - "ens33"
|
||||||
{
|
},
|
||||||
"address": "gateway",
|
{
|
||||||
"hwtype": "ether",
|
- `"address"` - "gateway",
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
- `"hwtype"` - "ether",
|
||||||
"flags_mask": "C",
|
- `"hwaddress"` - "00:50:56:f7:4a:fc",
|
||||||
"iface": "ens33"
|
- `"flags_mask"` - "C",
|
||||||
}
|
- `"iface"` - "ens33"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ arp | jc --arp -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"address"` - "gateway",
|
||||||
|
- `"hwtype"` - "ether",
|
||||||
|
- `"hwaddress"` - "00:50:56:f7:4a:fc",
|
||||||
|
- `"flags_mask"` - "C",
|
||||||
|
- `"iface"` - "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"address"` - "192.168.71.254",
|
||||||
|
- `"hwtype"` - "ether",
|
||||||
|
- `"hwaddress"` - "00:50:56:fe:7a:b4",
|
||||||
|
- `"flags_mask"` - "C",
|
||||||
|
- `"iface"` - "ens33"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ arp -a | jc --arp -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"name"` - null,
|
||||||
|
- `"address"` - "192.168.71.254",
|
||||||
|
- `"hwtype"` - "ether",
|
||||||
|
- `"hwaddress"` - "00:50:56:f0:98:26",
|
||||||
|
- `"iface"` - "ens33"
|
||||||
|
- `"permanent"` - false,
|
||||||
|
- `"expires"` - 1182
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "gateway",
|
||||||
|
- `"address"` - "192.168.71.2",
|
||||||
|
- `"hwtype"` - "ether",
|
||||||
|
- `"hwaddress"` - "00:50:56:f7:4a:fc",
|
||||||
|
- `"iface"` - "ens33"
|
||||||
|
- `"permanent"` - false,
|
||||||
|
- `"expires"` - 110
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ arp -a | jc --arp -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"name"` - "?",
|
||||||
|
- `"address"` - "192.168.71.254",
|
||||||
|
- `"hwtype"` - "ether",
|
||||||
|
- `"hwaddress"` - "00:50:56:fe:7a:b4",
|
||||||
|
- `"iface"` - "ens33"
|
||||||
|
- `"permanent"` - false,
|
||||||
|
- `"expires"` - "1182"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "_gateway",
|
||||||
|
- `"address"` - "192.168.71.2",
|
||||||
|
- `"hwtype"` - "ether",
|
||||||
|
- `"hwaddress"` - "00:50:56:f7:4a:fc",
|
||||||
|
- `"iface"` - "ens33"
|
||||||
|
- `"permanent"` - false,
|
||||||
|
- `"expires"` - "110"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ arp | jc --arp -p -r
|
<a id="jc.parsers.arp.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"address": "gateway",
|
|
||||||
"hwtype": "ether",
|
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
|
||||||
"flags_mask": "C",
|
|
||||||
"iface": "ens33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"address": "192.168.71.254",
|
|
||||||
"hwtype": "ether",
|
|
||||||
"hwaddress": "00:50:56:fe:7a:b4",
|
|
||||||
"flags_mask": "C",
|
|
||||||
"iface": "ens33"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ arp -a | jc --arp -p
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": null,
|
|
||||||
"address": "192.168.71.254",
|
|
||||||
"hwtype": "ether",
|
|
||||||
"hwaddress": "00:50:56:f0:98:26",
|
|
||||||
"iface": "ens33"
|
|
||||||
"permanent": false,
|
|
||||||
"expires": 1182
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gateway",
|
|
||||||
"address": "192.168.71.2",
|
|
||||||
"hwtype": "ether",
|
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
|
||||||
"iface": "ens33"
|
|
||||||
"permanent": false,
|
|
||||||
"expires": 110
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ arp -a | jc --arp -p -r
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "?",
|
|
||||||
"address": "192.168.71.254",
|
|
||||||
"hwtype": "ether",
|
|
||||||
"hwaddress": "00:50:56:fe:7a:b4",
|
|
||||||
"iface": "ens33"
|
|
||||||
"permanent": false,
|
|
||||||
"expires": "1182"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_gateway",
|
|
||||||
"address": "192.168.71.2",
|
|
||||||
"hwtype": "ether",
|
|
||||||
"hwaddress": "00:50:56:f7:4a:fc",
|
|
||||||
"iface": "ens33"
|
|
||||||
"permanent": false,
|
|
||||||
"expires": "110"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.arp.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, aix, freebsd, darwin
|
Compatibility: linux, aix, freebsd, darwin
|
||||||
|
@ -1,151 +1,163 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.blkid"></a>
|
||||||
|
|
||||||
# jc.parsers.blkid
|
# jc.parsers.blkid
|
||||||
|
|
||||||
jc - JSON CLI output utility `blkid` command output parser
|
jc - JSON CLI output utility `blkid` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ blkid | jc --blkid
|
$ blkid | jc --blkid
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc blkid
|
$ jc blkid
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('blkid', blkid_command_output)
|
result = jc.parse('blkid', blkid_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.blkid
|
import jc.parsers.blkid
|
||||||
result = jc.parsers.blkid.parse(blkid_command_output)
|
result = jc.parsers.blkid.parse(blkid_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"device": string,
|
"device": string,
|
||||||
"uuid": string,
|
"uuid": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"usage": string,
|
"usage": string,
|
||||||
"part_entry_scheme": string,
|
"part_entry_scheme": string,
|
||||||
"part_entry_type": string,
|
"part_entry_type": string,
|
||||||
"part_entry_flags": string,
|
"part_entry_flags": string,
|
||||||
"part_entry_number": integer,
|
"part_entry_number": integer,
|
||||||
"part_entry_offset": integer,
|
"part_entry_offset": integer,
|
||||||
"part_entry_size": integer,
|
"part_entry_size": integer,
|
||||||
"part_entry_disk": string,
|
"part_entry_disk": string,
|
||||||
"id_fs_uuid": string,
|
"id_fs_uuid": string,
|
||||||
"id_fs_uuid_enc": string,
|
"id_fs_uuid_enc": string,
|
||||||
"id_fs_version": string,
|
"id_fs_version": string,
|
||||||
"id_fs_type": string,
|
"id_fs_type": string,
|
||||||
"id_fs_usage": string,
|
"id_fs_usage": string,
|
||||||
"id_part_entry_scheme": string,
|
"id_part_entry_scheme": string,
|
||||||
"id_part_entry_type": string,
|
"id_part_entry_type": string,
|
||||||
"id_part_entry_flags": string,
|
"id_part_entry_flags": string,
|
||||||
"id_part_entry_number": integer,
|
"id_part_entry_number": integer,
|
||||||
"id_part_entry_offset": integer,
|
"id_part_entry_offset": integer,
|
||||||
"id_part_entry_size": integer,
|
"id_part_entry_size": integer,
|
||||||
"id_iolimit_minimum_io_size": integer,
|
"id_iolimit_minimum_io_size": integer,
|
||||||
"id_iolimit_physical_sector_size": integer,
|
"id_iolimit_physical_sector_size": integer,
|
||||||
"id_iolimit_logical_sector_size": integer,
|
"id_iolimit_logical_sector_size": integer,
|
||||||
"id_part_entry_disk": string,
|
"id_part_entry_disk": string,
|
||||||
"minimum_io_size": integer,
|
"minimum_io_size": integer,
|
||||||
"physical_sector_size": integer,
|
"physical_sector_size": integer,
|
||||||
"logical_sector_size": integer
|
"logical_sector_size": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ blkid | jc --blkid -p
|
|
||||||
[
|
$ blkid | jc --blkid -p
|
||||||
{
|
[
|
||||||
"device": "/dev/sda1",
|
{
|
||||||
"uuid": "05d927ab-5875-49e4-ada1-7f46cb32c932",
|
- `"device"` - "/dev/sda1",
|
||||||
"type": "xfs"
|
- `"uuid"` - "05d927ab-5875-49e4-ada1-7f46cb32c932",
|
||||||
},
|
- `"type"` - "xfs"
|
||||||
{
|
},
|
||||||
"device": "/dev/sda2",
|
{
|
||||||
"uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
- `"device"` - "/dev/sda2",
|
||||||
"type": "LVM2_member"
|
- `"uuid"` - "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
||||||
},
|
- `"type"` - "LVM2_member"
|
||||||
{
|
},
|
||||||
"device": "/dev/mapper/centos-root",
|
{
|
||||||
"uuid": "07d718ff-950c-4e5b-98f0-42a1147c77d9",
|
- `"device"` - "/dev/mapper/centos-root",
|
||||||
"type": "xfs"
|
- `"uuid"` - "07d718ff-950c-4e5b-98f0-42a1147c77d9",
|
||||||
},
|
- `"type"` - "xfs"
|
||||||
{
|
},
|
||||||
"device": "/dev/mapper/centos-swap",
|
{
|
||||||
"uuid": "615eb89a-bcbf-46fd-80e3-c483ff5c931f",
|
- `"device"` - "/dev/mapper/centos-swap",
|
||||||
"type": "swap"
|
- `"uuid"` - "615eb89a-bcbf-46fd-80e3-c483ff5c931f",
|
||||||
}
|
- `"type"` - "swap"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo blkid -o udev -ip /dev/sda2 | jc --blkid -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"id_fs_uuid"` - "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
||||||
|
- `"id_fs_uuid_enc"` - "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
||||||
|
- `"id_fs_version"` - "LVM2\\x20001",
|
||||||
|
- `"id_fs_type"` - "LVM2_member",
|
||||||
|
- `"id_fs_usage"` - "raid",
|
||||||
|
- `"id_iolimit_minimum_io_size"` - 512,
|
||||||
|
- `"id_iolimit_physical_sector_size"` - 512,
|
||||||
|
- `"id_iolimit_logical_sector_size"` - 512,
|
||||||
|
- `"id_part_entry_scheme"` - "dos",
|
||||||
|
- `"id_part_entry_type"` - "0x8e",
|
||||||
|
- `"id_part_entry_number"` - 2,
|
||||||
|
- `"id_part_entry_offset"` - 2099200,
|
||||||
|
- `"id_part_entry_size"` - 39843840,
|
||||||
|
- `"id_part_entry_disk"` - "8:0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo blkid -ip /dev/sda1 | jc --blkid -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"devname"` - "/dev/sda1",
|
||||||
|
- `"uuid"` - "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
|
- `"type"` - "xfs",
|
||||||
|
- `"usage"` - "filesystem",
|
||||||
|
- `"minimum_io_size"` - "512",
|
||||||
|
- `"physical_sector_size"` - "512",
|
||||||
|
- `"logical_sector_size"` - "512",
|
||||||
|
- `"part_entry_scheme"` - "dos",
|
||||||
|
- `"part_entry_type"` - "0x83",
|
||||||
|
- `"part_entry_flags"` - "0x80",
|
||||||
|
- `"part_entry_number"` - "1",
|
||||||
|
- `"part_entry_offset"` - "2048",
|
||||||
|
- `"part_entry_size"` - "2097152",
|
||||||
|
- `"part_entry_disk"` - "8:0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ sudo blkid -o udev -ip /dev/sda2 | jc --blkid -p
|
<a id="jc.parsers.blkid.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"id_fs_uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
|
||||||
"id_fs_uuid_enc": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
|
|
||||||
"id_fs_version": "LVM2\x20001",
|
|
||||||
"id_fs_type": "LVM2_member",
|
|
||||||
"id_fs_usage": "raid",
|
|
||||||
"id_iolimit_minimum_io_size": 512,
|
|
||||||
"id_iolimit_physical_sector_size": 512,
|
|
||||||
"id_iolimit_logical_sector_size": 512,
|
|
||||||
"id_part_entry_scheme": "dos",
|
|
||||||
"id_part_entry_type": "0x8e",
|
|
||||||
"id_part_entry_number": 2,
|
|
||||||
"id_part_entry_offset": 2099200,
|
|
||||||
"id_part_entry_size": 39843840,
|
|
||||||
"id_part_entry_disk": "8:0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ sudo blkid -ip /dev/sda1 | jc --blkid -p -r
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"devname": "/dev/sda1",
|
|
||||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
|
||||||
"type": "xfs",
|
|
||||||
"usage": "filesystem",
|
|
||||||
"minimum_io_size": "512",
|
|
||||||
"physical_sector_size": "512",
|
|
||||||
"logical_sector_size": "512",
|
|
||||||
"part_entry_scheme": "dos",
|
|
||||||
"part_entry_type": "0x83",
|
|
||||||
"part_entry_flags": "0x80",
|
|
||||||
"part_entry_number": "1",
|
|
||||||
"part_entry_offset": "2048",
|
|
||||||
"part_entry_size": "2097152",
|
|
||||||
"part_entry_disk": "8:0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.blkid.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.cksum"></a>
|
||||||
|
|
||||||
# jc.parsers.cksum
|
# jc.parsers.cksum
|
||||||
|
|
||||||
jc - JSON CLI output utility `cksum` command output parser
|
jc - JSON CLI output utility `cksum` command output parser
|
||||||
|
|
||||||
This parser works with the following checksum calculation utilities:
|
This parser works with the following checksum calculation utilities:
|
||||||
@ -9,77 +11,87 @@ This parser works with the following checksum calculation utilities:
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cksum file.txt | jc --cksum
|
$ cksum file.txt | jc --cksum
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc cksum file.txt
|
$ jc cksum file.txt
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('cksum', cksum_command_output)
|
result = jc.parse('cksum', cksum_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.cksum
|
import jc.parsers.cksum
|
||||||
result = jc.parsers.cksum.parse(cksum_command_output)
|
result = jc.parsers.cksum.parse(cksum_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": string,
|
"filename": string,
|
||||||
"checksum": integer,
|
"checksum": integer,
|
||||||
"blocks": integer
|
"blocks": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cksum * | jc --cksum -p
|
|
||||||
[
|
$ cksum * | jc --cksum -p
|
||||||
{
|
[
|
||||||
"filename": "__init__.py",
|
{
|
||||||
"checksum": 4294967295,
|
- `"filename"` - "__init__.py",
|
||||||
"blocks": 0
|
- `"checksum"` - 4294967295,
|
||||||
},
|
- `"blocks"` - 0
|
||||||
{
|
},
|
||||||
"filename": "airport.py",
|
{
|
||||||
"checksum": 2208551092,
|
- `"filename"` - "airport.py",
|
||||||
"blocks": 3745
|
- `"checksum"` - 2208551092,
|
||||||
},
|
- `"blocks"` - 3745
|
||||||
{
|
},
|
||||||
"filename": "airport_s.py",
|
{
|
||||||
"checksum": 1113817598,
|
- `"filename"` - "airport_s.py",
|
||||||
"blocks": 4572
|
- `"checksum"` - 1113817598,
|
||||||
},
|
- `"blocks"` - 4572
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.cksum.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.cksum.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.crontab"></a>
|
||||||
|
|
||||||
# jc.parsers.crontab
|
# jc.parsers.crontab
|
||||||
|
|
||||||
jc - JSON CLI output utility `crontab -l` command output and crontab
|
jc - JSON CLI output utility `crontab -l` command output and crontab
|
||||||
file parser
|
file parser
|
||||||
|
|
||||||
@ -8,197 +10,207 @@ Supports `crontab -l` command output and crontab files.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ crontab -l | jc --crontab
|
$ crontab -l | jc --crontab
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc crontab -l
|
$ jc crontab -l
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('crontab', crontab_output)
|
result = jc.parse('crontab', crontab_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.crontab
|
import jc.parsers.crontab
|
||||||
result = jc.parsers.crontab.parse(crontab_output)
|
result = jc.parsers.crontab.parse(crontab_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"schedule": [
|
"schedule": [
|
||||||
{
|
{
|
||||||
"occurrence" string,
|
"occurrence" string,
|
||||||
"minute": [
|
"minute": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"hour": [
|
"hour": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"day_of_month": [
|
"day_of_month": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"month": [
|
"month": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"day_of_week": [
|
"day_of_week": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"occurrence": string,
|
"occurrence": string,
|
||||||
"command": string
|
"command": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ crontab -l | jc --crontab -p
|
|
||||||
{
|
$ crontab -l | jc --crontab -p
|
||||||
"variables": [
|
{
|
||||||
{
|
- `"variables"` - [
|
||||||
"name": "MAILTO",
|
{
|
||||||
"value": "root"
|
- `"name"` - "MAILTO",
|
||||||
},
|
- `"value"` - "root"
|
||||||
{
|
},
|
||||||
"name": "PATH",
|
{
|
||||||
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
|
- `"name"` - "PATH",
|
||||||
},
|
- `"value"` - "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||||
{
|
},
|
||||||
"name": "SHELL",
|
{
|
||||||
"value": "/bin/bash"
|
- `"name"` - "SHELL",
|
||||||
}
|
- `"value"` - "/bin/bash"
|
||||||
],
|
}
|
||||||
"schedule": [
|
],
|
||||||
{
|
- `"schedule"` - [
|
||||||
"minute": [
|
{
|
||||||
"5"
|
- `"minute"` - [
|
||||||
],
|
"5"
|
||||||
"hour": [
|
],
|
||||||
"10-11",
|
- `"hour"` - [
|
||||||
"22"
|
"10-11",
|
||||||
],
|
"22"
|
||||||
"day_of_month": [
|
],
|
||||||
"*"
|
- `"day_of_month"` - [
|
||||||
],
|
"*"
|
||||||
"month": [
|
],
|
||||||
"*"
|
- `"month"` - [
|
||||||
],
|
"*"
|
||||||
"day_of_week": [
|
],
|
||||||
"*"
|
- `"day_of_week"` - [
|
||||||
],
|
"*"
|
||||||
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
|
],
|
||||||
},
|
- `"command"` - "/var/www/devdaily.com/bin/mk-new-links.php"
|
||||||
{
|
},
|
||||||
"minute": [
|
{
|
||||||
"30"
|
- `"minute"` - [
|
||||||
],
|
"30"
|
||||||
"hour": [
|
],
|
||||||
"4/2"
|
- `"hour"` - [
|
||||||
],
|
"4/2"
|
||||||
"day_of_month": [
|
],
|
||||||
"*"
|
- `"day_of_month"` - [
|
||||||
],
|
"*"
|
||||||
"month": [
|
],
|
||||||
"*"
|
- `"month"` - [
|
||||||
],
|
"*"
|
||||||
"day_of_week": [
|
],
|
||||||
"*"
|
- `"day_of_week"` - [
|
||||||
],
|
"*"
|
||||||
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
|
],
|
||||||
},
|
- `"command"` - "/var/www/devdaily.com/bin/create-all-backups.sh"
|
||||||
{
|
},
|
||||||
"occurrence": "yearly",
|
{
|
||||||
"command": "/home/maverick/bin/annual-maintenance"
|
- `"occurrence"` - "yearly",
|
||||||
},
|
- `"command"` - "/home/maverick/bin/annual-maintenance"
|
||||||
{
|
},
|
||||||
"occurrence": "reboot",
|
{
|
||||||
"command": "/home/cleanup"
|
- `"occurrence"` - "reboot",
|
||||||
},
|
- `"command"` - "/home/cleanup"
|
||||||
{
|
},
|
||||||
"occurrence": "monthly",
|
{
|
||||||
"command": "/home/maverick/bin/tape-backup"
|
- `"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
$ cat /etc/crontab | jc --crontab -p -r
|
<a id="jc.parsers.crontab.info"></a>
|
||||||
{
|
|
||||||
"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 Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.crontab.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.crontab_u"></a>
|
||||||
|
|
||||||
|
# jc.parsers.crontab\_u
|
||||||
|
|
||||||
# jc.parsers.crontab_u
|
|
||||||
jc - JSON CLI output utility `crontab -l` command output and crontab
|
jc - JSON CLI output utility `crontab -l` command output and crontab
|
||||||
file parser
|
file parser
|
||||||
|
|
||||||
@ -9,193 +11,203 @@ information for processes.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ crontab -l | jc --crontab-u
|
$ crontab -l | jc --crontab-u
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('crontab_u', crontab_u_output)
|
result = jc.parse('crontab_u', crontab_u_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.crontab_u
|
import jc.parsers.crontab_u
|
||||||
result = jc.parsers.crontab_u.parse(crontab_u_output)
|
result = jc.parsers.crontab_u.parse(crontab_u_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"schedule": [
|
"schedule": [
|
||||||
{
|
{
|
||||||
"occurrence" string,
|
"occurrence" string,
|
||||||
"minute": [
|
"minute": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"hour": [
|
"hour": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"day_of_month": [
|
"day_of_month": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"month": [
|
"month": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"day_of_week": [
|
"day_of_week": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"occurrence": string,
|
"occurrence": string,
|
||||||
"user": string,
|
"user": string,
|
||||||
"command": string
|
"command": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat /etc/crontab | jc --crontab-u -p
|
|
||||||
{
|
$ cat /etc/crontab | jc --crontab-u -p
|
||||||
"variables": [
|
{
|
||||||
{
|
- `"variables"` - [
|
||||||
"name": "PATH",
|
{
|
||||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..."
|
- `"name"` - "PATH",
|
||||||
},
|
- `"value"` - "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..."
|
||||||
{
|
},
|
||||||
"name": "SHELL",
|
{
|
||||||
"value": "/bin/sh"
|
- `"name"` - "SHELL",
|
||||||
}
|
- `"value"` - "/bin/sh"
|
||||||
],
|
}
|
||||||
"schedule": [
|
],
|
||||||
{
|
- `"schedule"` - [
|
||||||
"minute": [
|
{
|
||||||
"25"
|
- `"minute"` - [
|
||||||
],
|
"25"
|
||||||
"hour": [
|
],
|
||||||
"6"
|
- `"hour"` - [
|
||||||
],
|
"6"
|
||||||
"day_of_month": [
|
],
|
||||||
"*"
|
- `"day_of_month"` - [
|
||||||
],
|
"*"
|
||||||
"month": [
|
],
|
||||||
"*"
|
- `"month"` - [
|
||||||
],
|
"*"
|
||||||
"day_of_week": [
|
],
|
||||||
"*"
|
- `"day_of_week"` - [
|
||||||
],
|
"*"
|
||||||
"user": "root",
|
],
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
- `"user"` - "root",
|
||||||
},
|
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
{
|
},
|
||||||
"minute": [
|
{
|
||||||
"47"
|
- `"minute"` - [
|
||||||
],
|
"47"
|
||||||
"hour": [
|
],
|
||||||
"6"
|
- `"hour"` - [
|
||||||
],
|
"6"
|
||||||
"day_of_month": [
|
],
|
||||||
"*"
|
- `"day_of_month"` - [
|
||||||
],
|
"*"
|
||||||
"month": [
|
],
|
||||||
"*"
|
- `"month"` - [
|
||||||
],
|
"*"
|
||||||
"day_of_week": [
|
],
|
||||||
"7"
|
- `"day_of_week"` - [
|
||||||
],
|
"7"
|
||||||
"user": "root",
|
],
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
- `"user"` - "root",
|
||||||
},
|
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
{
|
},
|
||||||
"minute": [
|
{
|
||||||
"52"
|
- `"minute"` - [
|
||||||
],
|
"52"
|
||||||
"hour": [
|
],
|
||||||
"6"
|
- `"hour"` - [
|
||||||
],
|
"6"
|
||||||
"day_of_month": [
|
],
|
||||||
"1"
|
- `"day_of_month"` - [
|
||||||
],
|
"1"
|
||||||
"month": [
|
],
|
||||||
"*"
|
- `"month"` - [
|
||||||
],
|
"*"
|
||||||
"day_of_week": [
|
],
|
||||||
"*"
|
- `"day_of_week"` - [
|
||||||
],
|
"*"
|
||||||
"user": "root",
|
],
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
- `"user"` - "root",
|
||||||
}
|
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ cat /etc/crontab | jc --crontab-u -p -r
|
||||||
|
{
|
||||||
|
- `"variables"` - [
|
||||||
|
{
|
||||||
|
- `"name"` - "PATH",
|
||||||
|
- `"value"` - "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "SHELL",
|
||||||
|
- `"value"` - "/bin/sh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"schedule"` - [
|
||||||
|
{
|
||||||
|
- `"minute"` - "25",
|
||||||
|
- `"hour"` - "6",
|
||||||
|
- `"day_of_month"` - "*",
|
||||||
|
- `"month"` - "*",
|
||||||
|
- `"day_of_week"` - "*",
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"minute"` - "47",
|
||||||
|
- `"hour"` - "6",
|
||||||
|
- `"day_of_month"` - "*",
|
||||||
|
- `"month"` - "*",
|
||||||
|
- `"day_of_week"` - "7",
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"minute"` - "52",
|
||||||
|
- `"hour"` - "6",
|
||||||
|
- `"day_of_month"` - "1",
|
||||||
|
- `"month"` - "*",
|
||||||
|
- `"day_of_week"` - "*",
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
$ cat /etc/crontab | jc --crontab-u -p -r
|
<a id="jc.parsers.crontab_u.info"></a>
|
||||||
{
|
|
||||||
"variables": [
|
|
||||||
{
|
|
||||||
"name": "PATH",
|
|
||||||
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SHELL",
|
|
||||||
"value": "/bin/sh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"schedule": [
|
|
||||||
{
|
|
||||||
"minute": "25",
|
|
||||||
"hour": "6",
|
|
||||||
"day_of_month": "*",
|
|
||||||
"month": "*",
|
|
||||||
"day_of_week": "*",
|
|
||||||
"user": "root",
|
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"minute": "47",
|
|
||||||
"hour": "6",
|
|
||||||
"day_of_month": "*",
|
|
||||||
"month": "*",
|
|
||||||
"day_of_week": "7",
|
|
||||||
"user": "root",
|
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"minute": "52",
|
|
||||||
"hour": "6",
|
|
||||||
"day_of_month": "1",
|
|
||||||
"month": "*",
|
|
||||||
"day_of_week": "*",
|
|
||||||
"user": "root",
|
|
||||||
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.crontab_u.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.csv"></a>
|
||||||
|
|
||||||
# jc.parsers.csv
|
# jc.parsers.csv
|
||||||
|
|
||||||
jc - JSON CLI output utility `csv` file parser
|
jc - JSON CLI output utility `csv` file parser
|
||||||
|
|
||||||
The `csv` parser will attempt to automatically detect the delimiter
|
The `csv` parser will attempt to automatically detect the delimiter
|
||||||
@ -9,100 +11,110 @@ The first row of the file must be a header row.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat file.csv | jc --csv
|
$ cat file.csv | jc --csv
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('csv', csv_output)
|
result = jc.parse('csv', csv_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.csv
|
import jc.parsers.csv
|
||||||
result = jc.parsers.csv.parse(csv_output)
|
result = jc.parsers.csv.parse(csv_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
csv file converted to a Dictionary:
|
csv file converted to a Dictionary:
|
||||||
https://docs.python.org/3/library/csv.html
|
https://docs.python.org/3/library/csv.html
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"column_name1": string,
|
"column_name1": string,
|
||||||
"column_name2": string
|
"column_name2": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat homes.csv
|
|
||||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
$ cat homes.csv
|
||||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
||||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||||
...
|
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||||
|
...
|
||||||
|
|
||||||
|
$ cat homes.csv | jc --csv -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"Sell"` - "142",
|
||||||
|
- `"List"` - "160",
|
||||||
|
- `"Living"` - "28",
|
||||||
|
- `"Rooms"` - "10",
|
||||||
|
- `"Beds"` - "5",
|
||||||
|
- `"Baths"` - "3",
|
||||||
|
- `"Age"` - "60",
|
||||||
|
- `"Acres"` - "0.28",
|
||||||
|
- `"Taxes"` - "3167"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"Sell"` - "175",
|
||||||
|
- `"List"` - "180",
|
||||||
|
- `"Living"` - "18",
|
||||||
|
- `"Rooms"` - "8",
|
||||||
|
- `"Beds"` - "4",
|
||||||
|
- `"Baths"` - "1",
|
||||||
|
- `"Age"` - "12",
|
||||||
|
- `"Acres"` - "0.43",
|
||||||
|
- `"Taxes"` - "4033"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"Sell"` - "129",
|
||||||
|
- `"List"` - "132",
|
||||||
|
- `"Living"` - "13",
|
||||||
|
- `"Rooms"` - "6",
|
||||||
|
- `"Beds"` - "3",
|
||||||
|
- `"Baths"` - "1",
|
||||||
|
- `"Age"` - "41",
|
||||||
|
- `"Acres"` - "0.33",
|
||||||
|
- `"Taxes"` - "1471"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ cat homes.csv | jc --csv -p
|
<a id="jc.parsers.csv.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"Sell": "142",
|
|
||||||
"List": "160",
|
|
||||||
"Living": "28",
|
|
||||||
"Rooms": "10",
|
|
||||||
"Beds": "5",
|
|
||||||
"Baths": "3",
|
|
||||||
"Age": "60",
|
|
||||||
"Acres": "0.28",
|
|
||||||
"Taxes": "3167"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Sell": "175",
|
|
||||||
"List": "180",
|
|
||||||
"Living": "18",
|
|
||||||
"Rooms": "8",
|
|
||||||
"Beds": "4",
|
|
||||||
"Baths": "1",
|
|
||||||
"Age": "12",
|
|
||||||
"Acres": "0.43",
|
|
||||||
"Taxes": "4033"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Sell": "129",
|
|
||||||
"List": "132",
|
|
||||||
"Living": "13",
|
|
||||||
"Rooms": "6",
|
|
||||||
"Beds": "3",
|
|
||||||
"Baths": "1",
|
|
||||||
"Age": "41",
|
|
||||||
"Acres": "0.33",
|
|
||||||
"Taxes": "1471"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.csv.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.csv_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.csv\_s
|
||||||
|
|
||||||
# jc.parsers.csv_s
|
|
||||||
jc - JSON CLI output utility `csv` file streaming parser
|
jc - JSON CLI output utility `csv` file streaming parser
|
||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
@ -14,88 +16,100 @@ then the rest of the rows are loaded lazily.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat file.csv | jc --csv-s
|
$ cat file.csv | jc --csv-s
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parse('csv_s', csv_output.splitlines())
|
result = jc.parse('csv_s', csv_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.csv_s
|
import jc.parsers.csv_s
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parsers.csv_s.parse(csv_output.splitlines())
|
result = jc.parsers.csv_s.parse(csv_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
csv file converted to a Dictionary:
|
csv file converted to a Dictionary:
|
||||||
https://docs.python.org/3/library/csv.html
|
https://docs.python.org/3/library/csv.html
|
||||||
|
|
||||||
{
|
{
|
||||||
"column_name1": string,
|
"column_name1": string,
|
||||||
"column_name2": string,
|
"column_name2": string,
|
||||||
|
|
||||||
# below object only exists if using -qq or ignore_exceptions=True
|
# below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
"_jc_meta":
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # false if error parsing
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat homes.csv
|
|
||||||
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
$ cat homes.csv
|
||||||
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
|
||||||
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
|
||||||
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
|
||||||
...
|
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
|
||||||
|
...
|
||||||
|
|
||||||
|
$ cat homes.csv | jc --csv-s
|
||||||
|
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...}
|
||||||
|
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...}
|
||||||
|
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...}
|
||||||
|
...
|
||||||
|
|
||||||
$ cat homes.csv | jc --csv-s
|
<a id="jc.parsers.csv_s.info"></a>
|
||||||
{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...}
|
|
||||||
{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...}
|
|
||||||
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...}
|
|
||||||
...
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.csv_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse
|
|
||||||
(e.g. sys.stdin or str.splitlines())
|
- `data` - (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
|
||||||
|
|
||||||
raw: (boolean) unprocessed output if True
|
**Yields**:
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
**Returns**:
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
Iterator object
|
||||||
Iterator object
|
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.date"></a>
|
||||||
|
|
||||||
# jc.parsers.date
|
# jc.parsers.date
|
||||||
|
|
||||||
jc - JSON CLI output utility `date` command output parser
|
jc - JSON CLI output utility `date` command output parser
|
||||||
|
|
||||||
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
||||||
@ -11,98 +13,108 @@ available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ date | jc --date
|
$ date | jc --date
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc date
|
$ jc date
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('date', date_command_output)
|
result = jc.parse('date', date_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.date
|
import jc.parsers.date
|
||||||
result = jc.parsers.date.parse(date_command_output)
|
result = jc.parsers.date.parse(date_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"year": integer,
|
"year": integer,
|
||||||
"month": string,
|
"month": string,
|
||||||
"month_num": integer,
|
"month_num": integer,
|
||||||
"day": integer,
|
"day": integer,
|
||||||
"weekday": string,
|
"weekday": string,
|
||||||
"weekday_num": integer,
|
"weekday_num": integer,
|
||||||
"hour": integer,
|
"hour": integer,
|
||||||
"hour_24": integer,
|
"hour_24": integer,
|
||||||
"minute": integer,
|
"minute": integer,
|
||||||
"second": integer,
|
"second": integer,
|
||||||
"period": string,
|
"period": string,
|
||||||
"timezone": string,
|
"timezone": string,
|
||||||
"utc_offset": string, # null if timezone field is not UTC
|
"utc_offset": string, # null if timezone field is not UTC
|
||||||
"day_of_year": integer,
|
"day_of_year": integer,
|
||||||
"week_of_year": integer,
|
"week_of_year": integer,
|
||||||
"iso": string,
|
"iso": string,
|
||||||
"epoch": integer, # [0]
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer, # [1]
|
"epoch_utc": integer, # [1]
|
||||||
"timezone_aware": boolean # [2]
|
"timezone_aware": boolean # [2]
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] naive timestamp
|
[0] naive timestamp
|
||||||
[1] timezone-aware timestamp. Only available if timezone field is UTC
|
[1] timezone-aware timestamp. Only available if timezone field is UTC
|
||||||
[2] if true, all fields are correctly based on UTC
|
[2] if true, all fields are correctly based on UTC
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ date | jc --date -p
|
|
||||||
{
|
$ date | jc --date -p
|
||||||
"year": 2021,
|
{
|
||||||
"month": "Mar",
|
- `"year"` - 2021,
|
||||||
"month_num": 3,
|
- `"month"` - "Mar",
|
||||||
"day": 25,
|
- `"month_num"` - 3,
|
||||||
"weekday": "Thu",
|
- `"day"` - 25,
|
||||||
"weekday_num": 4,
|
- `"weekday"` - "Thu",
|
||||||
"hour": 2,
|
- `"weekday_num"` - 4,
|
||||||
"hour_24": 2,
|
- `"hour"` - 2,
|
||||||
"minute": 2,
|
- `"hour_24"` - 2,
|
||||||
"second": 26,
|
- `"minute"` - 2,
|
||||||
"period": "AM",
|
- `"second"` - 26,
|
||||||
"timezone": "UTC",
|
- `"period"` - "AM",
|
||||||
"utc_offset": "+0000",
|
- `"timezone"` - "UTC",
|
||||||
"day_of_year": 84,
|
- `"utc_offset"` - "+0000",
|
||||||
"week_of_year": 12,
|
- `"day_of_year"` - 84,
|
||||||
"iso": "2021-03-25T02:02:26+00:00",
|
- `"week_of_year"` - 12,
|
||||||
"epoch": 1616662946,
|
- `"iso"` - "2021-03-25T02:02:26+00:00",
|
||||||
"epoch_utc": 1616637746,
|
- `"epoch"` - 1616662946,
|
||||||
"timezone_aware": true
|
- `"epoch_utc"` - 1616637746,
|
||||||
}
|
- `"timezone_aware"` - true
|
||||||
|
}
|
||||||
|
|
||||||
|
<a id="jc.parsers.date.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.date.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,128 +1,140 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.df"></a>
|
||||||
|
|
||||||
# jc.parsers.df
|
# jc.parsers.df
|
||||||
|
|
||||||
jc - JSON CLI output utility `df` command output parser
|
jc - JSON CLI output utility `df` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ df | jc --df
|
$ df | jc --df
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc df
|
$ jc df
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('df', df_command_output)
|
result = jc.parse('df', df_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.df
|
import jc.parsers.df
|
||||||
result = jc.parsers.df.parse(df_command_output)
|
result = jc.parsers.df.parse(df_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filesystem": string,
|
"filesystem": string,
|
||||||
"size": string,
|
"size": string,
|
||||||
"1k_blocks": integer,
|
"1k_blocks": integer,
|
||||||
"512_blocks": integer,
|
"512_blocks": integer,
|
||||||
"used": integer,
|
"used": integer,
|
||||||
"available": integer,
|
"available": integer,
|
||||||
"capacity_percent": integer,
|
"capacity_percent": integer,
|
||||||
"ifree": integer,
|
"ifree": integer,
|
||||||
"iused": integer,
|
"iused": integer,
|
||||||
"use_percent": integer,
|
"use_percent": integer,
|
||||||
"iused_percent": integer,
|
"iused_percent": integer,
|
||||||
"mounted_on": string
|
"mounted_on": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ df | jc --df -p
|
|
||||||
[
|
$ df | jc --df -p
|
||||||
{
|
[
|
||||||
"filesystem": "devtmpfs",
|
{
|
||||||
"1k_blocks": 1918820,
|
- `"filesystem"` - "devtmpfs",
|
||||||
"used": 0,
|
- `"1k_blocks"` - 1918820,
|
||||||
"available": 1918820,
|
- `"used"` - 0,
|
||||||
"use_percent": 0,
|
- `"available"` - 1918820,
|
||||||
"mounted_on": "/dev"
|
- `"use_percent"` - 0,
|
||||||
},
|
- `"mounted_on"` - "/dev"
|
||||||
{
|
},
|
||||||
"filesystem": "tmpfs",
|
{
|
||||||
"1k_blocks": 1930668,
|
- `"filesystem"` - "tmpfs",
|
||||||
"used": 0,
|
- `"1k_blocks"` - 1930668,
|
||||||
"available": 1930668,
|
- `"used"` - 0,
|
||||||
"use_percent": 0,
|
- `"available"` - 1930668,
|
||||||
"mounted_on": "/dev/shm"
|
- `"use_percent"` - 0,
|
||||||
},
|
- `"mounted_on"` - "/dev/shm"
|
||||||
{
|
},
|
||||||
"filesystem": "tmpfs",
|
{
|
||||||
"1k_blocks": 1930668,
|
- `"filesystem"` - "tmpfs",
|
||||||
"used": 11800,
|
- `"1k_blocks"` - 1930668,
|
||||||
"available": 1918868,
|
- `"used"` - 11800,
|
||||||
"use_percent": 1,
|
- `"available"` - 1918868,
|
||||||
"mounted_on": "/run"
|
- `"use_percent"` - 1,
|
||||||
},
|
- `"mounted_on"` - "/run"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ df | jc --df -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"filesystem"` - "devtmpfs",
|
||||||
|
- `"1k_blocks"` - "1918820",
|
||||||
|
- `"used"` - "0",
|
||||||
|
- `"available"` - "1918820",
|
||||||
|
- `"use_percent"` - "0%",
|
||||||
|
- `"mounted_on"` - "/dev"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"filesystem"` - "tmpfs",
|
||||||
|
- `"1k_blocks"` - "1930668",
|
||||||
|
- `"used"` - "0",
|
||||||
|
- `"available"` - "1930668",
|
||||||
|
- `"use_percent"` - "0%",
|
||||||
|
- `"mounted_on"` - "/dev/shm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"filesystem"` - "tmpfs",
|
||||||
|
- `"1k_blocks"` - "1930668",
|
||||||
|
- `"used"` - "11800",
|
||||||
|
- `"available"` - "1918868",
|
||||||
|
- `"use_percent"` - "1%",
|
||||||
|
- `"mounted_on"` - "/run"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ df | jc --df -p -r
|
<a id="jc.parsers.df.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"filesystem": "devtmpfs",
|
|
||||||
"1k_blocks": "1918820",
|
|
||||||
"used": "0",
|
|
||||||
"available": "1918820",
|
|
||||||
"use_percent": "0%",
|
|
||||||
"mounted_on": "/dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filesystem": "tmpfs",
|
|
||||||
"1k_blocks": "1930668",
|
|
||||||
"used": "0",
|
|
||||||
"available": "1930668",
|
|
||||||
"use_percent": "0%",
|
|
||||||
"mounted_on": "/dev/shm"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filesystem": "tmpfs",
|
|
||||||
"1k_blocks": "1930668",
|
|
||||||
"used": "11800",
|
|
||||||
"available": "1918868",
|
|
||||||
"use_percent": "1%",
|
|
||||||
"mounted_on": "/run"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.df.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.dig"></a>
|
||||||
|
|
||||||
# jc.parsers.dig
|
# jc.parsers.dig
|
||||||
|
|
||||||
jc - JSON CLI output utility `dig` command output parser
|
jc - JSON CLI output utility `dig` command output parser
|
||||||
|
|
||||||
Options supported:
|
Options supported:
|
||||||
- `+noall +answer` options are supported in cases where only the answer
|
- `+noall +answer` options are supported in cases where only the answer
|
||||||
information is desired.
|
information is desired.
|
||||||
- `+axfr` option is supported on its own
|
- `+axfr` option is supported on its own
|
||||||
|
|
||||||
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
|
The `when_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||||
@ -16,338 +18,348 @@ only available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ dig example.com | jc --dig
|
$ dig example.com | jc --dig
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc dig example.com
|
$ jc dig example.com
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('dig', dig_command_output)
|
result = jc.parse('dig', dig_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.dig
|
import jc.parsers.dig
|
||||||
result = jc.parsers.dig.parse(dig_command_output)
|
result = jc.parsers.dig.parse(dig_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"opcode": string,
|
"opcode": string,
|
||||||
"status": string,
|
"status": string,
|
||||||
"flags": [
|
"flags": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"query_num": integer,
|
"query_num": integer,
|
||||||
"answer_num": integer,
|
"answer_num": integer,
|
||||||
"authority_num": integer,
|
"authority_num": integer,
|
||||||
"additional_num": integer,
|
"additional_num": integer,
|
||||||
"axfr": [
|
"axfr": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"class": string,
|
"class": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"data": string
|
"data": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"opt_pseudosection": {
|
"opt_pseudosection": {
|
||||||
"edns": {
|
"edns": {
|
||||||
"version": integer,
|
"version": integer,
|
||||||
"flags": [
|
"flags": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"udp": integer
|
"udp": integer
|
||||||
},
|
},
|
||||||
"cookie": string
|
"cookie": string
|
||||||
},
|
},
|
||||||
"question": {
|
"question": {
|
||||||
"name": string,
|
"name": string,
|
||||||
"class": string,
|
"class": string,
|
||||||
"type": string
|
"type": string
|
||||||
},
|
},
|
||||||
"answer": [
|
"answer": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"class": string,
|
"class": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"data": string
|
"data": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"additional": [
|
"additional": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"class": string,
|
"class": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"data": string
|
"data": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"authority": [
|
"authority": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"class": string,
|
"class": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"data": string
|
"data": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query_size": integer,
|
"query_size": integer,
|
||||||
"query_time": integer, # in msec
|
"query_time": integer, # in msec
|
||||||
"server": string,
|
"server": string,
|
||||||
"when": string,
|
"when": string,
|
||||||
"when_epoch": integer, # [0]
|
"when_epoch": integer, # [0]
|
||||||
"when_epoch_utc": integer, # [1]
|
"when_epoch_utc": integer, # [1]
|
||||||
"rcvd": integer
|
"rcvd": integer
|
||||||
"size": string
|
"size": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] naive timestamp if "when" field is parsable, else null
|
[0] naive timestamp if "when" field is parsable, else null
|
||||||
[1] timezone aware timestamp availabe for UTC, else null
|
[1] timezone aware timestamp availabe for UTC, else null
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ dig example.com | jc --dig -p
|
|
||||||
[
|
$ dig example.com | jc --dig -p
|
||||||
{
|
[
|
||||||
"id": 2951,
|
{
|
||||||
"opcode": "QUERY",
|
- `"id"` - 2951,
|
||||||
"status": "NOERROR",
|
- `"opcode"` - "QUERY",
|
||||||
"flags": [
|
- `"status"` - "NOERROR",
|
||||||
"qr",
|
- `"flags"` - [
|
||||||
"rd",
|
"qr",
|
||||||
"ra"
|
"rd",
|
||||||
],
|
"ra"
|
||||||
"query_num": 1,
|
],
|
||||||
"answer_num": 1,
|
- `"query_num"` - 1,
|
||||||
"authority_num": 0,
|
- `"answer_num"` - 1,
|
||||||
"additional_num": 1,
|
- `"authority_num"` - 0,
|
||||||
"opt_pseudosection": {
|
- `"additional_num"` - 1,
|
||||||
"edns": {
|
- `"opt_pseudosection"` - {
|
||||||
"version": 0,
|
- `"edns"` - {
|
||||||
"flags": [],
|
- `"version"` - 0,
|
||||||
"udp": 4096
|
- `"flags"` - [],
|
||||||
}
|
- `"udp"` - 4096
|
||||||
},
|
}
|
||||||
"question": {
|
},
|
||||||
"name": "example.com.",
|
- `"question"` - {
|
||||||
"class": "IN",
|
- `"name"` - "example.com.",
|
||||||
"type": "A"
|
- `"class"` - "IN",
|
||||||
},
|
- `"type"` - "A"
|
||||||
"answer": [
|
},
|
||||||
{
|
- `"answer"` - [
|
||||||
"name": "example.com.",
|
{
|
||||||
"class": "IN",
|
- `"name"` - "example.com.",
|
||||||
"type": "A",
|
- `"class"` - "IN",
|
||||||
"ttl": 39302,
|
- `"type"` - "A",
|
||||||
"data": "93.184.216.34"
|
- `"ttl"` - 39302,
|
||||||
}
|
- `"data"` - "93.184.216.34"
|
||||||
],
|
}
|
||||||
"query_time": 49,
|
],
|
||||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
- `"query_time"` - 49,
|
||||||
"when": "Fri Apr 16 16:05:10 PDT 2021",
|
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||||
"rcvd": 56,
|
- `"when"` - "Fri Apr 16 16:05:10 PDT 2021",
|
||||||
"when_epoch": 1618614310,
|
- `"rcvd"` - 56,
|
||||||
"when_epoch_utc": null
|
- `"when_epoch"` - 1618614310,
|
||||||
}
|
- `"when_epoch_utc"` - null
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"id"` - "46052",
|
||||||
|
- `"opcode"` - "QUERY",
|
||||||
|
- `"status"` - "NOERROR",
|
||||||
|
- `"flags"` - [
|
||||||
|
"qr",
|
||||||
|
"rd",
|
||||||
|
"ra"
|
||||||
|
],
|
||||||
|
- `"query_num"` - "1",
|
||||||
|
- `"answer_num"` - "1",
|
||||||
|
- `"authority_num"` - "0",
|
||||||
|
- `"additional_num"` - "1",
|
||||||
|
- `"opt_pseudosection"` - {
|
||||||
|
- `"edns"` - {
|
||||||
|
- `"version"` - "0",
|
||||||
|
- `"flags"` - [],
|
||||||
|
- `"udp"` - "4096"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
- `"question"` - {
|
||||||
|
- `"name"` - "example.com.",
|
||||||
|
- `"class"` - "IN",
|
||||||
|
- `"type"` - "A"
|
||||||
|
},
|
||||||
|
- `"answer"` - [
|
||||||
|
{
|
||||||
|
- `"name"` - "example.com.",
|
||||||
|
- `"class"` - "IN",
|
||||||
|
- `"type"` - "A",
|
||||||
|
- `"ttl"` - "40426",
|
||||||
|
- `"data"` - "93.184.216.34"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"query_time"` - "48 msec",
|
||||||
|
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||||
|
- `"when"` - "Fri Apr 16 16:06:12 PDT 2021",
|
||||||
|
- `"rcvd"` - "56"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ dig -x 1.1.1.1 | jc --dig -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"id"` - 20785,
|
||||||
|
- `"opcode"` - "QUERY",
|
||||||
|
- `"status"` - "NOERROR",
|
||||||
|
- `"flags"` - [
|
||||||
|
"qr",
|
||||||
|
"rd",
|
||||||
|
"ra"
|
||||||
|
],
|
||||||
|
- `"query_num"` - 1,
|
||||||
|
- `"answer_num"` - 1,
|
||||||
|
- `"authority_num"` - 0,
|
||||||
|
- `"additional_num"` - 1,
|
||||||
|
- `"opt_pseudosection"` - {
|
||||||
|
- `"edns"` - {
|
||||||
|
- `"version"` - 0,
|
||||||
|
- `"flags"` - [],
|
||||||
|
- `"udp"` - 4096
|
||||||
|
}
|
||||||
|
},
|
||||||
|
- `"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"` - 40,
|
||||||
|
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||||
|
- `"when"` - "Sat Apr 17 14:50:50 PDT 2021",
|
||||||
|
- `"rcvd"` - 78,
|
||||||
|
- `"when_epoch"` - 1618696250,
|
||||||
|
- `"when_epoch_utc"` - null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ dig -x 1.1.1.1 | jc --dig -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"id"` - "32644",
|
||||||
|
- `"opcode"` - "QUERY",
|
||||||
|
- `"status"` - "NOERROR",
|
||||||
|
- `"flags"` - [
|
||||||
|
"qr",
|
||||||
|
"rd",
|
||||||
|
"ra"
|
||||||
|
],
|
||||||
|
- `"query_num"` - "1",
|
||||||
|
- `"answer_num"` - "1",
|
||||||
|
- `"authority_num"` - "0",
|
||||||
|
- `"additional_num"` - "1",
|
||||||
|
- `"opt_pseudosection"` - {
|
||||||
|
- `"edns"` - {
|
||||||
|
- `"version"` - "0",
|
||||||
|
- `"flags"` - [],
|
||||||
|
- `"udp"` - "4096"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
- `"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"` - "52 msec",
|
||||||
|
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
||||||
|
- `"when"` - "Sat Apr 17 14:51:46 PDT 2021",
|
||||||
|
- `"rcvd"` - "78"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ dig +noall +answer cnn.com | jc --dig -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"answer"` - [
|
||||||
|
{
|
||||||
|
- `"name"` - "cnn.com.",
|
||||||
|
- `"class"` - "IN",
|
||||||
|
- `"type"` - "A",
|
||||||
|
- `"ttl"` - 60,
|
||||||
|
- `"data"` - "151.101.193.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "cnn.com.",
|
||||||
|
- `"class"` - "IN",
|
||||||
|
- `"type"` - "A",
|
||||||
|
- `"ttl"` - 60,
|
||||||
|
- `"data"` - "151.101.65.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "cnn.com.",
|
||||||
|
- `"class"` - "IN",
|
||||||
|
- `"type"` - "A",
|
||||||
|
- `"ttl"` - 60,
|
||||||
|
- `"data"` - "151.101.1.67"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "cnn.com.",
|
||||||
|
- `"class"` - "IN",
|
||||||
|
- `"type"` - "A",
|
||||||
|
- `"ttl"` - 60,
|
||||||
|
- `"data"` - "151.101.129.67"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r
|
<a id="jc.parsers.dig.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": "46052",
|
|
||||||
"opcode": "QUERY",
|
|
||||||
"status": "NOERROR",
|
|
||||||
"flags": [
|
|
||||||
"qr",
|
|
||||||
"rd",
|
|
||||||
"ra"
|
|
||||||
],
|
|
||||||
"query_num": "1",
|
|
||||||
"answer_num": "1",
|
|
||||||
"authority_num": "0",
|
|
||||||
"additional_num": "1",
|
|
||||||
"opt_pseudosection": {
|
|
||||||
"edns": {
|
|
||||||
"version": "0",
|
|
||||||
"flags": [],
|
|
||||||
"udp": "4096"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"question": {
|
|
||||||
"name": "example.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A"
|
|
||||||
},
|
|
||||||
"answer": [
|
|
||||||
{
|
|
||||||
"name": "example.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A",
|
|
||||||
"ttl": "40426",
|
|
||||||
"data": "93.184.216.34"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"query_time": "48 msec",
|
|
||||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
|
||||||
"when": "Fri Apr 16 16:06:12 PDT 2021",
|
|
||||||
"rcvd": "56"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ dig -x 1.1.1.1 | jc --dig -p
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": 20785,
|
|
||||||
"opcode": "QUERY",
|
|
||||||
"status": "NOERROR",
|
|
||||||
"flags": [
|
|
||||||
"qr",
|
|
||||||
"rd",
|
|
||||||
"ra"
|
|
||||||
],
|
|
||||||
"query_num": 1,
|
|
||||||
"answer_num": 1,
|
|
||||||
"authority_num": 0,
|
|
||||||
"additional_num": 1,
|
|
||||||
"opt_pseudosection": {
|
|
||||||
"edns": {
|
|
||||||
"version": 0,
|
|
||||||
"flags": [],
|
|
||||||
"udp": 4096
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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": 40,
|
|
||||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
|
||||||
"when": "Sat Apr 17 14:50:50 PDT 2021",
|
|
||||||
"rcvd": 78,
|
|
||||||
"when_epoch": 1618696250,
|
|
||||||
"when_epoch_utc": null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ dig -x 1.1.1.1 | jc --dig -p -r
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": "32644",
|
|
||||||
"opcode": "QUERY",
|
|
||||||
"status": "NOERROR",
|
|
||||||
"flags": [
|
|
||||||
"qr",
|
|
||||||
"rd",
|
|
||||||
"ra"
|
|
||||||
],
|
|
||||||
"query_num": "1",
|
|
||||||
"answer_num": "1",
|
|
||||||
"authority_num": "0",
|
|
||||||
"additional_num": "1",
|
|
||||||
"opt_pseudosection": {
|
|
||||||
"edns": {
|
|
||||||
"version": "0",
|
|
||||||
"flags": [],
|
|
||||||
"udp": "4096"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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": "52 msec",
|
|
||||||
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
|
|
||||||
"when": "Sat Apr 17 14:51:46 PDT 2021",
|
|
||||||
"rcvd": "78"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ dig +noall +answer cnn.com | jc --dig -p
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"answer": [
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A",
|
|
||||||
"ttl": 60,
|
|
||||||
"data": "151.101.193.67"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A",
|
|
||||||
"ttl": 60,
|
|
||||||
"data": "151.101.65.67"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A",
|
|
||||||
"ttl": 60,
|
|
||||||
"data": "151.101.1.67"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cnn.com.",
|
|
||||||
"class": "IN",
|
|
||||||
"type": "A",
|
|
||||||
"ttl": 60,
|
|
||||||
"data": "151.101.129.67"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.dig.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.dir"></a>
|
||||||
|
|
||||||
# jc.parsers.dir
|
# jc.parsers.dir
|
||||||
|
|
||||||
jc - JSON CLI output utility `dir` command output parser
|
jc - JSON CLI output utility `dir` command output parser
|
||||||
|
|
||||||
Options supported:
|
Options supported:
|
||||||
@ -17,135 +19,145 @@ time of the system the parser is run on)
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
C:> dir | jc --dir
|
C:> dir | jc --dir
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('dir', dir_command_output)
|
result = jc.parse('dir', dir_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.dir
|
import jc.parsers.dir
|
||||||
result = jc.parsers.dir.parse(dir_command_output)
|
result = jc.parsers.dir.parse(dir_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"date": string,
|
"date": string,
|
||||||
"time": string,
|
"time": string,
|
||||||
"epoch": integer, # naive timestamp
|
"epoch": integer, # naive timestamp
|
||||||
"dir": boolean,
|
"dir": boolean,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"filename: string,
|
"filename: string,
|
||||||
"parent": string
|
"parent": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
C:> dir | jc --dir -p
|
|
||||||
[
|
C:> dir | jc --dir -p
|
||||||
{
|
[
|
||||||
"date": "03/24/2021",
|
{
|
||||||
"time": "03:15 PM",
|
- `"date"` - "03/24/2021",
|
||||||
"dir": true,
|
- `"time"` - "03:15 PM",
|
||||||
"size": null,
|
- `"dir"` - true,
|
||||||
"filename": ".",
|
- `"size"` - null,
|
||||||
"parent": "C:\Program Files\Internet Explorer",
|
- `"filename"` - ".",
|
||||||
"epoch": 1616624100
|
- `"parent"` - "C:\\Program Files\\Internet Explorer",
|
||||||
},
|
- `"epoch"` - 1616624100
|
||||||
{
|
},
|
||||||
"date": "03/24/2021",
|
{
|
||||||
"time": "03:15 PM",
|
- `"date"` - "03/24/2021",
|
||||||
"dir": true,
|
- `"time"` - "03:15 PM",
|
||||||
"size": null,
|
- `"dir"` - true,
|
||||||
"filename": "..",
|
- `"size"` - null,
|
||||||
"parent": "C:\Program Files\Internet Explorer",
|
- `"filename"` - "..",
|
||||||
"epoch": 1616624100
|
- `"parent"` - "C:\\Program Files\\Internet Explorer",
|
||||||
},
|
- `"epoch"` - 1616624100
|
||||||
{
|
},
|
||||||
"date": "12/07/2019",
|
{
|
||||||
"time": "02:49 AM",
|
- `"date"` - "12/07/2019",
|
||||||
"dir": true,
|
- `"time"` - "02:49 AM",
|
||||||
"size": null,
|
- `"dir"` - true,
|
||||||
"filename": "en-US",
|
- `"size"` - null,
|
||||||
"parent": "C:\Program Files\Internet Explorer",
|
- `"filename"` - "en-US",
|
||||||
"epoch": 1575715740
|
- `"parent"` - "C:\\Program Files\\Internet Explorer",
|
||||||
},
|
- `"epoch"` - 1575715740
|
||||||
{
|
},
|
||||||
"date": "12/07/2019",
|
{
|
||||||
"time": "02:09 AM",
|
- `"date"` - "12/07/2019",
|
||||||
"dir": false,
|
- `"time"` - "02:09 AM",
|
||||||
"size": 54784,
|
- `"dir"` - false,
|
||||||
"filename": "ExtExport.exe",
|
- `"size"` - 54784,
|
||||||
"parent": "C:\Program Files\Internet Explorer",
|
- `"filename"` - "ExtExport.exe",
|
||||||
"epoch": 1575713340
|
- `"parent"` - "C:\\Program Files\\Internet Explorer",
|
||||||
},
|
- `"epoch"` - 1575713340
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
C:> dir | jc --dir -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"date"` - "03/24/2021",
|
||||||
|
- `"time"` - "03:15 PM",
|
||||||
|
- `"dir"` - true,
|
||||||
|
- `"size"` - null,
|
||||||
|
- `"filename"` - ".",
|
||||||
|
- `"parent"` - "C:\\Program Files\\Internet Explorer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"date"` - "03/24/2021",
|
||||||
|
- `"time"` - "03:15 PM",
|
||||||
|
- `"dir"` - true,
|
||||||
|
- `"size"` - null,
|
||||||
|
- `"filename"` - "..",
|
||||||
|
- `"parent"` - "C:\\Program Files\\Internet Explorer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"date"` - "12/07/2019",
|
||||||
|
- `"time"` - "02:49 AM",
|
||||||
|
- `"dir"` - true,
|
||||||
|
- `"size"` - null,
|
||||||
|
- `"filename"` - "en-US",
|
||||||
|
- `"parent"` - "C:\\Program Files\\Internet Explorer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"date"` - "12/07/2019",
|
||||||
|
- `"time"` - "02:09 AM",
|
||||||
|
- `"dir"` - false,
|
||||||
|
- `"size"` - "54,784",
|
||||||
|
- `"filename"` - "ExtExport.exe",
|
||||||
|
- `"parent"` - "C:\\Program Files\\Internet Explorer"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
C:> dir | jc --dir -p -r
|
<a id="jc.parsers.dir.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"date": "03/24/2021",
|
|
||||||
"time": "03:15 PM",
|
|
||||||
"dir": true,
|
|
||||||
"size": null,
|
|
||||||
"filename": ".",
|
|
||||||
"parent": "C:\Program Files\Internet Explorer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"date": "03/24/2021",
|
|
||||||
"time": "03:15 PM",
|
|
||||||
"dir": true,
|
|
||||||
"size": null,
|
|
||||||
"filename": "..",
|
|
||||||
"parent": "C:\Program Files\Internet Explorer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"date": "12/07/2019",
|
|
||||||
"time": "02:49 AM",
|
|
||||||
"dir": true,
|
|
||||||
"size": null,
|
|
||||||
"filename": "en-US",
|
|
||||||
"parent": "C:\Program Files\Internet Explorer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"date": "12/07/2019",
|
|
||||||
"time": "02:09 AM",
|
|
||||||
"dir": false,
|
|
||||||
"size": "54,784",
|
|
||||||
"filename": "ExtExport.exe",
|
|
||||||
"parent": "C:\Program Files\Internet Explorer"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.dir.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: win32
|
Compatibility: win32
|
||||||
|
@ -1,156 +1,168 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.dmidecode"></a>
|
||||||
|
|
||||||
# jc.parsers.dmidecode
|
# jc.parsers.dmidecode
|
||||||
|
|
||||||
jc - JSON CLI output utility `dmidecode` command output parser
|
jc - JSON CLI output utility `dmidecode` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ dmidecode | jc --dmidecode
|
$ dmidecode | jc --dmidecode
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc dmidecode
|
$ jc dmidecode
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('dmidecode', dmidecode_command_output)
|
result = jc.parse('dmidecode', dmidecode_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.dmidecode
|
import jc.parsers.dmidecode
|
||||||
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
|
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"handle": string,
|
"handle": string,
|
||||||
"type": integer,
|
"type": integer,
|
||||||
"bytes": integer,
|
"bytes": integer,
|
||||||
"description": string,
|
"description": string,
|
||||||
"values": { # null if empty
|
"values": { # null if empty
|
||||||
"lowercase_no_spaces_keys": string,
|
"lowercase_no_spaces_keys": string,
|
||||||
"multiline_key_values": [
|
"multiline_key_values": [
|
||||||
string,
|
string,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
# dmidecode | jc --dmidecode -p
|
|
||||||
[
|
# dmidecode | jc --dmidecode -p
|
||||||
{
|
[
|
||||||
"handle": "0x0000",
|
{
|
||||||
"type": 0,
|
- `"handle"` - "0x0000",
|
||||||
"bytes": 24,
|
- `"type"` - 0,
|
||||||
"description": "BIOS Information",
|
- `"bytes"` - 24,
|
||||||
"values": {
|
- `"description"` - "BIOS Information",
|
||||||
"vendor": "Phoenix Technologies LTD",
|
- `"values"` - {
|
||||||
"version": "6.00",
|
- `"vendor"` - "Phoenix Technologies LTD",
|
||||||
"release_date": "04/13/2018",
|
- `"version"` - "6.00",
|
||||||
"address": "0xEA490",
|
- `"release_date"` - "04/13/2018",
|
||||||
"runtime_size": "88944 bytes",
|
- `"address"` - "0xEA490",
|
||||||
"rom_size": "64 kB",
|
- `"runtime_size"` - "88944 bytes",
|
||||||
"characteristics": [
|
- `"rom_size"` - "64 kB",
|
||||||
"ISA is supported",
|
- `"characteristics"` - [
|
||||||
"PCI is supported",
|
"ISA is supported",
|
||||||
"PC Card (PCMCIA) is supported",
|
"PCI is supported",
|
||||||
"PNP is supported",
|
"PC Card (PCMCIA) is supported",
|
||||||
"APM is supported",
|
"PNP is supported",
|
||||||
"BIOS is upgradeable",
|
"APM is supported",
|
||||||
"BIOS shadowing is allowed",
|
"BIOS is upgradeable",
|
||||||
"ESCD support is available",
|
"BIOS shadowing is allowed",
|
||||||
"Boot from CD is supported",
|
"ESCD support is available",
|
||||||
"Selectable boot is supported",
|
"Boot from CD is supported",
|
||||||
"EDD is supported",
|
"Selectable boot is supported",
|
||||||
"Print screen service is supported (int 5h)",
|
"EDD is supported",
|
||||||
"8042 keyboard services are supported (int 9h)",
|
"Print screen service is supported (int 5h)",
|
||||||
"Serial services are supported (int 14h)",
|
"8042 keyboard services are supported (int 9h)",
|
||||||
"Printer services are supported (int 17h)",
|
"Serial services are supported (int 14h)",
|
||||||
"CGA/mono video services are supported (int 10h)",
|
"Printer services are supported (int 17h)",
|
||||||
"ACPI is supported",
|
"CGA/mono video services are supported (int 10h)",
|
||||||
"Smart battery is supported",
|
"ACPI is supported",
|
||||||
"BIOS boot specification is supported",
|
"Smart battery is supported",
|
||||||
"Function key-initiated network boot is supported",
|
"BIOS boot specification is supported",
|
||||||
"Targeted content distribution is supported"
|
"Function key-initiated network boot is supported",
|
||||||
],
|
"Targeted content distribution is supported"
|
||||||
"bios_revision": "4.6",
|
],
|
||||||
"firmware_revision": "0.0"
|
- `"bios_revision"` - "4.6",
|
||||||
}
|
- `"firmware_revision"` - "0.0"
|
||||||
},
|
}
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
# dmidecode | jc --dmidecode -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"handle"` - "0x0000",
|
||||||
|
- `"type"` - "0",
|
||||||
|
- `"bytes"` - "24",
|
||||||
|
- `"description"` - "BIOS Information",
|
||||||
|
- `"values"` - {
|
||||||
|
- `"vendor"` - "Phoenix Technologies LTD",
|
||||||
|
- `"version"` - "6.00",
|
||||||
|
- `"release_date"` - "04/13/2018",
|
||||||
|
- `"address"` - "0xEA490",
|
||||||
|
- `"runtime_size"` - "88944 bytes",
|
||||||
|
- `"rom_size"` - "64 kB",
|
||||||
|
- `"characteristics"` - [
|
||||||
|
"ISA is supported",
|
||||||
|
"PCI is supported",
|
||||||
|
"PC Card (PCMCIA) is supported",
|
||||||
|
"PNP is supported",
|
||||||
|
"APM is supported",
|
||||||
|
"BIOS is upgradeable",
|
||||||
|
"BIOS shadowing is allowed",
|
||||||
|
"ESCD support is available",
|
||||||
|
"Boot from CD is supported",
|
||||||
|
"Selectable boot is supported",
|
||||||
|
"EDD is supported",
|
||||||
|
"Print screen service is supported (int 5h)",
|
||||||
|
"8042 keyboard services are supported (int 9h)",
|
||||||
|
"Serial services are supported (int 14h)",
|
||||||
|
"Printer services are supported (int 17h)",
|
||||||
|
"CGA/mono video services are supported (int 10h)",
|
||||||
|
"ACPI is supported",
|
||||||
|
"Smart battery is supported",
|
||||||
|
"BIOS boot specification is supported",
|
||||||
|
"Function key-initiated network boot is supported",
|
||||||
|
"Targeted content distribution is supported"
|
||||||
|
],
|
||||||
|
- `"bios_revision"` - "4.6",
|
||||||
|
- `"firmware_revision"` - "0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
# dmidecode | jc --dmidecode -p -r
|
<a id="jc.parsers.dmidecode.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"handle": "0x0000",
|
|
||||||
"type": "0",
|
|
||||||
"bytes": "24",
|
|
||||||
"description": "BIOS Information",
|
|
||||||
"values": {
|
|
||||||
"vendor": "Phoenix Technologies LTD",
|
|
||||||
"version": "6.00",
|
|
||||||
"release_date": "04/13/2018",
|
|
||||||
"address": "0xEA490",
|
|
||||||
"runtime_size": "88944 bytes",
|
|
||||||
"rom_size": "64 kB",
|
|
||||||
"characteristics": [
|
|
||||||
"ISA is supported",
|
|
||||||
"PCI is supported",
|
|
||||||
"PC Card (PCMCIA) is supported",
|
|
||||||
"PNP is supported",
|
|
||||||
"APM is supported",
|
|
||||||
"BIOS is upgradeable",
|
|
||||||
"BIOS shadowing is allowed",
|
|
||||||
"ESCD support is available",
|
|
||||||
"Boot from CD is supported",
|
|
||||||
"Selectable boot is supported",
|
|
||||||
"EDD is supported",
|
|
||||||
"Print screen service is supported (int 5h)",
|
|
||||||
"8042 keyboard services are supported (int 9h)",
|
|
||||||
"Serial services are supported (int 14h)",
|
|
||||||
"Printer services are supported (int 17h)",
|
|
||||||
"CGA/mono video services are supported (int 10h)",
|
|
||||||
"ACPI is supported",
|
|
||||||
"Smart battery is supported",
|
|
||||||
"BIOS boot specification is supported",
|
|
||||||
"Function key-initiated network boot is supported",
|
|
||||||
"Targeted content distribution is supported"
|
|
||||||
],
|
|
||||||
"bios_revision": "4.6",
|
|
||||||
"firmware_revision": "0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.dmidecode.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,162 +1,174 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.dpkg_l"></a>
|
||||||
|
|
||||||
|
# jc.parsers.dpkg\_l
|
||||||
|
|
||||||
# jc.parsers.dpkg_l
|
|
||||||
jc - JSON CLI output utility `dpkg -l` command output parser
|
jc - JSON CLI output utility `dpkg -l` command output parser
|
||||||
|
|
||||||
Set the `COLUMNS` environment variable to a large value to avoid field
|
Set the `COLUMNS` environment variable to a large value to avoid field
|
||||||
truncation. For example:
|
truncation. For example:
|
||||||
|
|
||||||
$ COLUMNS=500 dpkg -l | jc --dpkg-l
|
$ COLUMNS=500 dpkg -l | jc --dpkg-l
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ dpkg -l | jc --dpkg-l
|
$ dpkg -l | jc --dpkg-l
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc dpkg -l
|
$ jc dpkg -l
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('dpkg_l', dpkg_command_output)
|
result = jc.parse('dpkg_l', dpkg_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.dpkg_l
|
import jc.parsers.dpkg_l
|
||||||
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
|
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"codes": string,
|
"codes": string,
|
||||||
"name": string,
|
"name": string,
|
||||||
"version": string,
|
"version": string,
|
||||||
"architecture": string,
|
"architecture": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"desired": string,
|
"desired": string,
|
||||||
"status": string,
|
"status": string,
|
||||||
"error": string
|
"error": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ dpkg -l | jc --dpkg-l -p
|
|
||||||
[
|
$ dpkg -l | jc --dpkg-l -p
|
||||||
{
|
[
|
||||||
"codes": "ii",
|
{
|
||||||
"name": "accountsservice",
|
- `"codes"` - "ii",
|
||||||
"version": "0.6.45-1ubuntu1.3",
|
- `"name"` - "accountsservice",
|
||||||
"architecture": "amd64",
|
- `"version"` - "0.6.45-1ubuntu1.3",
|
||||||
"description": "query and manipulate user account information",
|
- `"architecture"` - "amd64",
|
||||||
"desired": "install",
|
- `"description"` - "query and manipulate user account information",
|
||||||
"status": "installed"
|
- `"desired"` - "install",
|
||||||
},
|
- `"status"` - "installed"
|
||||||
{
|
},
|
||||||
"codes": "rc",
|
{
|
||||||
"name": "acl",
|
- `"codes"` - "rc",
|
||||||
"version": "2.2.52-3build1",
|
- `"name"` - "acl",
|
||||||
"architecture": "amd64",
|
- `"version"` - "2.2.52-3build1",
|
||||||
"description": "Access control list utilities",
|
- `"architecture"` - "amd64",
|
||||||
"desired": "remove",
|
- `"description"` - "Access control list utilities",
|
||||||
"status": "config-files"
|
- `"desired"` - "remove",
|
||||||
},
|
- `"status"` - "config-files"
|
||||||
{
|
},
|
||||||
"codes": "uWR",
|
{
|
||||||
"name": "acpi",
|
- `"codes"` - "uWR",
|
||||||
"version": "1.7-1.1",
|
- `"name"` - "acpi",
|
||||||
"architecture": "amd64",
|
- `"version"` - "1.7-1.1",
|
||||||
"description": "displays information on ACPI devices",
|
- `"architecture"` - "amd64",
|
||||||
"desired": "unknown",
|
- `"description"` - "displays information on ACPI devices",
|
||||||
"status": "trigger await",
|
- `"desired"` - "unknown",
|
||||||
"error": "reinstall required"
|
- `"status"` - "trigger await",
|
||||||
},
|
- `"error"` - "reinstall required"
|
||||||
{
|
},
|
||||||
"codes": "rh",
|
{
|
||||||
"name": "acpid",
|
- `"codes"` - "rh",
|
||||||
"version": "1:2.0.28-1ubuntu1",
|
- `"name"` - "acpid",
|
||||||
"architecture": "amd64",
|
- `"version"` - "1:2.0.28-1ubuntu1",
|
||||||
"description": "Advanced Configuration and Power Interface...",
|
- `"architecture"` - "amd64",
|
||||||
"desired": "remove",
|
- `"description"` - "Advanced Configuration and Power Interface...",
|
||||||
"status": "half installed"
|
- `"desired"` - "remove",
|
||||||
},
|
- `"status"` - "half installed"
|
||||||
{
|
},
|
||||||
"codes": "pn",
|
{
|
||||||
"name": "adduser",
|
- `"codes"` - "pn",
|
||||||
"version": "3.116ubuntu1",
|
- `"name"` - "adduser",
|
||||||
"architecture": "all",
|
- `"version"` - "3.116ubuntu1",
|
||||||
"description": "add and remove users and groups",
|
- `"architecture"` - "all",
|
||||||
"desired": "purge",
|
- `"description"` - "add and remove users and groups",
|
||||||
"status": "not installed"
|
- `"desired"` - "purge",
|
||||||
},
|
- `"status"` - "not installed"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ dpkg -l | jc --dpkg-l -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"codes"` - "ii",
|
||||||
|
- `"name"` - "accountsservice",
|
||||||
|
- `"version"` - "0.6.45-1ubuntu1.3",
|
||||||
|
- `"architecture"` - "amd64",
|
||||||
|
- `"description"` - "query and manipulate user account information"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"codes"` - "rc",
|
||||||
|
- `"name"` - "acl",
|
||||||
|
- `"version"` - "2.2.52-3build1",
|
||||||
|
- `"architecture"` - "amd64",
|
||||||
|
- `"description"` - "Access control list utilities"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"codes"` - "uWR",
|
||||||
|
- `"name"` - "acpi",
|
||||||
|
- `"version"` - "1.7-1.1",
|
||||||
|
- `"architecture"` - "amd64",
|
||||||
|
- `"description"` - "displays information on ACPI devices"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"codes"` - "rh",
|
||||||
|
- `"name"` - "acpid",
|
||||||
|
- `"version"` - "1:2.0.28-1ubuntu1",
|
||||||
|
- `"architecture"` - "amd64",
|
||||||
|
- `"description"` - "Advanced Configuration and Power Interface..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"codes"` - "pn",
|
||||||
|
- `"name"` - "adduser",
|
||||||
|
- `"version"` - "3.116ubuntu1",
|
||||||
|
- `"architecture"` - "all",
|
||||||
|
- `"description"` - "add and remove users and groups"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ dpkg -l | jc --dpkg-l -p -r
|
<a id="jc.parsers.dpkg_l.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"codes": "ii",
|
|
||||||
"name": "accountsservice",
|
|
||||||
"version": "0.6.45-1ubuntu1.3",
|
|
||||||
"architecture": "amd64",
|
|
||||||
"description": "query and manipulate user account information"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"codes": "rc",
|
|
||||||
"name": "acl",
|
|
||||||
"version": "2.2.52-3build1",
|
|
||||||
"architecture": "amd64",
|
|
||||||
"description": "Access control list utilities"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"codes": "uWR",
|
|
||||||
"name": "acpi",
|
|
||||||
"version": "1.7-1.1",
|
|
||||||
"architecture": "amd64",
|
|
||||||
"description": "displays information on ACPI devices"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"codes": "rh",
|
|
||||||
"name": "acpid",
|
|
||||||
"version": "1:2.0.28-1ubuntu1",
|
|
||||||
"architecture": "amd64",
|
|
||||||
"description": "Advanced Configuration and Power Interface..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"codes": "pn",
|
|
||||||
"name": "adduser",
|
|
||||||
"version": "3.116ubuntu1",
|
|
||||||
"architecture": "all",
|
|
||||||
"description": "add and remove users and groups"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.dpkg_l.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,118 +1,130 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.du"></a>
|
||||||
|
|
||||||
# jc.parsers.du
|
# jc.parsers.du
|
||||||
|
|
||||||
jc - JSON CLI output utility `du` command output parser
|
jc - JSON CLI output utility `du` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ du | jc --du
|
$ du | jc --du
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc du
|
$ jc du
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('du', du_command_output)
|
result = jc.parse('du', du_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.du
|
import jc.parsers.du
|
||||||
result = jc.parsers.du.parse(du_command_output)
|
result = jc.parsers.du.parse(du_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"name": string
|
"name": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ du /usr | jc --du -p
|
|
||||||
[
|
$ du /usr | jc --du -p
|
||||||
{
|
[
|
||||||
"size": 104608,
|
{
|
||||||
"name": "/usr/bin"
|
- `"size"` - 104608,
|
||||||
},
|
- `"name"` - "/usr/bin"
|
||||||
{
|
},
|
||||||
"size": 56,
|
{
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
- `"size"` - 56,
|
||||||
},
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
{
|
},
|
||||||
"size": 0,
|
{
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
- `"size"` - 0,
|
||||||
},
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
{
|
},
|
||||||
"size": 0,
|
{
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
- `"size"` - 0,
|
||||||
},
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
{
|
},
|
||||||
"size": 0,
|
{
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
- `"size"` - 0,
|
||||||
},
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
{
|
},
|
||||||
"size": 1008,
|
{
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
- `"size"` - 1008,
|
||||||
},
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ du /usr | jc --du -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"size"` - "104608",
|
||||||
|
- `"name"` - "/usr/bin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"size"` - "56",
|
||||||
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"size"` - "0",
|
||||||
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"size"` - "0",
|
||||||
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"size"` - "0",
|
||||||
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"size"` - "1008",
|
||||||
|
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ du /usr | jc --du -p -r
|
<a id="jc.parsers.du.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"size": "104608",
|
|
||||||
"name": "/usr/bin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"size": "56",
|
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"size": "0",
|
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"size": "0",
|
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"size": "0",
|
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"size": "1008",
|
|
||||||
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.du.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.env"></a>
|
||||||
|
|
||||||
# jc.parsers.env
|
# jc.parsers.env
|
||||||
|
|
||||||
jc - JSON CLI output utility `env` and `printenv` command output parser
|
jc - JSON CLI output utility `env` and `printenv` command output parser
|
||||||
|
|
||||||
This parser will output a list of dictionaries each containing `name` and
|
This parser will output a list of dictionaries each containing `name` and
|
||||||
@ -10,95 +12,105 @@ function.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ env | jc --env
|
$ env | jc --env
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc env
|
$ jc env
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('env', env_command_output)
|
result = jc.parse('env', env_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.env
|
import jc.parsers.env
|
||||||
result = jc.parsers.env.parse(env_command_output)
|
result = jc.parsers.env.parse(env_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ env | jc --env -p
|
|
||||||
[
|
$ env | jc --env -p
|
||||||
{
|
[
|
||||||
"name": "XDG_SESSION_ID",
|
{
|
||||||
"value": "1"
|
- `"name"` - "XDG_SESSION_ID",
|
||||||
},
|
- `"value"` - "1"
|
||||||
{
|
},
|
||||||
"name": "HOSTNAME",
|
{
|
||||||
"value": "localhost.localdomain"
|
- `"name"` - "HOSTNAME",
|
||||||
},
|
- `"value"` - "localhost.localdomain"
|
||||||
{
|
},
|
||||||
"name": "TERM",
|
{
|
||||||
"value": "vt220"
|
- `"name"` - "TERM",
|
||||||
},
|
- `"value"` - "vt220"
|
||||||
{
|
},
|
||||||
"name": "SHELL",
|
{
|
||||||
"value": "/bin/bash"
|
- `"name"` - "SHELL",
|
||||||
},
|
- `"value"` - "/bin/bash"
|
||||||
{
|
},
|
||||||
"name": "HISTSIZE",
|
{
|
||||||
"value": "1000"
|
- `"name"` - "HISTSIZE",
|
||||||
},
|
- `"value"` - "1000"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ env | jc --env -p -r
|
||||||
|
{
|
||||||
|
- `"TERM"` - "xterm-256color",
|
||||||
|
- `"SHELL"` - "/bin/bash",
|
||||||
|
- `"USER"` - "root",
|
||||||
|
- `"PATH"` - "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
|
- `"PWD"` - "/root",
|
||||||
|
- `"LANG"` - "en_US.UTF-8",
|
||||||
|
- `"HOME"` - "/root",
|
||||||
|
- `"LOGNAME"` - "root",
|
||||||
|
- `"_"` - "/usr/bin/env"
|
||||||
|
}
|
||||||
|
|
||||||
$ env | jc --env -p -r
|
<a id="jc.parsers.env.info"></a>
|
||||||
{
|
|
||||||
"TERM": "xterm-256color",
|
|
||||||
"SHELL": "/bin/bash",
|
|
||||||
"USER": "root",
|
|
||||||
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
|
|
||||||
"PWD": "/root",
|
|
||||||
"LANG": "en_US.UTF-8",
|
|
||||||
"HOME": "/root",
|
|
||||||
"LOGNAME": "root",
|
|
||||||
"_": "/usr/bin/env"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.env.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary of raw structured data or
|
|
||||||
List of Dictionaries of processed structured data
|
Dictionary of raw structured data or
|
||||||
|
List of Dictionaries of processed structured data
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,93 +1,105 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.file"></a>
|
||||||
|
|
||||||
# jc.parsers.file
|
# jc.parsers.file
|
||||||
|
|
||||||
jc - JSON CLI output utility `file` command output parser
|
jc - JSON CLI output utility `file` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ file * | jc --file
|
$ file * | jc --file
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc file *
|
$ jc file *
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('file', file_command_output)
|
result = jc.parse('file', file_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.file
|
import jc.parsers.file
|
||||||
result = jc.parsers.file.parse(file_command_output)
|
result = jc.parsers.file.parse(file_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": string,
|
"filename": string,
|
||||||
"type": string
|
"type": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ file * | jc --file -p
|
|
||||||
[
|
$ file * | jc --file -p
|
||||||
{
|
[
|
||||||
"filename": "Applications",
|
{
|
||||||
"type": "directory"
|
- `"filename"` - "Applications",
|
||||||
},
|
- `"type"` - "directory"
|
||||||
{
|
},
|
||||||
"filename": "another file with spaces",
|
{
|
||||||
"type": "empty"
|
- `"filename"` - "another file with spaces",
|
||||||
},
|
- `"type"` - "empty"
|
||||||
{
|
},
|
||||||
"filename": "argstest.py",
|
{
|
||||||
"type": "Python script text executable, ASCII text"
|
- `"filename"` - "argstest.py",
|
||||||
},
|
- `"type"` - "Python script text executable, ASCII text"
|
||||||
{
|
},
|
||||||
"filename": "blkid-p.out",
|
{
|
||||||
"type": "ASCII text"
|
- `"filename"` - "blkid-p.out",
|
||||||
},
|
- `"type"` - "ASCII text"
|
||||||
{
|
},
|
||||||
"filename": "blkid-pi.out",
|
{
|
||||||
"type": "ASCII text, with very long lines"
|
- `"filename"` - "blkid-pi.out",
|
||||||
},
|
- `"type"` - "ASCII text, with very long lines"
|
||||||
{
|
},
|
||||||
"filename": "cd_catalog.xml",
|
{
|
||||||
"type": "XML 1.0 document text, ASCII text, with CRLF line ..."
|
- `"filename"` - "cd_catalog.xml",
|
||||||
},
|
- `"type"` - "XML 1.0 document text, ASCII text, with CRLF line ..."
|
||||||
{
|
},
|
||||||
"filename": "centosserial.sh",
|
{
|
||||||
"type": "Bourne-Again shell script text executable, UTF-8 ..."
|
- `"filename"` - "centosserial.sh",
|
||||||
},
|
- `"type"` - "Bourne-Again shell script text executable, UTF-8 ..."
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.file.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.file.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, aix, freebsd, darwin
|
Compatibility: linux, aix, freebsd, darwin
|
||||||
|
@ -1,121 +1,133 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.finger"></a>
|
||||||
|
|
||||||
# jc.parsers.finger
|
# jc.parsers.finger
|
||||||
|
|
||||||
jc - JSON CLI output utility `finger` command output parser
|
jc - JSON CLI output utility `finger` command output parser
|
||||||
|
|
||||||
Supports `-s` output option. Does not support the `-l` detail option.
|
Supports `-s` output option. Does not support the `-l` detail option.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ finger | jc --finger
|
$ finger | jc --finger
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc finger
|
$ jc finger
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('finger', finger_command_output)
|
result = jc.parse('finger', finger_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.finger
|
import jc.parsers.finger
|
||||||
result = jc.parsers.finger.parse(finger_command_output)
|
result = jc.parsers.finger.parse(finger_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"login": string,
|
"login": string,
|
||||||
"name": string,
|
"name": string,
|
||||||
"tty": string,
|
"tty": string,
|
||||||
"idle": string, # null if empty
|
"idle": string, # null if empty
|
||||||
"login_time": string,
|
"login_time": string,
|
||||||
"details": string,
|
"details": string,
|
||||||
"tty_writeable": boolean,
|
"tty_writeable": boolean,
|
||||||
"idle_minutes": integer,
|
"idle_minutes": integer,
|
||||||
"idle_hours": integer,
|
"idle_hours": integer,
|
||||||
"idle_days": integer,
|
"idle_days": integer,
|
||||||
"total_idle_minutes": integer
|
"total_idle_minutes": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ finger | jc --finger -p
|
|
||||||
[
|
$ finger | jc --finger -p
|
||||||
{
|
[
|
||||||
"login": "jdoe",
|
{
|
||||||
"name": "John Doe",
|
- `"login"` - "jdoe",
|
||||||
"tty": "tty1",
|
- `"name"` - "John Doe",
|
||||||
"idle": "14d",
|
- `"tty"` - "tty1",
|
||||||
"login_time": "Mar 22 21:14",
|
- `"idle"` - "14d",
|
||||||
"tty_writeable": false,
|
- `"login_time"` - "Mar 22 21:14",
|
||||||
"idle_minutes": 0,
|
- `"tty_writeable"` - false,
|
||||||
"idle_hours": 0,
|
- `"idle_minutes"` - 0,
|
||||||
"idle_days": 14,
|
- `"idle_hours"` - 0,
|
||||||
"total_idle_minutes": 20160
|
- `"idle_days"` - 14,
|
||||||
},
|
- `"total_idle_minutes"` - 20160
|
||||||
{
|
},
|
||||||
"login": "jdoe",
|
{
|
||||||
"name": "John Doe",
|
- `"login"` - "jdoe",
|
||||||
"tty": "pts/0",
|
- `"name"` - "John Doe",
|
||||||
"idle": null,
|
- `"tty"` - "pts/0",
|
||||||
"login_time": "Apr 5 15:33",
|
- `"idle"` - null,
|
||||||
"details": "(192.168.1.22)",
|
- `"login_time"` - "Apr 5 15:33",
|
||||||
"tty_writeable": true,
|
- `"details"` - "(192.168.1.22)",
|
||||||
"idle_minutes": 0,
|
- `"tty_writeable"` - true,
|
||||||
"idle_hours": 0,
|
- `"idle_minutes"` - 0,
|
||||||
"idle_days": 0,
|
- `"idle_hours"` - 0,
|
||||||
"total_idle_minutes": 0
|
- `"idle_days"` - 0,
|
||||||
},
|
- `"total_idle_minutes"` - 0
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ finger | jc --finger -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"login"` - "jdoe",
|
||||||
|
- `"name"` - "John Doe",
|
||||||
|
- `"tty"` - "*tty1",
|
||||||
|
- `"idle"` - "14d",
|
||||||
|
- `"login_time"` - "Mar 22 21:14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"login"` - "jdoe",
|
||||||
|
- `"name"` - "John Doe",
|
||||||
|
- `"tty"` - "pts/0",
|
||||||
|
- `"idle"` - null,
|
||||||
|
- `"login_time"` - "Apr 5 15:33",
|
||||||
|
- `"details"` - "(192.168.1.22)"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ finger | jc --finger -p -r
|
<a id="jc.parsers.finger.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"login": "jdoe",
|
|
||||||
"name": "John Doe",
|
|
||||||
"tty": "*tty1",
|
|
||||||
"idle": "14d",
|
|
||||||
"login_time": "Mar 22 21:14"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"login": "jdoe",
|
|
||||||
"name": "John Doe",
|
|
||||||
"tty": "pts/0",
|
|
||||||
"idle": null,
|
|
||||||
"login_time": "Apr 5 15:33",
|
|
||||||
"details": "(192.168.1.22)"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.finger.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, freebsd
|
Compatibility: linux, darwin, cygwin, freebsd
|
||||||
|
@ -1,103 +1,115 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.free"></a>
|
||||||
|
|
||||||
# jc.parsers.free
|
# jc.parsers.free
|
||||||
|
|
||||||
jc - JSON CLI output utility `free` command output parser
|
jc - JSON CLI output utility `free` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ free | jc --free
|
$ free | jc --free
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc free
|
$ jc free
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('free', free_command_output)
|
result = jc.parse('free', free_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.free
|
import jc.parsers.free
|
||||||
result = jc.parsers.free.parse(free_command_output)
|
result = jc.parsers.free.parse(free_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": string,
|
"type": string,
|
||||||
"total": integer,
|
"total": integer,
|
||||||
"used": integer,
|
"used": integer,
|
||||||
"free": integer,
|
"free": integer,
|
||||||
"shared": integer,
|
"shared": integer,
|
||||||
"buff_cache": integer,
|
"buff_cache": integer,
|
||||||
"available": integer
|
"available": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ free | jc --free -p
|
|
||||||
[
|
$ free | jc --free -p
|
||||||
{
|
[
|
||||||
"type": "Mem",
|
{
|
||||||
"total": 3861340,
|
- `"type"` - "Mem",
|
||||||
"used": 220508,
|
- `"total"` - 3861340,
|
||||||
"free": 3381972,
|
- `"used"` - 220508,
|
||||||
"shared": 11800,
|
- `"free"` - 3381972,
|
||||||
"buff_cache": 258860,
|
- `"shared"` - 11800,
|
||||||
"available": 3397784
|
- `"buff_cache"` - 258860,
|
||||||
},
|
- `"available"` - 3397784
|
||||||
{
|
},
|
||||||
"type": "Swap",
|
{
|
||||||
"total": 2097148,
|
- `"type"` - "Swap",
|
||||||
"used": 0,
|
- `"total"` - 2097148,
|
||||||
"free": 2097148
|
- `"used"` - 0,
|
||||||
}
|
- `"free"` - 2097148
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ free | jc --free -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"type"` - "Mem",
|
||||||
|
- `"total"` - "2017300",
|
||||||
|
- `"used"` - "213104",
|
||||||
|
- `"free"` - "1148452",
|
||||||
|
- `"shared"` - "1176",
|
||||||
|
- `"buff_cache"` - "655744",
|
||||||
|
- `"available"` - "1622204"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "Swap",
|
||||||
|
- `"total"` - "2097148",
|
||||||
|
- `"used"` - "0",
|
||||||
|
- `"free"` - "2097148"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ free | jc --free -p -r
|
<a id="jc.parsers.free.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"type": "Mem",
|
|
||||||
"total": "2017300",
|
|
||||||
"used": "213104",
|
|
||||||
"free": "1148452",
|
|
||||||
"shared": "1176",
|
|
||||||
"buff_cache": "655744",
|
|
||||||
"available": "1622204"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Swap",
|
|
||||||
"total": "2097148",
|
|
||||||
"used": "0",
|
|
||||||
"free": "2097148"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.free.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,116 +1,128 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.fstab"></a>
|
||||||
|
|
||||||
# jc.parsers.fstab
|
# jc.parsers.fstab
|
||||||
|
|
||||||
jc - JSON CLI output utility `fstab` file parser
|
jc - JSON CLI output utility `fstab` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat /etc/fstab | jc --fstab
|
$ cat /etc/fstab | jc --fstab
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('fstab', fstab_command_output)
|
result = jc.parse('fstab', fstab_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.fstab
|
import jc.parsers.fstab
|
||||||
result = jc.parsers.fstab.parse(fstab_command_output)
|
result = jc.parsers.fstab.parse(fstab_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"fs_spec": string,
|
"fs_spec": string,
|
||||||
"fs_file": string,
|
"fs_file": string,
|
||||||
"fs_vfstype": string,
|
"fs_vfstype": string,
|
||||||
"fs_mntops": string,
|
"fs_mntops": string,
|
||||||
"fs_freq": integer,
|
"fs_freq": integer,
|
||||||
"fs_passno": integer
|
"fs_passno": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat /etc/fstab | jc --fstab -p
|
|
||||||
[
|
$ cat /etc/fstab | jc --fstab -p
|
||||||
{
|
[
|
||||||
"fs_spec": "/dev/mapper/centos-root",
|
{
|
||||||
"fs_file": "/",
|
- `"fs_spec"` - "/dev/mapper/centos-root",
|
||||||
"fs_vfstype": "xfs",
|
- `"fs_file"` - "/",
|
||||||
"fs_mntops": "defaults",
|
- `"fs_vfstype"` - "xfs",
|
||||||
"fs_freq": 0,
|
- `"fs_mntops"` - "defaults",
|
||||||
"fs_passno": 0
|
- `"fs_freq"` - 0,
|
||||||
},
|
- `"fs_passno"` - 0
|
||||||
{
|
},
|
||||||
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
|
{
|
||||||
"fs_file": "/boot",
|
- `"fs_spec"` - "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
"fs_vfstype": "xfs",
|
- `"fs_file"` - "/boot",
|
||||||
"fs_mntops": "defaults",
|
- `"fs_vfstype"` - "xfs",
|
||||||
"fs_freq": 0,
|
- `"fs_mntops"` - "defaults",
|
||||||
"fs_passno": 0
|
- `"fs_freq"` - 0,
|
||||||
},
|
- `"fs_passno"` - 0
|
||||||
{
|
},
|
||||||
"fs_spec": "/dev/mapper/centos-swap",
|
{
|
||||||
"fs_file": "swap",
|
- `"fs_spec"` - "/dev/mapper/centos-swap",
|
||||||
"fs_vfstype": "swap",
|
- `"fs_file"` - "swap",
|
||||||
"fs_mntops": "defaults",
|
- `"fs_vfstype"` - "swap",
|
||||||
"fs_freq": 0,
|
- `"fs_mntops"` - "defaults",
|
||||||
"fs_passno": 0
|
- `"fs_freq"` - 0,
|
||||||
}
|
- `"fs_passno"` - 0
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ cat /etc/fstab | jc --fstab -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"fs_spec"` - "/dev/mapper/centos-root",
|
||||||
|
- `"fs_file"` - "/",
|
||||||
|
- `"fs_vfstype"` - "xfs",
|
||||||
|
- `"fs_mntops"` - "defaults",
|
||||||
|
- `"fs_freq"` - "0",
|
||||||
|
- `"fs_passno"` - "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"fs_spec"` - "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
|
- `"fs_file"` - "/boot",
|
||||||
|
- `"fs_vfstype"` - "xfs",
|
||||||
|
- `"fs_mntops"` - "defaults",
|
||||||
|
- `"fs_freq"` - "0",
|
||||||
|
- `"fs_passno"` - "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"fs_spec"` - "/dev/mapper/centos-swap",
|
||||||
|
- `"fs_file"` - "swap",
|
||||||
|
- `"fs_vfstype"` - "swap",
|
||||||
|
- `"fs_mntops"` - "defaults",
|
||||||
|
- `"fs_freq"` - "0",
|
||||||
|
- `"fs_passno"` - "0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ cat /etc/fstab | jc --fstab -p -r
|
<a id="jc.parsers.fstab.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"fs_spec": "/dev/mapper/centos-root",
|
|
||||||
"fs_file": "/",
|
|
||||||
"fs_vfstype": "xfs",
|
|
||||||
"fs_mntops": "defaults",
|
|
||||||
"fs_freq": "0",
|
|
||||||
"fs_passno": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
|
|
||||||
"fs_file": "/boot",
|
|
||||||
"fs_vfstype": "xfs",
|
|
||||||
"fs_mntops": "defaults",
|
|
||||||
"fs_freq": "0",
|
|
||||||
"fs_passno": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fs_spec": "/dev/mapper/centos-swap",
|
|
||||||
"fs_file": "swap",
|
|
||||||
"fs_vfstype": "swap",
|
|
||||||
"fs_mntops": "defaults",
|
|
||||||
"fs_freq": "0",
|
|
||||||
"fs_passno": "0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.fstab.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, freebsd
|
Compatibility: linux, freebsd
|
||||||
|
@ -1,140 +1,152 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.group"></a>
|
||||||
|
|
||||||
# jc.parsers.group
|
# jc.parsers.group
|
||||||
|
|
||||||
jc - JSON CLI output utility `/etc/group` file parser
|
jc - JSON CLI output utility `/etc/group` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat /etc/group | jc --group
|
$ cat /etc/group | jc --group
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('group', group_file_output)
|
result = jc.parse('group', group_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.group
|
import jc.parsers.group
|
||||||
result = jc.parsers.group.parse(group_file_output)
|
result = jc.parsers.group.parse(group_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"group_name": string,
|
"group_name": string,
|
||||||
"password": string,
|
"password": string,
|
||||||
"gid": integer,
|
"gid": integer,
|
||||||
"members": [
|
"members": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat /etc/group | jc --group -p
|
|
||||||
[
|
$ cat /etc/group | jc --group -p
|
||||||
{
|
[
|
||||||
"group_name": "nobody",
|
{
|
||||||
"password": "*",
|
- `"group_name"` - "nobody",
|
||||||
"gid": -2,
|
- `"password"` - "*",
|
||||||
"members": []
|
- `"gid"` - -2,
|
||||||
},
|
- `"members"` - []
|
||||||
{
|
},
|
||||||
"group_name": "nogroup",
|
{
|
||||||
"password": "*",
|
- `"group_name"` - "nogroup",
|
||||||
"gid": -1,
|
- `"password"` - "*",
|
||||||
"members": []
|
- `"gid"` - -1,
|
||||||
},
|
- `"members"` - []
|
||||||
{
|
},
|
||||||
"group_name": "wheel",
|
{
|
||||||
"password": "*",
|
- `"group_name"` - "wheel",
|
||||||
"gid": 0,
|
- `"password"` - "*",
|
||||||
"members": [
|
- `"gid"` - 0,
|
||||||
"root"
|
- `"members"` - [
|
||||||
]
|
"root"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"group_name": "certusers",
|
{
|
||||||
"password": "*",
|
- `"group_name"` - "certusers",
|
||||||
"gid": 29,
|
- `"password"` - "*",
|
||||||
"members": [
|
- `"gid"` - 29,
|
||||||
"root",
|
- `"members"` - [
|
||||||
"_jabber",
|
"root",
|
||||||
"_postfix",
|
"_jabber",
|
||||||
"_cyrus",
|
"_postfix",
|
||||||
"_calendar",
|
"_cyrus",
|
||||||
"_dovecot"
|
"_calendar",
|
||||||
]
|
"_dovecot"
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ cat /etc/group | jc --group -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"group_name"` - "nobody",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"gid"` - "-2",
|
||||||
|
- `"members"` - [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"group_name"` - "nogroup",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"gid"` - "-1",
|
||||||
|
- `"members"` - [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"group_name"` - "wheel",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"gid"` - "0",
|
||||||
|
- `"members"` - [
|
||||||
|
"root"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"group_name"` - "certusers",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"gid"` - "29",
|
||||||
|
- `"members"` - [
|
||||||
|
"root",
|
||||||
|
"_jabber",
|
||||||
|
"_postfix",
|
||||||
|
"_cyrus",
|
||||||
|
"_calendar",
|
||||||
|
"_dovecot"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ cat /etc/group | jc --group -p -r
|
<a id="jc.parsers.group.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"group_name": "nobody",
|
|
||||||
"password": "*",
|
|
||||||
"gid": "-2",
|
|
||||||
"members": [
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"group_name": "nogroup",
|
|
||||||
"password": "*",
|
|
||||||
"gid": "-1",
|
|
||||||
"members": [
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"group_name": "wheel",
|
|
||||||
"password": "*",
|
|
||||||
"gid": "0",
|
|
||||||
"members": [
|
|
||||||
"root"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"group_name": "certusers",
|
|
||||||
"password": "*",
|
|
||||||
"gid": "29",
|
|
||||||
"members": [
|
|
||||||
"root",
|
|
||||||
"_jabber",
|
|
||||||
"_postfix",
|
|
||||||
"_cyrus",
|
|
||||||
"_calendar",
|
|
||||||
"_dovecot"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.group.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,108 +1,120 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.gshadow"></a>
|
||||||
|
|
||||||
# jc.parsers.gshadow
|
# jc.parsers.gshadow
|
||||||
|
|
||||||
jc - JSON CLI output utility `/etc/gshadow` file parser
|
jc - JSON CLI output utility `/etc/gshadow` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat /etc/gshadow | jc --gshadow
|
$ cat /etc/gshadow | jc --gshadow
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('gshadow', gshadow_file_output)
|
result = jc.parse('gshadow', gshadow_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.gshadow
|
import jc.parsers.gshadow
|
||||||
result = jc.parsers.gshadow.parse(gshadow_file_output)
|
result = jc.parsers.gshadow.parse(gshadow_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"group_name": string,
|
"group_name": string,
|
||||||
"password": string,
|
"password": string,
|
||||||
"administrators": [
|
"administrators": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"members": [
|
"members": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat /etc/gshadow | jc --gshadow -p
|
|
||||||
[
|
$ cat /etc/gshadow | jc --gshadow -p
|
||||||
{
|
[
|
||||||
"group_name": "root",
|
{
|
||||||
"password": "*",
|
- `"group_name"` - "root",
|
||||||
"administrators": [],
|
- `"password"` - "*",
|
||||||
"members": []
|
- `"administrators"` - [],
|
||||||
},
|
- `"members"` - []
|
||||||
{
|
},
|
||||||
"group_name": "adm",
|
{
|
||||||
"password": "*",
|
- `"group_name"` - "adm",
|
||||||
"administrators": [],
|
- `"password"` - "*",
|
||||||
"members": [
|
- `"administrators"` - [],
|
||||||
"syslog",
|
- `"members"` - [
|
||||||
"joeuser"
|
"syslog",
|
||||||
]
|
"joeuser"
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ cat /etc/gshadow | jc --gshadow -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"group_name"` - "root",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"administrators"` - [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
- `"members"` - [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"group_name"` - "adm",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"administrators"` - [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
- `"members"` - [
|
||||||
|
"syslog",
|
||||||
|
"joeuser"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ cat /etc/gshadow | jc --gshadow -p -r
|
<a id="jc.parsers.gshadow.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"group_name": "root",
|
|
||||||
"password": "*",
|
|
||||||
"administrators": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"members": [
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"group_name": "adm",
|
|
||||||
"password": "*",
|
|
||||||
"administrators": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"members": [
|
|
||||||
"syslog",
|
|
||||||
"joeuser"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.gshadow.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, aix, freebsd
|
Compatibility: linux, aix, freebsd
|
||||||
|
@ -1,68 +1,80 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.hash"></a>
|
||||||
|
|
||||||
# jc.parsers.hash
|
# jc.parsers.hash
|
||||||
|
|
||||||
jc - JSON CLI output utility `hash` command output parser
|
jc - JSON CLI output utility `hash` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ hash | jc --hash
|
$ hash | jc --hash
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('hash', hash_command_output)
|
result = jc.parse('hash', hash_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.hash
|
import jc.parsers.hash
|
||||||
result = jc.parsers.hash.parse(hash_command_output)
|
result = jc.parsers.hash.parse(hash_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"command": string,
|
"command": string,
|
||||||
"hits": integer
|
"hits": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ hash | jc --hash -p
|
|
||||||
[
|
$ hash | jc --hash -p
|
||||||
{
|
[
|
||||||
"hits": 2,
|
{
|
||||||
"command": "/bin/cat"
|
- `"hits"` - 2,
|
||||||
},
|
- `"command"` - "/bin/cat"
|
||||||
{
|
},
|
||||||
"hits": 1,
|
{
|
||||||
"command": "/bin/ls"
|
- `"hits"` - 1,
|
||||||
}
|
- `"command"` - "/bin/ls"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.hash.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.hash.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.hashsum"></a>
|
||||||
|
|
||||||
# jc.parsers.hashsum
|
# jc.parsers.hashsum
|
||||||
|
|
||||||
jc - JSON CLI output utility `hash sum` command output parser
|
jc - JSON CLI output utility `hash sum` command output parser
|
||||||
|
|
||||||
This parser works with the following hash calculation utilities:
|
This parser works with the following hash calculation utilities:
|
||||||
@ -15,85 +17,95 @@ This parser works with the following hash calculation utilities:
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ md5sum file.txt | jc --hashsum
|
$ md5sum file.txt | jc --hashsum
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc md5sum file.txt
|
$ jc md5sum file.txt
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('hashsum', md5sum_command_output)
|
result = jc.parse('hashsum', md5sum_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.hashsum
|
import jc.parsers.hashsum
|
||||||
result = jc.parsers.hashsum.parse(md5sum_command_output)
|
result = jc.parsers.hashsum.parse(md5sum_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": string,
|
"filename": string,
|
||||||
"hash": string,
|
"hash": string,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ md5sum * | jc --hashsum -p
|
|
||||||
[
|
$ md5sum * | jc --hashsum -p
|
||||||
{
|
[
|
||||||
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
|
{
|
||||||
"hash": "65fc958c1add637ec23c4b137aecf3d3"
|
- `"filename"` - "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
|
||||||
},
|
- `"hash"` - "65fc958c1add637ec23c4b137aecf3d3"
|
||||||
{
|
},
|
||||||
"filename": "digout",
|
{
|
||||||
"hash": "5b9312ee5aff080927753c63a347707d"
|
- `"filename"` - "digout",
|
||||||
},
|
- `"hash"` - "5b9312ee5aff080927753c63a347707d"
|
||||||
{
|
},
|
||||||
"filename": "dmidecode.out",
|
{
|
||||||
"hash": "716fd11c2ac00db109281f7110b8fb9d"
|
- `"filename"` - "dmidecode.out",
|
||||||
},
|
- `"hash"` - "716fd11c2ac00db109281f7110b8fb9d"
|
||||||
{
|
},
|
||||||
"filename": "file with spaces in the name",
|
{
|
||||||
"hash": "d41d8cd98f00b204e9800998ecf8427e"
|
- `"filename"` - "file with spaces in the name",
|
||||||
},
|
- `"hash"` - "d41d8cd98f00b204e9800998ecf8427e"
|
||||||
{
|
},
|
||||||
"filename": "id-centos.out",
|
{
|
||||||
"hash": "4295be239a14ad77ef3253103de976d2"
|
- `"filename"` - "id-centos.out",
|
||||||
},
|
- `"hash"` - "4295be239a14ad77ef3253103de976d2"
|
||||||
{
|
},
|
||||||
"filename": "ifcfg.json",
|
{
|
||||||
"hash": "01fda0d9ba9a75618b072e64ff512b43"
|
- `"filename"` - "ifcfg.json",
|
||||||
},
|
- `"hash"` - "01fda0d9ba9a75618b072e64ff512b43"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.hashsum.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.hashsum.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,348 +1,360 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.hciconfig"></a>
|
||||||
|
|
||||||
# jc.parsers.hciconfig
|
# jc.parsers.hciconfig
|
||||||
|
|
||||||
jc - JSON CLI output utility `hciconfig` command output parser
|
jc - JSON CLI output utility `hciconfig` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ hciconfig | jc --hciconfig
|
$ hciconfig | jc --hciconfig
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc hciconfig
|
$ jc hciconfig
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('hciconfig', hciconfig_command_output)
|
result = jc.parse('hciconfig', hciconfig_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.hciconfig
|
import jc.parsers.hciconfig
|
||||||
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
|
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"device": string,
|
"device": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"bus": string,
|
"bus": string,
|
||||||
"bd_address": string,
|
"bd_address": string,
|
||||||
"acl_mtu": integer,
|
"acl_mtu": integer,
|
||||||
"acl_mtu_packets": integer,
|
"acl_mtu_packets": integer,
|
||||||
"sco_mtu": integer,
|
"sco_mtu": integer,
|
||||||
"sco_mtu_packets": integer,
|
"sco_mtu_packets": integer,
|
||||||
"state": [
|
"state": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"rx_bytes": integer,
|
"rx_bytes": integer,
|
||||||
"rx_acl": integer,
|
"rx_acl": integer,
|
||||||
"rx_sco": integer,
|
"rx_sco": integer,
|
||||||
"rx_events": integer,
|
"rx_events": integer,
|
||||||
"rx_errors": integer,
|
"rx_errors": integer,
|
||||||
"tx_bytes": integer,
|
"tx_bytes": integer,
|
||||||
"tx_acl": integer,
|
"tx_acl": integer,
|
||||||
"tx_sco": integer,
|
"tx_sco": integer,
|
||||||
"tx_commands": integer,
|
"tx_commands": integer,
|
||||||
"tx_errors": integer,
|
"tx_errors": integer,
|
||||||
"features": [
|
"features": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"packet_type": [
|
"packet_type": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"link_policy": [
|
"link_policy": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"link_mode": [
|
"link_mode": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"name": string,
|
"name": string,
|
||||||
"class": string,
|
"class": string,
|
||||||
"service_classes": [
|
"service_classes": [
|
||||||
string # 'Unspecified' is null
|
string # 'Unspecified' is null
|
||||||
],
|
],
|
||||||
"device_class": string,
|
"device_class": string,
|
||||||
"hci_version": string,
|
"hci_version": string,
|
||||||
"hci_revision": string,
|
"hci_revision": string,
|
||||||
"lmp_version": string,
|
"lmp_version": string,
|
||||||
"lmp_subversion": string,
|
"lmp_subversion": string,
|
||||||
"manufacturer": string
|
"manufacturer": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ hciconfig -a | jc --hciconfig -p
|
|
||||||
[
|
$ hciconfig -a | jc --hciconfig -p
|
||||||
{
|
[
|
||||||
"device": "hci0",
|
{
|
||||||
"type": "Primary",
|
- `"device"` - "hci0",
|
||||||
"bus": "USB",
|
- `"type"` - "Primary",
|
||||||
"bd_address": "00:1A:7D:DA:71:13",
|
- `"bus"` - "USB",
|
||||||
"acl_mtu": 310,
|
- `"bd_address"` - "00:1A:7D:DA:71:13",
|
||||||
"acl_mtu_packets": 10,
|
- `"acl_mtu"` - 310,
|
||||||
"sco_mtu": 64,
|
- `"acl_mtu_packets"` - 10,
|
||||||
"sco_mtu_packets": 8,
|
- `"sco_mtu"` - 64,
|
||||||
"state": [
|
- `"sco_mtu_packets"` - 8,
|
||||||
"UP",
|
- `"state"` - [
|
||||||
"RUNNING"
|
"UP",
|
||||||
],
|
"RUNNING"
|
||||||
"rx_bytes": 13905869,
|
],
|
||||||
"rx_acl": 0,
|
- `"rx_bytes"` - 13905869,
|
||||||
"rx_sco": 0,
|
- `"rx_acl"` - 0,
|
||||||
"rx_events": 393300,
|
- `"rx_sco"` - 0,
|
||||||
"rx_errors": 0,
|
- `"rx_events"` - 393300,
|
||||||
"tx_bytes": 62629,
|
- `"rx_errors"` - 0,
|
||||||
"tx_acl": 0,
|
- `"tx_bytes"` - 62629,
|
||||||
"tx_sco": 0,
|
- `"tx_acl"` - 0,
|
||||||
"tx_commands": 3893,
|
- `"tx_sco"` - 0,
|
||||||
"tx_errors": 0,
|
- `"tx_commands"` - 3893,
|
||||||
"features": [
|
- `"tx_errors"` - 0,
|
||||||
"0xff",
|
- `"features"` - [
|
||||||
"0xff",
|
"0xff",
|
||||||
"0x8f",
|
"0xff",
|
||||||
"0xfe",
|
"0x8f",
|
||||||
"0xdb",
|
"0xfe",
|
||||||
"0xff",
|
"0xdb",
|
||||||
"0x5b",
|
"0xff",
|
||||||
"0x87"
|
"0x5b",
|
||||||
],
|
"0x87"
|
||||||
"packet_type": [
|
],
|
||||||
"DM1",
|
- `"packet_type"` - [
|
||||||
"DM3",
|
"DM1",
|
||||||
"DM5",
|
"DM3",
|
||||||
"DH1",
|
"DM5",
|
||||||
"DH3",
|
"DH1",
|
||||||
"DH5",
|
"DH3",
|
||||||
"HV1",
|
"DH5",
|
||||||
"HV2",
|
"HV1",
|
||||||
"HV3"
|
"HV2",
|
||||||
],
|
"HV3"
|
||||||
"link_policy": [
|
],
|
||||||
"RSWITCH",
|
- `"link_policy"` - [
|
||||||
"HOLD",
|
"RSWITCH",
|
||||||
"SNIFF",
|
"HOLD",
|
||||||
"PARK"
|
"SNIFF",
|
||||||
],
|
"PARK"
|
||||||
"link_mode": [
|
],
|
||||||
"SLAVE",
|
- `"link_mode"` - [
|
||||||
"ACCEPT"
|
"SLAVE",
|
||||||
],
|
"ACCEPT"
|
||||||
"name": "CSR8510 A10",
|
],
|
||||||
"class": "0x000000",
|
- `"name"` - "CSR8510 A10",
|
||||||
"service_classes": null,
|
- `"class"` - "0x000000",
|
||||||
"device_class": "Miscellaneous",
|
- `"service_classes"` - null,
|
||||||
"hci_version": "4.0 (0x6)",
|
- `"device_class"` - "Miscellaneous",
|
||||||
"hci_revision": "0x22bb",
|
- `"hci_version"` - "4.0 (0x6)",
|
||||||
"lmp_version": "4.0 (0x6)",
|
- `"hci_revision"` - "0x22bb",
|
||||||
"lmp_subversion": "0x22bb",
|
- `"lmp_version"` - "4.0 (0x6)",
|
||||||
"manufacturer": "Cambridge Silicon Radio (10)"
|
- `"lmp_subversion"` - "0x22bb",
|
||||||
},
|
- `"manufacturer"` - "Cambridge Silicon Radio (10)"
|
||||||
{
|
},
|
||||||
"device": "hci1",
|
{
|
||||||
"type": "Primary",
|
- `"device"` - "hci1",
|
||||||
"bus": "USB",
|
- `"type"` - "Primary",
|
||||||
"bd_address": "00:1A:7D:DA:71:13",
|
- `"bus"` - "USB",
|
||||||
"acl_mtu": 310,
|
- `"bd_address"` - "00:1A:7D:DA:71:13",
|
||||||
"acl_mtu_packets": 10,
|
- `"acl_mtu"` - 310,
|
||||||
"sco_mtu": 64,
|
- `"acl_mtu_packets"` - 10,
|
||||||
"sco_mtu_packets": 8,
|
- `"sco_mtu"` - 64,
|
||||||
"state": [
|
- `"sco_mtu_packets"` - 8,
|
||||||
"DOWN"
|
- `"state"` - [
|
||||||
],
|
"DOWN"
|
||||||
"rx_bytes": 4388363,
|
],
|
||||||
"rx_acl": 0,
|
- `"rx_bytes"` - 4388363,
|
||||||
"rx_sco": 0,
|
- `"rx_acl"` - 0,
|
||||||
"rx_events": 122021,
|
- `"rx_sco"` - 0,
|
||||||
"rx_errors": 0,
|
- `"rx_events"` - 122021,
|
||||||
"tx_bytes": 52350,
|
- `"rx_errors"` - 0,
|
||||||
"tx_acl": 0,
|
- `"tx_bytes"` - 52350,
|
||||||
"tx_sco": 0,
|
- `"tx_acl"` - 0,
|
||||||
"tx_commands": 3480,
|
- `"tx_sco"` - 0,
|
||||||
"tx_errors": 2,
|
- `"tx_commands"` - 3480,
|
||||||
"features": [
|
- `"tx_errors"` - 2,
|
||||||
"0xff",
|
- `"features"` - [
|
||||||
"0xff",
|
"0xff",
|
||||||
"0x8f",
|
"0xff",
|
||||||
"0xfe",
|
"0x8f",
|
||||||
"0xdb",
|
"0xfe",
|
||||||
"0xff",
|
"0xdb",
|
||||||
"0x5b",
|
"0xff",
|
||||||
"0x87"
|
"0x5b",
|
||||||
],
|
"0x87"
|
||||||
"packet_type": [
|
],
|
||||||
"DM1",
|
- `"packet_type"` - [
|
||||||
"DM3",
|
"DM1",
|
||||||
"DM5",
|
"DM3",
|
||||||
"DH1",
|
"DM5",
|
||||||
"DH3",
|
"DH1",
|
||||||
"DH5",
|
"DH3",
|
||||||
"HV1",
|
"DH5",
|
||||||
"HV2",
|
"HV1",
|
||||||
"HV3"
|
"HV2",
|
||||||
],
|
"HV3"
|
||||||
"link_policy": [
|
],
|
||||||
"RSWITCH",
|
- `"link_policy"` - [
|
||||||
"HOLD",
|
"RSWITCH",
|
||||||
"SNIFF",
|
"HOLD",
|
||||||
"PARK"
|
"SNIFF",
|
||||||
],
|
"PARK"
|
||||||
"link_mode": [
|
],
|
||||||
"SLAVE",
|
- `"link_mode"` - [
|
||||||
"ACCEPT"
|
"SLAVE",
|
||||||
]
|
"ACCEPT"
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ hciconfig -a | jc --hciconfig -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"device"` - "hci0",
|
||||||
|
- `"type"` - "Primary",
|
||||||
|
- `"bus"` - "USB",
|
||||||
|
- `"bd_address"` - "00:1A:7D:DA:71:13",
|
||||||
|
- `"acl_mtu"` - "310",
|
||||||
|
- `"acl_mtu_packets"` - "10",
|
||||||
|
- `"sco_mtu"` - "64",
|
||||||
|
- `"sco_mtu_packets"` - "8",
|
||||||
|
- `"state"` - [
|
||||||
|
"UP",
|
||||||
|
"RUNNING"
|
||||||
|
],
|
||||||
|
- `"rx_bytes"` - "13905869",
|
||||||
|
- `"rx_acl"` - "0",
|
||||||
|
- `"rx_sco"` - "0",
|
||||||
|
- `"rx_events"` - "393300",
|
||||||
|
- `"rx_errors"` - "0",
|
||||||
|
- `"tx_bytes"` - "62629",
|
||||||
|
- `"tx_acl"` - "0",
|
||||||
|
- `"tx_sco"` - "0",
|
||||||
|
- `"tx_commands"` - "3893",
|
||||||
|
- `"tx_errors"` - "0",
|
||||||
|
- `"features"` - [
|
||||||
|
"0xff",
|
||||||
|
"0xff",
|
||||||
|
"0x8f",
|
||||||
|
"0xfe",
|
||||||
|
"0xdb",
|
||||||
|
"0xff",
|
||||||
|
"0x5b",
|
||||||
|
"0x87"
|
||||||
|
],
|
||||||
|
- `"packet_type"` - [
|
||||||
|
"DM1",
|
||||||
|
"DM3",
|
||||||
|
"DM5",
|
||||||
|
"DH1",
|
||||||
|
"DH3",
|
||||||
|
"DH5",
|
||||||
|
"HV1",
|
||||||
|
"HV2",
|
||||||
|
"HV3"
|
||||||
|
],
|
||||||
|
- `"link_policy"` - [
|
||||||
|
"RSWITCH",
|
||||||
|
"HOLD",
|
||||||
|
"SNIFF",
|
||||||
|
"PARK"
|
||||||
|
],
|
||||||
|
- `"link_mode"` - [
|
||||||
|
"SLAVE",
|
||||||
|
"ACCEPT"
|
||||||
|
],
|
||||||
|
- `"name"` - "CSR8510 A10",
|
||||||
|
- `"class"` - "0x000000",
|
||||||
|
- `"service_classes"` - [
|
||||||
|
"Unspecified"
|
||||||
|
],
|
||||||
|
- `"device_class"` - "Miscellaneous",
|
||||||
|
- `"hci_version"` - "4.0 (0x6)",
|
||||||
|
- `"hci_revision"` - "0x22bb",
|
||||||
|
- `"lmp_version"` - "4.0 (0x6)",
|
||||||
|
- `"lmp_subversion"` - "0x22bb",
|
||||||
|
- `"manufacturer"` - "Cambridge Silicon Radio (10)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "hci1",
|
||||||
|
- `"type"` - "Primary",
|
||||||
|
- `"bus"` - "USB",
|
||||||
|
- `"bd_address"` - "00:1A:7D:DA:71:13",
|
||||||
|
- `"acl_mtu"` - "310",
|
||||||
|
- `"acl_mtu_packets"` - "10",
|
||||||
|
- `"sco_mtu"` - "64",
|
||||||
|
- `"sco_mtu_packets"` - "8",
|
||||||
|
- `"state"` - [
|
||||||
|
"DOWN"
|
||||||
|
],
|
||||||
|
- `"rx_bytes"` - "4388363",
|
||||||
|
- `"rx_acl"` - "0",
|
||||||
|
- `"rx_sco"` - "0",
|
||||||
|
- `"rx_events"` - "122021",
|
||||||
|
- `"rx_errors"` - "0",
|
||||||
|
- `"tx_bytes"` - "52350",
|
||||||
|
- `"tx_acl"` - "0",
|
||||||
|
- `"tx_sco"` - "0",
|
||||||
|
- `"tx_commands"` - "3480",
|
||||||
|
- `"tx_errors"` - "2",
|
||||||
|
- `"features"` - [
|
||||||
|
"0xff",
|
||||||
|
"0xff",
|
||||||
|
"0x8f",
|
||||||
|
"0xfe",
|
||||||
|
"0xdb",
|
||||||
|
"0xff",
|
||||||
|
"0x5b",
|
||||||
|
"0x87"
|
||||||
|
],
|
||||||
|
- `"packet_type"` - [
|
||||||
|
"DM1",
|
||||||
|
"DM3",
|
||||||
|
"DM5",
|
||||||
|
"DH1",
|
||||||
|
"DH3",
|
||||||
|
"DH5",
|
||||||
|
"HV1",
|
||||||
|
"HV2",
|
||||||
|
"HV3"
|
||||||
|
],
|
||||||
|
- `"link_policy"` - [
|
||||||
|
"RSWITCH",
|
||||||
|
"HOLD",
|
||||||
|
"SNIFF",
|
||||||
|
"PARK"
|
||||||
|
],
|
||||||
|
- `"link_mode"` - [
|
||||||
|
"SLAVE",
|
||||||
|
"ACCEPT"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ hciconfig -a | jc --hciconfig -p -r
|
<a id="jc.parsers.hciconfig.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"device": "hci0",
|
|
||||||
"type": "Primary",
|
|
||||||
"bus": "USB",
|
|
||||||
"bd_address": "00:1A:7D:DA:71:13",
|
|
||||||
"acl_mtu": "310",
|
|
||||||
"acl_mtu_packets": "10",
|
|
||||||
"sco_mtu": "64",
|
|
||||||
"sco_mtu_packets": "8",
|
|
||||||
"state": [
|
|
||||||
"UP",
|
|
||||||
"RUNNING"
|
|
||||||
],
|
|
||||||
"rx_bytes": "13905869",
|
|
||||||
"rx_acl": "0",
|
|
||||||
"rx_sco": "0",
|
|
||||||
"rx_events": "393300",
|
|
||||||
"rx_errors": "0",
|
|
||||||
"tx_bytes": "62629",
|
|
||||||
"tx_acl": "0",
|
|
||||||
"tx_sco": "0",
|
|
||||||
"tx_commands": "3893",
|
|
||||||
"tx_errors": "0",
|
|
||||||
"features": [
|
|
||||||
"0xff",
|
|
||||||
"0xff",
|
|
||||||
"0x8f",
|
|
||||||
"0xfe",
|
|
||||||
"0xdb",
|
|
||||||
"0xff",
|
|
||||||
"0x5b",
|
|
||||||
"0x87"
|
|
||||||
],
|
|
||||||
"packet_type": [
|
|
||||||
"DM1",
|
|
||||||
"DM3",
|
|
||||||
"DM5",
|
|
||||||
"DH1",
|
|
||||||
"DH3",
|
|
||||||
"DH5",
|
|
||||||
"HV1",
|
|
||||||
"HV2",
|
|
||||||
"HV3"
|
|
||||||
],
|
|
||||||
"link_policy": [
|
|
||||||
"RSWITCH",
|
|
||||||
"HOLD",
|
|
||||||
"SNIFF",
|
|
||||||
"PARK"
|
|
||||||
],
|
|
||||||
"link_mode": [
|
|
||||||
"SLAVE",
|
|
||||||
"ACCEPT"
|
|
||||||
],
|
|
||||||
"name": "CSR8510 A10",
|
|
||||||
"class": "0x000000",
|
|
||||||
"service_classes": [
|
|
||||||
"Unspecified"
|
|
||||||
],
|
|
||||||
"device_class": "Miscellaneous",
|
|
||||||
"hci_version": "4.0 (0x6)",
|
|
||||||
"hci_revision": "0x22bb",
|
|
||||||
"lmp_version": "4.0 (0x6)",
|
|
||||||
"lmp_subversion": "0x22bb",
|
|
||||||
"manufacturer": "Cambridge Silicon Radio (10)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "hci1",
|
|
||||||
"type": "Primary",
|
|
||||||
"bus": "USB",
|
|
||||||
"bd_address": "00:1A:7D:DA:71:13",
|
|
||||||
"acl_mtu": "310",
|
|
||||||
"acl_mtu_packets": "10",
|
|
||||||
"sco_mtu": "64",
|
|
||||||
"sco_mtu_packets": "8",
|
|
||||||
"state": [
|
|
||||||
"DOWN"
|
|
||||||
],
|
|
||||||
"rx_bytes": "4388363",
|
|
||||||
"rx_acl": "0",
|
|
||||||
"rx_sco": "0",
|
|
||||||
"rx_events": "122021",
|
|
||||||
"rx_errors": "0",
|
|
||||||
"tx_bytes": "52350",
|
|
||||||
"tx_acl": "0",
|
|
||||||
"tx_sco": "0",
|
|
||||||
"tx_commands": "3480",
|
|
||||||
"tx_errors": "2",
|
|
||||||
"features": [
|
|
||||||
"0xff",
|
|
||||||
"0xff",
|
|
||||||
"0x8f",
|
|
||||||
"0xfe",
|
|
||||||
"0xdb",
|
|
||||||
"0xff",
|
|
||||||
"0x5b",
|
|
||||||
"0x87"
|
|
||||||
],
|
|
||||||
"packet_type": [
|
|
||||||
"DM1",
|
|
||||||
"DM3",
|
|
||||||
"DM5",
|
|
||||||
"DH1",
|
|
||||||
"DH3",
|
|
||||||
"DH5",
|
|
||||||
"HV1",
|
|
||||||
"HV2",
|
|
||||||
"HV3"
|
|
||||||
],
|
|
||||||
"link_policy": [
|
|
||||||
"RSWITCH",
|
|
||||||
"HOLD",
|
|
||||||
"SNIFF",
|
|
||||||
"PARK"
|
|
||||||
],
|
|
||||||
"link_mode": [
|
|
||||||
"SLAVE",
|
|
||||||
"ACCEPT"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.hciconfig.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.history"></a>
|
||||||
|
|
||||||
# jc.parsers.history
|
# jc.parsers.history
|
||||||
|
|
||||||
jc - JSON CLI output utility `history` command output parser
|
jc - JSON CLI output utility `history` command output parser
|
||||||
|
|
||||||
This parser will output a list of dictionaries each containing `line` and
|
This parser will output a list of dictionaries each containing `line` and
|
||||||
@ -13,83 +15,93 @@ builtin.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ history | jc --history
|
$ history | jc --history
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('history', history_command_output)
|
result = jc.parse('history', history_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.history
|
import jc.parsers.history
|
||||||
result = jc.parsers.history.parse(history_command_output)
|
result = jc.parsers.history.parse(history_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"line": integer,
|
"line": integer,
|
||||||
"command": string
|
"command": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ history | jc --history -p
|
|
||||||
[
|
$ history | jc --history -p
|
||||||
{
|
[
|
||||||
"line": 118,
|
{
|
||||||
"command": "sleep 100"
|
- `"line"` - 118,
|
||||||
},
|
- `"command"` - "sleep 100"
|
||||||
{
|
},
|
||||||
"line": 119,
|
{
|
||||||
"command": "ls /bin"
|
- `"line"` - 119,
|
||||||
},
|
- `"command"` - "ls /bin"
|
||||||
{
|
},
|
||||||
"line": 120,
|
{
|
||||||
"command": "echo "hello""
|
- `"line"` - 120,
|
||||||
},
|
- `"command"` - "echo \"hello\""
|
||||||
{
|
},
|
||||||
"line": 121,
|
{
|
||||||
"command": "docker images"
|
- `"line"` - 121,
|
||||||
},
|
- `"command"` - "docker images"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ history | jc --history -p -r
|
||||||
|
{
|
||||||
|
- `"118"` - "sleep 100",
|
||||||
|
- `"119"` - "ls /bin",
|
||||||
|
- `"120"` - "echo \"hello\"",
|
||||||
|
- `"121"` - "docker images",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
$ history | jc --history -p -r
|
<a id="jc.parsers.history.info"></a>
|
||||||
{
|
|
||||||
"118": "sleep 100",
|
|
||||||
"119": "ls /bin",
|
|
||||||
"120": "echo "hello"",
|
|
||||||
"121": "docker images",
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.history.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary of raw structured data or
|
|
||||||
List of Dictionaries of processed structured data
|
Dictionary of raw structured data or
|
||||||
|
List of Dictionaries of processed structured data
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,105 +1,117 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.hosts"></a>
|
||||||
|
|
||||||
# jc.parsers.hosts
|
# jc.parsers.hosts
|
||||||
|
|
||||||
jc - JSON CLI output utility `/etc/hosts` file parser
|
jc - JSON CLI output utility `/etc/hosts` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat /etc/hosts | jc --hosts
|
$ cat /etc/hosts | jc --hosts
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('hosts', hosts_file_output)
|
result = jc.parse('hosts', hosts_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.hosts
|
import jc.parsers.hosts
|
||||||
result = jc.parsers.hosts.parse(hosts_file_output)
|
result = jc.parsers.hosts.parse(hosts_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"ip": string,
|
"ip": string,
|
||||||
"hostname": [
|
"hostname": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat /etc/hosts | jc --hosts -p
|
|
||||||
[
|
$ cat /etc/hosts | jc --hosts -p
|
||||||
{
|
[
|
||||||
"ip": "127.0.0.1",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "127.0.0.1",
|
||||||
"localhost"
|
- `"hostname"` - [
|
||||||
]
|
"localhost"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ip": "127.0.1.1",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "127.0.1.1",
|
||||||
"root-ubuntu"
|
- `"hostname"` - [
|
||||||
]
|
"root-ubuntu"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ip": "::1",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "::1",
|
||||||
"ip6-localhost",
|
- `"hostname"` - [
|
||||||
"ip6-loopback"
|
"ip6-localhost",
|
||||||
]
|
"ip6-loopback"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ip": "fe00::0",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "fe00::0",
|
||||||
"ip6-localnet"
|
- `"hostname"` - [
|
||||||
]
|
"ip6-localnet"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ip": "ff00::0",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "ff00::0",
|
||||||
"ip6-mcastprefix"
|
- `"hostname"` - [
|
||||||
]
|
"ip6-mcastprefix"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ip": "ff02::1",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "ff02::1",
|
||||||
"ip6-allnodes"
|
- `"hostname"` - [
|
||||||
]
|
"ip6-allnodes"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"ip": "ff02::2",
|
{
|
||||||
"hostname": [
|
- `"ip"` - "ff02::2",
|
||||||
"ip6-allrouters"
|
- `"hostname"` - [
|
||||||
]
|
"ip6-allrouters"
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.hosts.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.hosts.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,136 +1,148 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.id"></a>
|
||||||
|
|
||||||
# jc.parsers.id
|
# jc.parsers.id
|
||||||
|
|
||||||
jc - JSON CLI output utility `id` command output parser
|
jc - JSON CLI output utility `id` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ id | jc --id
|
$ id | jc --id
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc id
|
$ jc id
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('id', id_command_output)
|
result = jc.parse('id', id_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.id
|
import jc.parsers.id
|
||||||
result = jc.parsers.id.parse(id_command_output)
|
result = jc.parsers.id.parse(id_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"uid": {
|
"uid": {
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"name": string
|
"name": string
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"name": string
|
"name": string
|
||||||
},
|
},
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"name": string
|
"name": string
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": integer,
|
"id": integer,
|
||||||
"name": string
|
"name": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"context": {
|
"context": {
|
||||||
"user": string,
|
"user": string,
|
||||||
"role": string,
|
"role": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"level": string
|
"level": string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ id | jc --id -p
|
|
||||||
{
|
$ id | jc --id -p
|
||||||
"uid": {
|
{
|
||||||
"id": 1000,
|
- `"uid"` - {
|
||||||
"name": "joeuser"
|
- `"id"` - 1000,
|
||||||
},
|
- `"name"` - "joeuser"
|
||||||
"gid": {
|
},
|
||||||
"id": 1000,
|
- `"gid"` - {
|
||||||
"name": "joeuser"
|
- `"id"` - 1000,
|
||||||
},
|
- `"name"` - "joeuser"
|
||||||
"groups": [
|
},
|
||||||
{
|
- `"groups"` - [
|
||||||
"id": 1000,
|
{
|
||||||
"name": "joeuser"
|
- `"id"` - 1000,
|
||||||
},
|
- `"name"` - "joeuser"
|
||||||
{
|
},
|
||||||
"id": 10,
|
{
|
||||||
"name": "wheel"
|
- `"id"` - 10,
|
||||||
}
|
- `"name"` - "wheel"
|
||||||
],
|
}
|
||||||
"context": {
|
],
|
||||||
"user": "unconfined_u",
|
- `"context"` - {
|
||||||
"role": "unconfined_r",
|
- `"user"` - "unconfined_u",
|
||||||
"type": "unconfined_t",
|
- `"role"` - "unconfined_r",
|
||||||
"level": "s0-s0:c0.c1023"
|
- `"type"` - "unconfined_t",
|
||||||
}
|
- `"level"` - "s0-s0:c0.c1023"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ id | jc --id -p -r
|
||||||
|
{
|
||||||
|
- `"uid"` - {
|
||||||
|
- `"id"` - "1000",
|
||||||
|
- `"name"` - "joeuser"
|
||||||
|
},
|
||||||
|
- `"gid"` - {
|
||||||
|
- `"id"` - "1000",
|
||||||
|
- `"name"` - "joeuser"
|
||||||
|
},
|
||||||
|
- `"groups"` - [
|
||||||
|
{
|
||||||
|
- `"id"` - "1000",
|
||||||
|
- `"name"` - "joeuser"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"id"` - "10",
|
||||||
|
- `"name"` - "wheel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"context"` - {
|
||||||
|
- `"user"` - "unconfined_u",
|
||||||
|
- `"role"` - "unconfined_r",
|
||||||
|
- `"type"` - "unconfined_t",
|
||||||
|
- `"level"` - "s0-s0:c0.c1023"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ id | jc --id -p -r
|
<a id="jc.parsers.id.info"></a>
|
||||||
{
|
|
||||||
"uid": {
|
|
||||||
"id": "1000",
|
|
||||||
"name": "joeuser"
|
|
||||||
},
|
|
||||||
"gid": {
|
|
||||||
"id": "1000",
|
|
||||||
"name": "joeuser"
|
|
||||||
},
|
|
||||||
"groups": [
|
|
||||||
{
|
|
||||||
"id": "1000",
|
|
||||||
"name": "joeuser"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "10",
|
|
||||||
"name": "wheel"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"context": {
|
|
||||||
"user": "unconfined_u",
|
|
||||||
"role": "unconfined_r",
|
|
||||||
"type": "unconfined_t",
|
|
||||||
"level": "s0-s0:c0.c1023"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.id.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,217 +1,323 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ifconfig"></a>
|
||||||
|
|
||||||
# jc.parsers.ifconfig
|
# jc.parsers.ifconfig
|
||||||
|
|
||||||
jc - JSON CLI output utility `ifconfig` command output parser
|
jc - JSON CLI output utility `ifconfig` command output parser
|
||||||
|
|
||||||
Note: No `ifconfig` options are supported.
|
Note: No `ifconfig` options are supported.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig
|
$ ifconfig | jc --ifconfig
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ifconfig
|
$ jc ifconfig
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ifconfig', ifconfig_command_output)
|
result = jc.parse('ifconfig', ifconfig_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ifconfig
|
import jc.parsers.ifconfig
|
||||||
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
|
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"flags": integer,
|
"flags": integer,
|
||||||
"state": [
|
"state": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"mtu": integer,
|
"mtu": integer,
|
||||||
"ipv4_addr": string,
|
"ipv4_addr": string,
|
||||||
"ipv4_mask": string,
|
"ipv4_mask": string,
|
||||||
"ipv4_bcast": string,
|
"ipv4_bcast": string,
|
||||||
"ipv6_addr": string,
|
"ipv6_addr": string,
|
||||||
"ipv6_mask": integer,
|
"ipv6_mask": integer,
|
||||||
"ipv6_scope": string,
|
"ipv6_scope": string,
|
||||||
"mac_addr": string,
|
"mac_addr": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"rx_packets": integer,
|
"rx_packets": integer,
|
||||||
"rx_bytes": integer,
|
"rx_bytes": integer,
|
||||||
"rx_errors": integer,
|
"rx_errors": integer,
|
||||||
"rx_dropped": integer,
|
"rx_dropped": integer,
|
||||||
"rx_overruns": integer,
|
"rx_overruns": integer,
|
||||||
"rx_frame": integer,
|
"rx_frame": integer,
|
||||||
"tx_packets": integer,
|
"tx_packets": integer,
|
||||||
"tx_bytes": integer,
|
"tx_bytes": integer,
|
||||||
"tx_errors": integer,
|
"tx_errors": integer,
|
||||||
"tx_dropped": integer,
|
"tx_dropped": integer,
|
||||||
"tx_overruns": integer,
|
"tx_overruns": integer,
|
||||||
"tx_carrier": integer,
|
"tx_carrier": integer,
|
||||||
"tx_collisions": integer,
|
"tx_collisions": integer,
|
||||||
"metric": integer
|
"metric": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p
|
|
||||||
[
|
$ ifconfig | jc --ifconfig -p
|
||||||
{
|
[
|
||||||
"name": "ens33",
|
{
|
||||||
"flags": 4163,
|
- `"name"` - "ens33",
|
||||||
"state": [
|
- `"flags"` - 4163,
|
||||||
"UP",
|
- `"state"` - [
|
||||||
"BROADCAST",
|
"UP",
|
||||||
"RUNNING",
|
"BROADCAST",
|
||||||
"MULTICAST"
|
"RUNNING",
|
||||||
],
|
"MULTICAST"
|
||||||
"mtu": 1500,
|
],
|
||||||
"ipv4_addr": "192.168.71.137",
|
- `"mtu"` - 1500,
|
||||||
"ipv4_mask": "255.255.255.0",
|
- `"ipv4_addr"` - "192.168.71.137",
|
||||||
"ipv4_bcast": "192.168.71.255",
|
- `"ipv4_mask"` - "255.255.255.0",
|
||||||
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
|
- `"ipv4_bcast"` - "192.168.71.255",
|
||||||
"ipv6_mask": 64,
|
- `"ipv6_addr"` - "fe80::c1cb:715d:bc3e:b8a0",
|
||||||
"ipv6_scope": "0x20",
|
- `"ipv6_mask"` - 64,
|
||||||
"mac_addr": "00:0c:29:3b:58:0e",
|
- `"ipv6_scope"` - "0x20",
|
||||||
"type": "Ethernet",
|
- `"mac_addr"` - "00:0c:29:3b:58:0e",
|
||||||
"rx_packets": 8061,
|
- `"type"` - "Ethernet",
|
||||||
"rx_bytes": 1514413,
|
- `"rx_packets"` - 8061,
|
||||||
"rx_errors": 0,
|
- `"rx_bytes"` - 1514413,
|
||||||
"rx_dropped": 0,
|
- `"rx_errors"` - 0,
|
||||||
"rx_overruns": 0,
|
- `"rx_dropped"` - 0,
|
||||||
"rx_frame": 0,
|
- `"rx_overruns"` - 0,
|
||||||
"tx_packets": 4502,
|
- `"rx_frame"` - 0,
|
||||||
"tx_bytes": 866622,
|
- `"tx_packets"` - 4502,
|
||||||
"tx_errors": 0,
|
- `"tx_bytes"` - 866622,
|
||||||
"tx_dropped": 0,
|
- `"tx_errors"` - 0,
|
||||||
"tx_overruns": 0,
|
- `"tx_dropped"` - 0,
|
||||||
"tx_carrier": 0,
|
- `"tx_overruns"` - 0,
|
||||||
"tx_collisions": 0,
|
- `"tx_carrier"` - 0,
|
||||||
"metric": null
|
- `"tx_collisions"` - 0,
|
||||||
},
|
- `"metric"` - null
|
||||||
{
|
},
|
||||||
"name": "lo",
|
{
|
||||||
"flags": 73,
|
- `"name"` - "lo",
|
||||||
"state": [
|
- `"flags"` - 73,
|
||||||
"UP",
|
- `"state"` - [
|
||||||
"LOOPBACK",
|
"UP",
|
||||||
"RUNNING"
|
"LOOPBACK",
|
||||||
],
|
"RUNNING"
|
||||||
"mtu": 65536,
|
],
|
||||||
"ipv4_addr": "127.0.0.1",
|
- `"mtu"` - 65536,
|
||||||
"ipv4_mask": "255.0.0.0",
|
- `"ipv4_addr"` - "127.0.0.1",
|
||||||
"ipv4_bcast": null,
|
- `"ipv4_mask"` - "255.0.0.0",
|
||||||
"ipv6_addr": "::1",
|
- `"ipv4_bcast"` - null,
|
||||||
"ipv6_mask": 128,
|
- `"ipv6_addr"` - "::1",
|
||||||
"ipv6_scope": "0x10",
|
- `"ipv6_mask"` - 128,
|
||||||
"mac_addr": null,
|
- `"ipv6_scope"` - "0x10",
|
||||||
"type": "Local Loopback",
|
- `"mac_addr"` - null,
|
||||||
"rx_packets": 73,
|
- `"type"` - "Local Loopback",
|
||||||
"rx_bytes": 6009,
|
- `"rx_packets"` - 73,
|
||||||
"rx_errors": 0,
|
- `"rx_bytes"` - 6009,
|
||||||
"rx_dropped": 0,
|
- `"rx_errors"` - 0,
|
||||||
"rx_overruns": 0,
|
- `"rx_dropped"` - 0,
|
||||||
"rx_frame": 0,
|
- `"rx_overruns"` - 0,
|
||||||
"tx_packets": 73,
|
- `"rx_frame"` - 0,
|
||||||
"tx_bytes": 6009,
|
- `"tx_packets"` - 73,
|
||||||
"tx_errors": 0,
|
- `"tx_bytes"` - 6009,
|
||||||
"tx_dropped": 0,
|
- `"tx_errors"` - 0,
|
||||||
"tx_overruns": 0,
|
- `"tx_dropped"` - 0,
|
||||||
"tx_carrier": 0,
|
- `"tx_overruns"` - 0,
|
||||||
"tx_collisions": 0,
|
- `"tx_carrier"` - 0,
|
||||||
"metric": null
|
- `"tx_collisions"` - 0,
|
||||||
}
|
- `"metric"` - null
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ifconfig | jc --ifconfig -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"name"` - "ens33",
|
||||||
|
- `"flags"` - "4163",
|
||||||
|
- `"state"` - "UP,BROADCAST,RUNNING,MULTICAST",
|
||||||
|
- `"mtu"` - "1500",
|
||||||
|
- `"ipv4_addr"` - "192.168.71.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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ ifconfig | jc --ifconfig -p -r
|
<a id="jc.parsers.ifconfig.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ifconfig._IfconfigParser"></a>
|
||||||
|
|
||||||
|
## \_IfconfigParser Objects
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
class _IfconfigParser(object)
|
||||||
|
```
|
||||||
|
|
||||||
|
ifconfig parser module written by threeheadedknight@protonmail.com
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.__init__"></a>
|
||||||
|
|
||||||
|
#### \_\_init\_\_
|
||||||
|
|
||||||
|
```python
|
||||||
|
def __init__(console_output)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
|
||||||
|
- `console_output`:
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.list_interfaces"></a>
|
||||||
|
|
||||||
|
#### list\_interfaces
|
||||||
|
|
||||||
|
```python
|
||||||
|
def list_interfaces()
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.count_interfaces"></a>
|
||||||
|
|
||||||
|
#### count\_interfaces
|
||||||
|
|
||||||
|
```python
|
||||||
|
def count_interfaces()
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.filter_interfaces"></a>
|
||||||
|
|
||||||
|
#### filter\_interfaces
|
||||||
|
|
||||||
|
```python
|
||||||
|
def filter_interfaces(**kwargs)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
|
||||||
|
- `kwargs`:
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.get_interface"></a>
|
||||||
|
|
||||||
|
#### get\_interface
|
||||||
|
|
||||||
|
```python
|
||||||
|
def get_interface(name)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
|
||||||
|
- `name`:
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.get_interfaces"></a>
|
||||||
|
|
||||||
|
#### get\_interfaces
|
||||||
|
|
||||||
|
```python
|
||||||
|
def get_interfaces()
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.is_available"></a>
|
||||||
|
|
||||||
|
#### is\_available
|
||||||
|
|
||||||
|
```python
|
||||||
|
def is_available(name)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
|
||||||
|
- `name`:
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig._IfconfigParser.parser"></a>
|
||||||
|
|
||||||
|
#### parser
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parser(source_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Arguments**:
|
||||||
|
|
||||||
|
- `source_data`:
|
||||||
|
|
||||||
|
<a id="jc.parsers.ifconfig.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, aix, freebsd, darwin
|
Compatibility: linux, aix, freebsd, darwin
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ini"></a>
|
||||||
|
|
||||||
# jc.parsers.ini
|
# jc.parsers.ini
|
||||||
|
|
||||||
jc - JSON CLI output utility `INI` file parser
|
jc - JSON CLI output utility `INI` file parser
|
||||||
|
|
||||||
Parses standard `INI` files and files containing simple key/value pairs.
|
Parses standard `INI` files and files containing simple key/value pairs.
|
||||||
@ -13,85 +15,95 @@ command-line argument or the `raw=True` argument in `parse()`.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat foo.ini | jc --ini
|
$ cat foo.ini | jc --ini
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ini', ini_file_output)
|
result = jc.parse('ini', ini_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ini
|
import jc.parsers.ini
|
||||||
result = jc.parsers.ini.parse(ini_file_output)
|
result = jc.parsers.ini.parse(ini_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
ini or key/value document converted to a dictionary - see the
|
ini or key/value document converted to a dictionary - see the
|
||||||
configparser standard library documentation for more details.
|
configparser standard library documentation for more details.
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string,
|
"key1": string,
|
||||||
"key2": string
|
"key2": string
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat example.ini
|
|
||||||
[DEFAULT]
|
$ cat example.ini
|
||||||
ServerAliveInterval = 45
|
[DEFAULT]
|
||||||
Compression = yes
|
ServerAliveInterval = 45
|
||||||
CompressionLevel = 9
|
Compression = yes
|
||||||
ForwardX11 = yes
|
CompressionLevel = 9
|
||||||
|
ForwardX11 = yes
|
||||||
|
|
||||||
|
[bitbucket.org]
|
||||||
|
User = hg
|
||||||
|
|
||||||
|
[topsecret.server.com]
|
||||||
|
Port = 50022
|
||||||
|
ForwardX11 = no
|
||||||
|
|
||||||
|
$ cat example.ini | jc --ini -p
|
||||||
|
{
|
||||||
|
- `"bitbucket.org"` - {
|
||||||
|
- `"serveraliveinterval"` - "45",
|
||||||
|
- `"compression"` - "yes",
|
||||||
|
- `"compressionlevel"` - "9",
|
||||||
|
- `"forwardx11"` - "yes",
|
||||||
|
- `"user"` - "hg"
|
||||||
|
},
|
||||||
|
- `"topsecret.server.com"` - {
|
||||||
|
- `"serveraliveinterval"` - "45",
|
||||||
|
- `"compression"` - "yes",
|
||||||
|
- `"compressionlevel"` - "9",
|
||||||
|
- `"forwardx11"` - "no",
|
||||||
|
- `"port"` - "50022"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[bitbucket.org]
|
<a id="jc.parsers.ini.info"></a>
|
||||||
User = hg
|
|
||||||
|
|
||||||
[topsecret.server.com]
|
## info Objects
|
||||||
Port = 50022
|
|
||||||
ForwardX11 = no
|
|
||||||
|
|
||||||
$ cat example.ini | jc --ini -p
|
|
||||||
{
|
|
||||||
"bitbucket.org": {
|
|
||||||
"serveraliveinterval": "45",
|
|
||||||
"compression": "yes",
|
|
||||||
"compressionlevel": "9",
|
|
||||||
"forwardx11": "yes",
|
|
||||||
"user": "hg"
|
|
||||||
},
|
|
||||||
"topsecret.server.com": {
|
|
||||||
"serveraliveinterval": "45",
|
|
||||||
"compression": "yes",
|
|
||||||
"compressionlevel": "9",
|
|
||||||
"forwardx11": "no",
|
|
||||||
"port": "50022"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ini.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary representing the ini file
|
|
||||||
|
Dictionary representing the ini file
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,190 +1,202 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.iostat"></a>
|
||||||
|
|
||||||
# jc.parsers.iostat
|
# jc.parsers.iostat
|
||||||
|
|
||||||
jc - JSON CLI output utility `iostat` command output parser
|
jc - JSON CLI output utility `iostat` command output parser
|
||||||
|
|
||||||
Note: `iostat` version 11 and higher include a JSON output option
|
Note: `iostat` version 11 and higher include a JSON output option
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ iostat | jc --iostat
|
$ iostat | jc --iostat
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc iostat
|
$ jc iostat
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('iostat', iostat_command_output)
|
result = jc.parse('iostat', iostat_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.iostat
|
import jc.parsers.iostat
|
||||||
result = jc.parsers.iostat.parse(iostat_command_output)
|
result = jc.parsers.iostat.parse(iostat_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": string,
|
"type": string,
|
||||||
"percent_user": float,
|
"percent_user": float,
|
||||||
"percent_nice": float,
|
"percent_nice": float,
|
||||||
"percent_system": float,
|
"percent_system": float,
|
||||||
"percent_iowait": float,
|
"percent_iowait": float,
|
||||||
"percent_steal": float,
|
"percent_steal": float,
|
||||||
"percent_idle": float,
|
"percent_idle": float,
|
||||||
"device": string,
|
"device": string,
|
||||||
"tps": float,
|
"tps": float,
|
||||||
"kb_read_s": float,
|
"kb_read_s": float,
|
||||||
"mb_read_s": float,
|
"mb_read_s": float,
|
||||||
"kb_wrtn_s": float,
|
"kb_wrtn_s": float,
|
||||||
"mb_wrtn_s": float,
|
"mb_wrtn_s": float,
|
||||||
"kb_read": integer,
|
"kb_read": integer,
|
||||||
"mb_read": integer,
|
"mb_read": integer,
|
||||||
"kb_wrtn": integer,
|
"kb_wrtn": integer,
|
||||||
"mb_wrtn": integer,
|
"mb_wrtn": integer,
|
||||||
'kb_dscd': integer,
|
'kb_dscd': integer,
|
||||||
'mb_dscd': integer,
|
'mb_dscd': integer,
|
||||||
"rrqm_s": float,
|
"rrqm_s": float,
|
||||||
"wrqm_s": float,
|
"wrqm_s": float,
|
||||||
"r_s": float,
|
"r_s": float,
|
||||||
"w_s": float,
|
"w_s": float,
|
||||||
"rmb_s": float,
|
"rmb_s": float,
|
||||||
"rkb_s": float,
|
"rkb_s": float,
|
||||||
"wmb_s": float,
|
"wmb_s": float,
|
||||||
"wkb_s": float,
|
"wkb_s": float,
|
||||||
"avgrq_sz": float,
|
"avgrq_sz": float,
|
||||||
"avgqu_sz": float,
|
"avgqu_sz": float,
|
||||||
"await": float,
|
"await": float,
|
||||||
"r_await": float,
|
"r_await": float,
|
||||||
"w_await": float,
|
"w_await": float,
|
||||||
"svctm": float,
|
"svctm": float,
|
||||||
"aqu_sz": float,
|
"aqu_sz": float,
|
||||||
"rareq_sz": float,
|
"rareq_sz": float,
|
||||||
"wareq_sz": float,
|
"wareq_sz": float,
|
||||||
"d_s": float,
|
"d_s": float,
|
||||||
"dkb_s": float,
|
"dkb_s": float,
|
||||||
"dmb_s": float,
|
"dmb_s": float,
|
||||||
"drqm_s": float,
|
"drqm_s": float,
|
||||||
"percent_drqm": float,
|
"percent_drqm": float,
|
||||||
"d_await": float,
|
"d_await": float,
|
||||||
"dareq_sz": float,
|
"dareq_sz": float,
|
||||||
"f_s": float,
|
"f_s": float,
|
||||||
"f_await": float,
|
"f_await": float,
|
||||||
"kb_dscd_s": float,
|
"kb_dscd_s": float,
|
||||||
"mb_dscd_s": float,
|
"mb_dscd_s": float,
|
||||||
"percent_util": float,
|
"percent_util": float,
|
||||||
"percent_rrqm": float,
|
"percent_rrqm": float,
|
||||||
"percent_wrqm": float
|
"percent_wrqm": float
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ iostat | jc --iostat -p
|
|
||||||
[
|
$ iostat | jc --iostat -p
|
||||||
{
|
[
|
||||||
"percent_user": 0.15,
|
{
|
||||||
"percent_nice": 0.0,
|
- `"percent_user"` - 0.15,
|
||||||
"percent_system": 0.18,
|
- `"percent_nice"` - 0.0,
|
||||||
"percent_iowait": 0.0,
|
- `"percent_system"` - 0.18,
|
||||||
"percent_steal": 0.0,
|
- `"percent_iowait"` - 0.0,
|
||||||
"percent_idle": 99.67,
|
- `"percent_steal"` - 0.0,
|
||||||
"type": "cpu"
|
- `"percent_idle"` - 99.67,
|
||||||
},
|
- `"type"` - "cpu"
|
||||||
{
|
},
|
||||||
"device": "sda",
|
{
|
||||||
"tps": 0.29,
|
- `"device"` - "sda",
|
||||||
"kb_read_s": 7.22,
|
- `"tps"` - 0.29,
|
||||||
"kb_wrtn_s": 1.25,
|
- `"kb_read_s"` - 7.22,
|
||||||
"kb_read": 194341,
|
- `"kb_wrtn_s"` - 1.25,
|
||||||
"kb_wrtn": 33590,
|
- `"kb_read"` - 194341,
|
||||||
"type": "device"
|
- `"kb_wrtn"` - 33590,
|
||||||
},
|
- `"type"` - "device"
|
||||||
{
|
},
|
||||||
"device": "dm-0",
|
{
|
||||||
"tps": 0.29,
|
- `"device"` - "dm-0",
|
||||||
"kb_read_s": 5.99,
|
- `"tps"` - 0.29,
|
||||||
"kb_wrtn_s": 1.17,
|
- `"kb_read_s"` - 5.99,
|
||||||
"kb_read": 161361,
|
- `"kb_wrtn_s"` - 1.17,
|
||||||
"kb_wrtn": 31522,
|
- `"kb_read"` - 161361,
|
||||||
"type": "device"
|
- `"kb_wrtn"` - 31522,
|
||||||
},
|
- `"type"` - "device"
|
||||||
{
|
},
|
||||||
"device": "dm-1",
|
{
|
||||||
"tps": 0.0,
|
- `"device"` - "dm-1",
|
||||||
"kb_read_s": 0.08,
|
- `"tps"` - 0.0,
|
||||||
"kb_wrtn_s": 0.0,
|
- `"kb_read_s"` - 0.08,
|
||||||
"kb_read": 2204,
|
- `"kb_wrtn_s"` - 0.0,
|
||||||
"kb_wrtn": 0,
|
- `"kb_read"` - 2204,
|
||||||
"type": "device"
|
- `"kb_wrtn"` - 0,
|
||||||
}
|
- `"type"` - "device"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ iostat | jc --iostat -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"percent_user"` - "0.15",
|
||||||
|
- `"percent_nice"` - "0.00",
|
||||||
|
- `"percent_system"` - "0.18",
|
||||||
|
- `"percent_iowait"` - "0.00",
|
||||||
|
- `"percent_steal"` - "0.00",
|
||||||
|
- `"percent_idle"` - "99.67",
|
||||||
|
- `"type"` - "cpu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "sda",
|
||||||
|
- `"tps"` - "0.29",
|
||||||
|
- `"kb_read_s"` - "7.22",
|
||||||
|
- `"kb_wrtn_s"` - "1.25",
|
||||||
|
- `"kb_read"` - "194341",
|
||||||
|
- `"kb_wrtn"` - "33590",
|
||||||
|
- `"type"` - "device"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "dm-0",
|
||||||
|
- `"tps"` - "0.29",
|
||||||
|
- `"kb_read_s"` - "5.99",
|
||||||
|
- `"kb_wrtn_s"` - "1.17",
|
||||||
|
- `"kb_read"` - "161361",
|
||||||
|
- `"kb_wrtn"` - "31522",
|
||||||
|
- `"type"` - "device"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "dm-1",
|
||||||
|
- `"tps"` - "0.00",
|
||||||
|
- `"kb_read_s"` - "0.08",
|
||||||
|
- `"kb_wrtn_s"` - "0.00",
|
||||||
|
- `"kb_read"` - "2204",
|
||||||
|
- `"kb_wrtn"` - "0",
|
||||||
|
- `"type"` - "device"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ iostat | jc --iostat -p -r
|
<a id="jc.parsers.iostat.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"percent_user": "0.15",
|
|
||||||
"percent_nice": "0.00",
|
|
||||||
"percent_system": "0.18",
|
|
||||||
"percent_iowait": "0.00",
|
|
||||||
"percent_steal": "0.00",
|
|
||||||
"percent_idle": "99.67",
|
|
||||||
"type": "cpu"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "sda",
|
|
||||||
"tps": "0.29",
|
|
||||||
"kb_read_s": "7.22",
|
|
||||||
"kb_wrtn_s": "1.25",
|
|
||||||
"kb_read": "194341",
|
|
||||||
"kb_wrtn": "33590",
|
|
||||||
"type": "device"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "dm-0",
|
|
||||||
"tps": "0.29",
|
|
||||||
"kb_read_s": "5.99",
|
|
||||||
"kb_wrtn_s": "1.17",
|
|
||||||
"kb_read": "161361",
|
|
||||||
"kb_wrtn": "31522",
|
|
||||||
"type": "device"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "dm-1",
|
|
||||||
"tps": "0.00",
|
|
||||||
"kb_read_s": "0.08",
|
|
||||||
"kb_wrtn_s": "0.00",
|
|
||||||
"kb_read": "2204",
|
|
||||||
"kb_wrtn": "0",
|
|
||||||
"type": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.iostat.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.iostat_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.iostat\_s
|
||||||
|
|
||||||
# jc.parsers.iostat_s
|
|
||||||
jc - JSON CLI output utility `iostat` command output streaming parser
|
jc - JSON CLI output utility `iostat` command output streaming parser
|
||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
@ -9,130 +11,142 @@ Note: `iostat` version 11 and higher include a JSON output option
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ iostat | jc --iostat-s
|
$ iostat | jc --iostat-s
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parse('iostat_s', iostat_command_output.splitlines())
|
result = jc.parse('iostat_s', iostat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.iostat_s
|
import jc.parsers.iostat_s
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines())
|
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": string,
|
"type": string,
|
||||||
"percent_user": float,
|
"percent_user": float,
|
||||||
"percent_nice": float,
|
"percent_nice": float,
|
||||||
"percent_system": float,
|
"percent_system": float,
|
||||||
"percent_iowait": float,
|
"percent_iowait": float,
|
||||||
"percent_steal": float,
|
"percent_steal": float,
|
||||||
"percent_idle": float,
|
"percent_idle": float,
|
||||||
"device": string,
|
"device": string,
|
||||||
"tps": float,
|
"tps": float,
|
||||||
"kb_read_s": float,
|
"kb_read_s": float,
|
||||||
"mb_read_s": float,
|
"mb_read_s": float,
|
||||||
"kb_wrtn_s": float,
|
"kb_wrtn_s": float,
|
||||||
"mb_wrtn_s": float,
|
"mb_wrtn_s": float,
|
||||||
"kb_read": integer,
|
"kb_read": integer,
|
||||||
"mb_read": integer,
|
"mb_read": integer,
|
||||||
"kb_wrtn": integer,
|
"kb_wrtn": integer,
|
||||||
"mb_wrtn": integer,
|
"mb_wrtn": integer,
|
||||||
'kb_dscd': integer,
|
'kb_dscd': integer,
|
||||||
'mb_dscd': integer,
|
'mb_dscd': integer,
|
||||||
"rrqm_s": float,
|
"rrqm_s": float,
|
||||||
"wrqm_s": float,
|
"wrqm_s": float,
|
||||||
"r_s": float,
|
"r_s": float,
|
||||||
"w_s": float,
|
"w_s": float,
|
||||||
"rmb_s": float,
|
"rmb_s": float,
|
||||||
"rkb_s": float,
|
"rkb_s": float,
|
||||||
"wmb_s": float,
|
"wmb_s": float,
|
||||||
"wkb_s": float,
|
"wkb_s": float,
|
||||||
"avgrq_sz": float,
|
"avgrq_sz": float,
|
||||||
"avgqu_sz": float,
|
"avgqu_sz": float,
|
||||||
"await": float,
|
"await": float,
|
||||||
"r_await": float,
|
"r_await": float,
|
||||||
"w_await": float,
|
"w_await": float,
|
||||||
"svctm": float,
|
"svctm": float,
|
||||||
"aqu_sz": float,
|
"aqu_sz": float,
|
||||||
"rareq_sz": float,
|
"rareq_sz": float,
|
||||||
"wareq_sz": float,
|
"wareq_sz": float,
|
||||||
"d_s": float,
|
"d_s": float,
|
||||||
"dkb_s": float,
|
"dkb_s": float,
|
||||||
"dmb_s": float,
|
"dmb_s": float,
|
||||||
"drqm_s": float,
|
"drqm_s": float,
|
||||||
"percent_drqm": float,
|
"percent_drqm": float,
|
||||||
"d_await": float,
|
"d_await": float,
|
||||||
"dareq_sz": float,
|
"dareq_sz": float,
|
||||||
"f_s": float,
|
"f_s": float,
|
||||||
"f_await": float,
|
"f_await": float,
|
||||||
"kb_dscd_s": float,
|
"kb_dscd_s": float,
|
||||||
"mb_dscd_s": float,
|
"mb_dscd_s": float,
|
||||||
"percent_util": float,
|
"percent_util": float,
|
||||||
"percent_rrqm": float,
|
"percent_rrqm": float,
|
||||||
"percent_wrqm": float,
|
"percent_wrqm": float,
|
||||||
|
|
||||||
# Below object only exists if using -qq or ignore_exceptions=True
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
"_jc_meta":
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # false if error parsing
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ iostat | jc --iostat-s
|
|
||||||
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...}
|
$ iostat | jc --iostat-s
|
||||||
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1...}
|
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...}
|
||||||
...
|
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1...}
|
||||||
|
...
|
||||||
|
|
||||||
|
$ iostat | jc --iostat-s -r
|
||||||
|
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16"...}
|
||||||
|
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...}
|
||||||
|
...
|
||||||
|
|
||||||
$ iostat | jc --iostat-s -r
|
<a id="jc.parsers.iostat_s.info"></a>
|
||||||
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16"...}
|
|
||||||
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...}
|
|
||||||
...
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.iostat_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse
|
|
||||||
(e.g. sys.stdin or str.splitlines())
|
- `data` - (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
|
||||||
|
|
||||||
raw: (boolean) unprocessed output if True
|
**Yields**:
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
**Returns**:
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
Iterator object
|
||||||
Iterator object
|
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,194 +1,206 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.iptables"></a>
|
||||||
|
|
||||||
# jc.parsers.iptables
|
# jc.parsers.iptables
|
||||||
|
|
||||||
jc - JSON CLI output utility `iptables` command output parser
|
jc - JSON CLI output utility `iptables` command output parser
|
||||||
|
|
||||||
Supports `-vLn` and `--line-numbers` for all tables.
|
Supports `-vLn` and `--line-numbers` for all tables.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ sudo iptables -L -t nat | jc --iptables
|
$ sudo iptables -L -t nat | jc --iptables
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc iptables -L -t nat
|
$ jc iptables -L -t nat
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('iptables', iptables_command_output)
|
result = jc.parse('iptables', iptables_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.iptables
|
import jc.parsers.iptables
|
||||||
result = jc.parsers.iptables.parse(iptables_command_output)
|
result = jc.parsers.iptables.parse(iptables_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"chain": string,
|
"chain": string,
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"num" integer,
|
"num" integer,
|
||||||
"pkts": integer,
|
"pkts": integer,
|
||||||
"bytes": integer, # converted based on suffix
|
"bytes": integer, # converted based on suffix
|
||||||
"target": string,
|
"target": string,
|
||||||
"prot": string,
|
"prot": string,
|
||||||
"opt": string, # "--" = Null
|
"opt": string, # "--" = Null
|
||||||
"in": string,
|
"in": string,
|
||||||
"out": string,
|
"out": string,
|
||||||
"source": string,
|
"source": string,
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"options": string
|
"options": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
|
||||||
[
|
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
|
||||||
{
|
[
|
||||||
"chain": "PREROUTING",
|
{
|
||||||
"rules": [
|
- `"chain"` - "PREROUTING",
|
||||||
{
|
- `"rules"` - [
|
||||||
"num": 1,
|
{
|
||||||
"pkts": 2183,
|
- `"num"` - 1,
|
||||||
"bytes": 186000,
|
- `"pkts"` - 2183,
|
||||||
"target": "PREROUTING_direct",
|
- `"bytes"` - 186000,
|
||||||
"prot": "all",
|
- `"target"` - "PREROUTING_direct",
|
||||||
"opt": null,
|
- `"prot"` - "all",
|
||||||
"in": "any",
|
- `"opt"` - null,
|
||||||
"out": "any",
|
- `"in"` - "any",
|
||||||
"source": "anywhere",
|
- `"out"` - "any",
|
||||||
"destination": "anywhere"
|
- `"source"` - "anywhere",
|
||||||
},
|
- `"destination"` - "anywhere"
|
||||||
{
|
},
|
||||||
"num": 2,
|
{
|
||||||
"pkts": 2183,
|
- `"num"` - 2,
|
||||||
"bytes": 186000,
|
- `"pkts"` - 2183,
|
||||||
"target": "PREROUTING_ZONES_SOURCE",
|
- `"bytes"` - 186000,
|
||||||
"prot": "all",
|
- `"target"` - "PREROUTING_ZONES_SOURCE",
|
||||||
"opt": null,
|
- `"prot"` - "all",
|
||||||
"in": "any",
|
- `"opt"` - null,
|
||||||
"out": "any",
|
- `"in"` - "any",
|
||||||
"source": "anywhere",
|
- `"out"` - "any",
|
||||||
"destination": "anywhere"
|
- `"source"` - "anywhere",
|
||||||
},
|
- `"destination"` - "anywhere"
|
||||||
{
|
},
|
||||||
"num": 3,
|
{
|
||||||
"pkts": 2183,
|
- `"num"` - 3,
|
||||||
"bytes": 186000,
|
- `"pkts"` - 2183,
|
||||||
"target": "PREROUTING_ZONES",
|
- `"bytes"` - 186000,
|
||||||
"prot": "all",
|
- `"target"` - "PREROUTING_ZONES",
|
||||||
"opt": null,
|
- `"prot"` - "all",
|
||||||
"in": "any",
|
- `"opt"` - null,
|
||||||
"out": "any",
|
- `"in"` - "any",
|
||||||
"source": "anywhere",
|
- `"out"` - "any",
|
||||||
"destination": "anywhere"
|
- `"source"` - "anywhere",
|
||||||
},
|
- `"destination"` - "anywhere"
|
||||||
{
|
},
|
||||||
"num": 4,
|
{
|
||||||
"pkts": 0,
|
- `"num"` - 4,
|
||||||
"bytes": 0,
|
- `"pkts"` - 0,
|
||||||
"target": "DOCKER",
|
- `"bytes"` - 0,
|
||||||
"prot": "all",
|
- `"target"` - "DOCKER",
|
||||||
"opt": null,
|
- `"prot"` - "all",
|
||||||
"in": "any",
|
- `"opt"` - null,
|
||||||
"out": "any",
|
- `"in"` - "any",
|
||||||
"source": "anywhere",
|
- `"out"` - "any",
|
||||||
"destination": "anywhere",
|
- `"source"` - "anywhere",
|
||||||
"options": "ADDRTYPE match dst-type LOCAL"
|
- `"destination"` - "anywhere",
|
||||||
}
|
- `"options"` - "ADDRTYPE match dst-type LOCAL"
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"chain"` - "PREROUTING",
|
||||||
|
- `"rules"` - [
|
||||||
|
{
|
||||||
|
- `"num"` - "1",
|
||||||
|
- `"pkts"` - "2183",
|
||||||
|
- `"bytes"` - "186K",
|
||||||
|
- `"target"` - "PREROUTING_direct",
|
||||||
|
- `"prot"` - "all",
|
||||||
|
- `"opt"` - "--",
|
||||||
|
- `"in"` - "any",
|
||||||
|
- `"out"` - "any",
|
||||||
|
- `"source"` - "anywhere",
|
||||||
|
- `"destination"` - "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"num"` - "2",
|
||||||
|
- `"pkts"` - "2183",
|
||||||
|
- `"bytes"` - "186K",
|
||||||
|
- `"target"` - "PREROUTING_ZONES_SOURCE",
|
||||||
|
- `"prot"` - "all",
|
||||||
|
- `"opt"` - "--",
|
||||||
|
- `"in"` - "any",
|
||||||
|
- `"out"` - "any",
|
||||||
|
- `"source"` - "anywhere",
|
||||||
|
- `"destination"` - "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"num"` - "3",
|
||||||
|
- `"pkts"` - "2183",
|
||||||
|
- `"bytes"` - "186K",
|
||||||
|
- `"target"` - "PREROUTING_ZONES",
|
||||||
|
- `"prot"` - "all",
|
||||||
|
- `"opt"` - "--",
|
||||||
|
- `"in"` - "any",
|
||||||
|
- `"out"` - "any",
|
||||||
|
- `"source"` - "anywhere",
|
||||||
|
- `"destination"` - "anywhere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"num"` - "4",
|
||||||
|
- `"pkts"` - "0",
|
||||||
|
- `"bytes"` - "0",
|
||||||
|
- `"target"` - "DOCKER",
|
||||||
|
- `"prot"` - "all",
|
||||||
|
- `"opt"` - "--",
|
||||||
|
- `"in"` - "any",
|
||||||
|
- `"out"` - "any",
|
||||||
|
- `"source"` - "anywhere",
|
||||||
|
- `"destination"` - "anywhere",
|
||||||
|
- `"options"` - "ADDRTYPE match dst-type LOCAL"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
|
<a id="jc.parsers.iptables.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"chain": "PREROUTING",
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"num": "1",
|
|
||||||
"pkts": "2183",
|
|
||||||
"bytes": "186K",
|
|
||||||
"target": "PREROUTING_direct",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": "2",
|
|
||||||
"pkts": "2183",
|
|
||||||
"bytes": "186K",
|
|
||||||
"target": "PREROUTING_ZONES_SOURCE",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": "3",
|
|
||||||
"pkts": "2183",
|
|
||||||
"bytes": "186K",
|
|
||||||
"target": "PREROUTING_ZONES",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"num": "4",
|
|
||||||
"pkts": "0",
|
|
||||||
"bytes": "0",
|
|
||||||
"target": "DOCKER",
|
|
||||||
"prot": "all",
|
|
||||||
"opt": "--",
|
|
||||||
"in": "any",
|
|
||||||
"out": "any",
|
|
||||||
"source": "anywhere",
|
|
||||||
"destination": "anywhere",
|
|
||||||
"options": "ADDRTYPE match dst-type LOCAL"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.iptables.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.iw_scan"></a>
|
||||||
|
|
||||||
|
# jc.parsers.iw\_scan
|
||||||
|
|
||||||
# jc.parsers.iw_scan
|
|
||||||
jc - JSON CLI output utility `iw dev <device> scan` command output parser
|
jc - JSON CLI output utility `iw dev <device> scan` command output parser
|
||||||
|
|
||||||
This parser is considered beta quality. Not all fields are parsed and there
|
This parser is considered beta quality. Not all fields are parsed and there
|
||||||
@ -8,145 +10,155 @@ are not enough samples to test.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ iw dev wlan0 scan | jc --iw-scan
|
$ iw dev wlan0 scan | jc --iw-scan
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc iw dev wlan0 scan
|
$ jc iw dev wlan0 scan
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('iw_scan', iw_scan_command_output)
|
result = jc.parse('iw_scan', iw_scan_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.iw_scan
|
import jc.parsers.iw_scan
|
||||||
result = jc.parsers.iw_scan.parse(iw_scan_command_output)
|
result = jc.parsers.iw_scan.parse(iw_scan_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"foo": string/integer/float, # best guess based on value
|
"foo": string/integer/float, # best guess based on value
|
||||||
"bar": string/integer/float,
|
"bar": string/integer/float,
|
||||||
"baz": string/integer/float
|
"baz": string/integer/float
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ iw dev wlan0 scan | jc --iw-scan -p
|
|
||||||
[
|
$ iw dev wlan0 scan | jc --iw-scan -p
|
||||||
{
|
[
|
||||||
"bssid": "71:31:72:65:e1:a2",
|
{
|
||||||
"interface": "wlan0",
|
- `"bssid"` - "71:31:72:65:e1:a2",
|
||||||
"freq": 2462,
|
- `"interface"` - "wlan0",
|
||||||
"capability": "ESS Privacy ShortSlotTime (0x0411)",
|
- `"freq"` - 2462,
|
||||||
"ssid": "WLAN-1234",
|
- `"capability"` - "ESS Privacy ShortSlotTime (0x0411)",
|
||||||
"supported_rates": [
|
- `"ssid"` - "WLAN-1234",
|
||||||
1.0,
|
- `"supported_rates"` - [
|
||||||
2.0,
|
1.0,
|
||||||
5.5,
|
2.0,
|
||||||
11.0,
|
5.5,
|
||||||
18.0,
|
11.0,
|
||||||
24.0,
|
18.0,
|
||||||
36.0,
|
24.0,
|
||||||
54.0
|
36.0,
|
||||||
],
|
54.0
|
||||||
"erp": "<no flags>",
|
],
|
||||||
"erp_d4.0": "<no flags>",
|
- `"erp"` - "<no flags>",
|
||||||
"rsn": "Version: 1",
|
- `"erp_d4.0"` - "<no flags>",
|
||||||
"group_cipher": "CCMP",
|
- `"rsn"` - "Version: 1",
|
||||||
"pairwise_ciphers": "CCMP",
|
- `"group_cipher"` - "CCMP",
|
||||||
"authentication_suites": "PSK",
|
- `"pairwise_ciphers"` - "CCMP",
|
||||||
"capabilities": "0x186c",
|
- `"authentication_suites"` - "PSK",
|
||||||
"extended_supported_rates": [
|
- `"capabilities"` - "0x186c",
|
||||||
6.0,
|
- `"extended_supported_rates"` - [
|
||||||
9.0,
|
6.0,
|
||||||
12.0,
|
9.0,
|
||||||
48.0
|
12.0,
|
||||||
],
|
48.0
|
||||||
"ht_rx_mcs_rate_indexes_supported": "0-15",
|
],
|
||||||
"primary_channel": 11,
|
- `"ht_rx_mcs_rate_indexes_supported"` - "0-15",
|
||||||
"secondary_channel_offset": "no secondary",
|
- `"primary_channel"` - 11,
|
||||||
"rifs": 1,
|
- `"secondary_channel_offset"` - "no secondary",
|
||||||
"ht_protection": "no",
|
- `"rifs"` - 1,
|
||||||
"non-gf_present": 1,
|
- `"ht_protection"` - "no",
|
||||||
"obss_non-gf_present": 0,
|
- `"non-gf_present"` - 1,
|
||||||
"dual_beacon": 0,
|
- `"obss_non-gf_present"` - 0,
|
||||||
"dual_cts_protection": 0,
|
- `"dual_beacon"` - 0,
|
||||||
"stbc_beacon": 0,
|
- `"dual_cts_protection"` - 0,
|
||||||
"l-sig_txop_prot": 0,
|
- `"stbc_beacon"` - 0,
|
||||||
"pco_active": 0,
|
- `"l-sig_txop_prot"` - 0,
|
||||||
"pco_phase": 0,
|
- `"pco_active"` - 0,
|
||||||
"bss_width_channel_transition_delay_factor": 5,
|
- `"pco_phase"` - 0,
|
||||||
"extended_capabilities": "HT Information Exchange Supported",
|
- `"bss_width_channel_transition_delay_factor"` - 5,
|
||||||
"wmm": "Parameter version 1",
|
- `"extended_capabilities"` - "HT Information Exchange Supported",
|
||||||
"be": "CW 15-1023, AIFSN 3",
|
- `"wmm"` - "Parameter version 1",
|
||||||
"bk": "CW 15-1023, AIFSN 7",
|
- `"be"` - "CW 15-1023, AIFSN 3",
|
||||||
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
|
- `"bk"` - "CW 15-1023, AIFSN 7",
|
||||||
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
|
- `"vi"` - "CW 7-15, AIFSN 2, TXOP 3008 usec",
|
||||||
"wps": "Version: 1.0",
|
- `"vo"` - "CW 3-7, AIFSN 2, TXOP 1504 usec",
|
||||||
"wi-fi_protected_setup_state": "2 (Configured)",
|
- `"wps"` - "Version: 1.0",
|
||||||
"selected_registrar": "0x0",
|
- `"wi-fi_protected_setup_state"` - "2 (Configured)",
|
||||||
"response_type": "3 (AP)",
|
- `"selected_registrar"` - "0x0",
|
||||||
"uuid": "00000000-0000-0003-0000-75317074f1a2",
|
- `"response_type"` - "3 (AP)",
|
||||||
"manufacturer": "Corporation",
|
- `"uuid"` - "00000000-0000-0003-0000-75317074f1a2",
|
||||||
"model": "VGV8539JW",
|
- `"manufacturer"` - "Corporation",
|
||||||
"model_number": "1.47.000",
|
- `"model"` - "VGV8539JW",
|
||||||
"serial_number": "J144024542",
|
- `"model_number"` - "1.47.000",
|
||||||
"primary_device_type": "6-0050f204-1",
|
- `"serial_number"` - "J144024542",
|
||||||
"device_name": "Wireless Router(WFA)",
|
- `"primary_device_type"` - "6-0050f204-1",
|
||||||
"config_methods": "Label, PBC",
|
- `"device_name"` - "Wireless Router(WFA)",
|
||||||
"rf_bands": "0x3",
|
- `"config_methods"` - "Label, PBC",
|
||||||
"tsf_usec": 212098649788,
|
- `"rf_bands"` - "0x3",
|
||||||
"sta_channel_width_mhz": 20,
|
- `"tsf_usec"` - 212098649788,
|
||||||
"passive_dwell_tus": 20,
|
- `"sta_channel_width_mhz"` - 20,
|
||||||
"active_dwell_tus": 10,
|
- `"passive_dwell_tus"` - 20,
|
||||||
"channel_width_trigger_scan_interval_s": 300,
|
- `"active_dwell_tus"` - 10,
|
||||||
"scan_passive_total_per_channel_tus": 200,
|
- `"channel_width_trigger_scan_interval_s"` - 300,
|
||||||
"scan_active_total_per_channel_tus": 20,
|
- `"scan_passive_total_per_channel_tus"` - 200,
|
||||||
"beacon_interval_tus": 100,
|
- `"scan_active_total_per_channel_tus"` - 20,
|
||||||
"signal_dbm": -80.0,
|
- `"beacon_interval_tus"` - 100,
|
||||||
"last_seen_ms": 11420,
|
- `"signal_dbm"` - -80.0,
|
||||||
"selected_rates": [
|
- `"last_seen_ms"` - 11420,
|
||||||
1.0,
|
- `"selected_rates"` - [
|
||||||
2.0,
|
1.0,
|
||||||
5.5,
|
2.0,
|
||||||
11.0
|
5.5,
|
||||||
],
|
11.0
|
||||||
"obss_scan_activity_threshold_percent": 0.25,
|
],
|
||||||
"ds_parameter_set_channel": 11,
|
- `"obss_scan_activity_threshold_percent"` - 0.25,
|
||||||
"max_amsdu_length_bytes": 7935,
|
- `"ds_parameter_set_channel"` - 11,
|
||||||
"minimum_rx_ampdu_time_spacing_usec": 16
|
- `"max_amsdu_length_bytes"` - 7935,
|
||||||
},
|
- `"minimum_rx_ampdu_time_spacing_usec"` - 16
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.iw_scan.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.iw_scan.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,108 +1,120 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.jar_manifest"></a>
|
||||||
|
|
||||||
|
# jc.parsers.jar\_manifest
|
||||||
|
|
||||||
# jc.parsers.jar_manifest
|
|
||||||
jc - JSON CLI output utility `MANIFEST.MF` file parser
|
jc - JSON CLI output utility `MANIFEST.MF` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat MANIFEST.MF | jc --jar-manifest
|
$ cat MANIFEST.MF | jc --jar-manifest
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('jar_manifest', jar_manifest_file_output)
|
result = jc.parse('jar_manifest', jar_manifest_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.jar_manifest
|
import jc.parsers.jar_manifest
|
||||||
result = jc.parsers.jar_manifest.parse(jar_manifest_file_output)
|
result = jc.parsers.jar_manifest.parse(jar_manifest_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"key1": string,
|
"key1": string,
|
||||||
"key2": string
|
"key2": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat MANIFEST.MF | jc --jar-manifest -p
|
|
||||||
$ unzip -c log4j-core-2.16.0.jar META-INF/MANIFEST.MF | \
|
$ cat MANIFEST.MF | jc --jar-manifest -p
|
||||||
jc --jar-manifest -p
|
$ unzip -c log4j-core-2.16.0.jar META-INF/MANIFEST.MF | \\
|
||||||
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \
|
jc --jar-manifest -p
|
||||||
jc --jar-manifest -p
|
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \\
|
||||||
|
jc --jar-manifest -p
|
||||||
|
|
||||||
|
$ cat MANIFEST.MF | jc --jar-manifest -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"Import_Package"` - "com.conversantmedia.util.concurrent;resoluti...",
|
||||||
|
- `"Export_Package"` - "org.apache.logging.log4j.core;uses:=\"org.ap...",
|
||||||
|
- `"Manifest_Version"` - "1.0",
|
||||||
|
- `"Bundle_License"` - "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||||
|
- `"Bundle_SymbolicName"` - "org.apache.logging.log4j.core",
|
||||||
|
- `"Built_By"` - "matt",
|
||||||
|
- `"Bnd_LastModified"` - "1639373735804",
|
||||||
|
- `"Implementation_Vendor_Id"` - "org.apache.logging.log4j",
|
||||||
|
- `"Specification_Title"` - "Apache Log4j Core",
|
||||||
|
- `"Log4jReleaseManager"` - "Matt Sicker",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \\
|
||||||
|
jc --jar-manifest -p
|
||||||
|
[
|
||||||
|
...
|
||||||
|
{
|
||||||
|
- `"Archive"` - "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-so...",
|
||||||
|
- `"Manifest_Version"` - "1.0",
|
||||||
|
- `"Built_By"` - "matt",
|
||||||
|
- `"Created_By"` - "Apache Maven 3.8.4",
|
||||||
|
- `"Build_Jdk"` - "1.8.0_312"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"Archive"` - "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-ja...",
|
||||||
|
- `"Manifest_Version"` - "1.0",
|
||||||
|
- `"Built_By"` - "matt",
|
||||||
|
- `"Created_By"` - "Apache Maven 3.8.4",
|
||||||
|
- `"Build_Jdk"` - "1.8.0_312"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"Bundle_SymbolicName"` - "org.apache.logging.log4j.spring-cloud-c...",
|
||||||
|
- `"Export_Package"` - "org.apache.logging.log4j.spring.cloud.config...",
|
||||||
|
- `"Archive"` - "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-c...",
|
||||||
|
- `"Manifest_Version"` - "1.0",
|
||||||
|
- `"Bundle_License"` - "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ cat MANIFEST.MF | jc --jar-manifest -p
|
<a id="jc.parsers.jar_manifest.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"Import_Package": "com.conversantmedia.util.concurrent;resoluti...",
|
|
||||||
"Export_Package": "org.apache.logging.log4j.core;uses:="org.ap...",
|
|
||||||
"Manifest_Version": "1.0",
|
|
||||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
|
||||||
"Bundle_SymbolicName": "org.apache.logging.log4j.core",
|
|
||||||
"Built_By": "matt",
|
|
||||||
"Bnd_LastModified": "1639373735804",
|
|
||||||
"Implementation_Vendor_Id": "org.apache.logging.log4j",
|
|
||||||
"Specification_Title": "Apache Log4j Core",
|
|
||||||
"Log4jReleaseManager": "Matt Sicker",
|
|
||||||
...
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \
|
## info Objects
|
||||||
jc --jar-manifest -p
|
|
||||||
[
|
|
||||||
...
|
|
||||||
{
|
|
||||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-so...",
|
|
||||||
"Manifest_Version": "1.0",
|
|
||||||
"Built_By": "matt",
|
|
||||||
"Created_By": "Apache Maven 3.8.4",
|
|
||||||
"Build_Jdk": "1.8.0_312"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-ja...",
|
|
||||||
"Manifest_Version": "1.0",
|
|
||||||
"Built_By": "matt",
|
|
||||||
"Created_By": "Apache Maven 3.8.4",
|
|
||||||
"Build_Jdk": "1.8.0_312"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Bundle_SymbolicName": "org.apache.logging.log4j.spring-cloud-c...",
|
|
||||||
"Export_Package": "org.apache.logging.log4j.spring.cloud.config...",
|
|
||||||
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-c...",
|
|
||||||
"Manifest_Version": "1.0",
|
|
||||||
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
|
|
||||||
...
|
|
||||||
}
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.jar_manifest.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.jobs"></a>
|
||||||
|
|
||||||
# jc.parsers.jobs
|
# jc.parsers.jobs
|
||||||
|
|
||||||
jc - JSON CLI output utility `jobs` command output parser
|
jc - JSON CLI output utility `jobs` command output parser
|
||||||
|
|
||||||
Also supports the `-l` option.
|
Also supports the `-l` option.
|
||||||
@ -10,115 +12,125 @@ builtin.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ jobs | jc --jobs
|
$ jobs | jc --jobs
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('jobs', jobs_command_output)
|
result = jc.parse('jobs', jobs_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.jobs
|
import jc.parsers.jobs
|
||||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"job_number": integer,
|
"job_number": integer,
|
||||||
"pid": integer,
|
"pid": integer,
|
||||||
"history": string,
|
"history": string,
|
||||||
"status": string,
|
"status": string,
|
||||||
"command": string
|
"command": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Example:
|
**Example**:
|
||||||
|
|
||||||
$ jobs -l | jc --jobs -p
|
|
||||||
[
|
$ jobs -l | jc --jobs -p
|
||||||
{
|
[
|
||||||
"job_number": 1,
|
{
|
||||||
"pid": 5283,
|
- `"job_number"` - 1,
|
||||||
"status": "Running",
|
- `"pid"` - 5283,
|
||||||
"command": "sleep 10000 &"
|
- `"status"` - "Running",
|
||||||
},
|
- `"command"` - "sleep 10000 &"
|
||||||
{
|
},
|
||||||
"job_number": 2,
|
{
|
||||||
"pid": 5284,
|
- `"job_number"` - 2,
|
||||||
"status": "Running",
|
- `"pid"` - 5284,
|
||||||
"command": "sleep 10100 &"
|
- `"status"` - "Running",
|
||||||
},
|
- `"command"` - "sleep 10100 &"
|
||||||
{
|
},
|
||||||
"job_number": 3,
|
{
|
||||||
"pid": 5285,
|
- `"job_number"` - 3,
|
||||||
"history": "previous",
|
- `"pid"` - 5285,
|
||||||
"status": "Running",
|
- `"history"` - "previous",
|
||||||
"command": "sleep 10001 &"
|
- `"status"` - "Running",
|
||||||
},
|
- `"command"` - "sleep 10001 &"
|
||||||
{
|
},
|
||||||
"job_number": 4,
|
{
|
||||||
"pid": 5286,
|
- `"job_number"` - 4,
|
||||||
"history": "current",
|
- `"pid"` - 5286,
|
||||||
"status": "Running",
|
- `"history"` - "current",
|
||||||
"command": "sleep 10112 &"
|
- `"status"` - "Running",
|
||||||
}
|
- `"command"` - "sleep 10112 &"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ jobs -l | jc --jobs -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"job_number"` - "1",
|
||||||
|
- `"pid"` - "19510",
|
||||||
|
- `"status"` - "Running",
|
||||||
|
- `"command"` - "sleep 1000 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"job_number"` - "2",
|
||||||
|
- `"pid"` - "19511",
|
||||||
|
- `"status"` - "Running",
|
||||||
|
- `"command"` - "sleep 1001 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"job_number"` - "3",
|
||||||
|
- `"pid"` - "19512",
|
||||||
|
- `"history"` - "previous",
|
||||||
|
- `"status"` - "Running",
|
||||||
|
- `"command"` - "sleep 1002 &"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"job_number"` - "4",
|
||||||
|
- `"pid"` - "19513",
|
||||||
|
- `"history"` - "current",
|
||||||
|
- `"status"` - "Running",
|
||||||
|
- `"command"` - "sleep 1003 &"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ jobs -l | jc --jobs -p -r
|
<a id="jc.parsers.jobs.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"job_number": "1",
|
|
||||||
"pid": "19510",
|
|
||||||
"status": "Running",
|
|
||||||
"command": "sleep 1000 &"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"job_number": "2",
|
|
||||||
"pid": "19511",
|
|
||||||
"status": "Running",
|
|
||||||
"command": "sleep 1001 &"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"job_number": "3",
|
|
||||||
"pid": "19512",
|
|
||||||
"history": "previous",
|
|
||||||
"status": "Running",
|
|
||||||
"command": "sleep 1002 &"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"job_number": "4",
|
|
||||||
"pid": "19513",
|
|
||||||
"history": "current",
|
|
||||||
"status": "Running",
|
|
||||||
"command": "sleep 1003 &"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.jobs.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.kv"></a>
|
||||||
|
|
||||||
# jc.parsers.kv
|
# jc.parsers.kv
|
||||||
|
|
||||||
jc - JSON CLI output utility `Key/Value` file parser
|
jc - JSON CLI output utility `Key/Value` file parser
|
||||||
|
|
||||||
Supports files containing simple key/value pairs. Delimiter can be `=` or
|
Supports files containing simple key/value pairs. Delimiter can be `=` or
|
||||||
@ -13,74 +15,84 @@ command-line argument or the `raw=True` argument in `parse()`.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat foo.txt | jc --kv
|
$ cat foo.txt | jc --kv
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('kv', kv_file_output)
|
result = jc.parse('kv', kv_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.kv
|
import jc.parsers.kv
|
||||||
result = jc.parsers.kv.parse(kv_file_output)
|
result = jc.parsers.kv.parse(kv_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
key/value document converted to a dictionary - see the
|
key/value document converted to a dictionary - see the
|
||||||
configparser standard library documentation for more details.
|
configparser standard library documentation for more details.
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string,
|
"key1": string,
|
||||||
"key2": string
|
"key2": string
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat keyvalue.txt
|
|
||||||
# this file contains key/value pairs
|
$ cat keyvalue.txt
|
||||||
name = John Doe
|
# this file contains key/value pairs
|
||||||
address=555 California Drive
|
name = John Doe
|
||||||
age: 34
|
address=555 California Drive
|
||||||
; comments can include # or ;
|
- `age` - 34
|
||||||
# delimiter can be = or :
|
; comments can include # or ;
|
||||||
# quoted values have quotation marks stripped by default
|
# delimiter can be = or :
|
||||||
# but can be preserved with the -r argument
|
# quoted values have quotation marks stripped by default
|
||||||
occupation:"Engineer"
|
# but can be preserved with the -r argument
|
||||||
|
occupation:"Engineer"
|
||||||
|
|
||||||
|
$ cat keyvalue.txt | jc --kv -p
|
||||||
|
{
|
||||||
|
- `"name"` - "John Doe",
|
||||||
|
- `"address"` - "555 California Drive",
|
||||||
|
- `"age"` - "34",
|
||||||
|
- `"occupation"` - "Engineer"
|
||||||
|
}
|
||||||
|
|
||||||
$ cat keyvalue.txt | jc --kv -p
|
<a id="jc.parsers.kv.info"></a>
|
||||||
{
|
|
||||||
"name": "John Doe",
|
|
||||||
"address": "555 California Drive",
|
|
||||||
"age": "34",
|
|
||||||
"occupation": "Engineer"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.kv.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Note: this is just a wrapper for jc.parsers.ini
|
Note: this is just a wrapper for jc.parsers.ini
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary representing the key/value file
|
|
||||||
|
Dictionary representing the key/value file
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.last"></a>
|
||||||
|
|
||||||
# jc.parsers.last
|
# jc.parsers.last
|
||||||
|
|
||||||
jc - JSON CLI output utility `last` and `lastb` command output parser
|
jc - JSON CLI output utility `last` and `lastb` command output parser
|
||||||
|
|
||||||
Supports `-w` and `-F` options.
|
Supports `-w` and `-F` options.
|
||||||
@ -11,126 +13,135 @@ system the parser is run on) since there is no timezone information in the
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ last | jc --last
|
$ last | jc --last
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc last
|
$ jc last
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('last', last_command_output)
|
result = jc.parse('last', last_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.last
|
import jc.parsers.last
|
||||||
result = jc.parsers.last.parse(last_command_output)
|
result = jc.parsers.last.parse(last_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": string,
|
"user": string,
|
||||||
"tty": string,
|
"tty": string,
|
||||||
"hostname": string,
|
"hostname": string,
|
||||||
"login": string,
|
"login": string,
|
||||||
"logout": string,
|
"logout": string,
|
||||||
"duration": string,
|
"duration": string,
|
||||||
"login_epoch": integer, # (naive) available w/last -F option
|
"login_epoch": integer, # (naive) available w/last -F option
|
||||||
"logout_epoch": integer, # (naive) available w/last -F option
|
"logout_epoch": integer, # (naive) available w/last -F option
|
||||||
"duration_seconds": integer # available w/last -F option
|
"duration_seconds": integer # available w/last -F option
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ last -F | jc --last -p
|
|
||||||
[
|
$ last -F | jc --last -p
|
||||||
{
|
[
|
||||||
"user": "kbrazil",
|
{
|
||||||
"tty": "ttys002",
|
- `"user"` - "kbrazil",
|
||||||
"hostname": null,
|
- `"tty"` - "ttys002",
|
||||||
"login": "Mon Dec 28 17:24:10 2020",
|
- `"hostname"` - null,
|
||||||
"logout": "still logged in"
|
- `"login"` - "Mon Dec 28 17:24:10 2020",
|
||||||
},
|
- `"logout"` - "still logged in"
|
||||||
{
|
},
|
||||||
"user": "kbrazil",
|
{
|
||||||
"tty": "ttys003",
|
- `"user"` - "kbrazil",
|
||||||
"hostname": null,
|
- `"tty"` - "ttys003",
|
||||||
"login": "Mon Dec 28 17:24:10 2020",
|
- `"hostname"` - null,
|
||||||
"logout": "Mon Dec 28 17:25:01 2020",
|
- `"login"` - "Mon Dec 28 17:24:10 2020",
|
||||||
"duration": "00:00",
|
- `"logout"` - "Mon Dec 28 17:25:01 2020",
|
||||||
"login_epoch": 1565891826,
|
- `"duration"` - "00:00",
|
||||||
"logout_epoch": 1565895404,
|
- `"login_epoch"` - 1565891826,
|
||||||
"duration_seconds": 3578
|
- `"logout_epoch"` - 1565895404,
|
||||||
},
|
- `"duration_seconds"` - 3578
|
||||||
{
|
},
|
||||||
"user": "kbrazil",
|
{
|
||||||
"tty": "ttys003",
|
- `"user"` - "kbrazil",
|
||||||
"hostname": null,
|
- `"tty"` - "ttys003",
|
||||||
"login": "Mon Dec 28 17:24:10 2020",
|
- `"hostname"` - null,
|
||||||
"logout": "Mon Dec 28 17:25:01 2020",
|
- `"login"` - "Mon Dec 28 17:24:10 2020",
|
||||||
"duration": "00:00",
|
- `"logout"` - "Mon Dec 28 17:25:01 2020",
|
||||||
"login_epoch": 1565891826,
|
- `"duration"` - "00:00",
|
||||||
"logout_epoch": 1565895404,
|
- `"login_epoch"` - 1565891826,
|
||||||
"duration_seconds": 3578
|
- `"logout_epoch"` - 1565895404,
|
||||||
},
|
- `"duration_seconds"` - 3578
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ last | jc --last -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"user"` - "kbrazil",
|
||||||
|
- `"tty"` - "ttys002",
|
||||||
|
- `"hostname"` - "-",
|
||||||
|
- `"login"` - "Thu Feb 27 14:31",
|
||||||
|
- `"logout"` - "still_logged_in"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "kbrazil",
|
||||||
|
- `"tty"` - "ttys003",
|
||||||
|
- `"hostname"` - "-",
|
||||||
|
- `"login"` - "Thu Feb 27 10:38",
|
||||||
|
- `"logout"` - "10:38",
|
||||||
|
- `"duration"` - "00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "kbrazil",
|
||||||
|
- `"tty"` - "ttys003",
|
||||||
|
- `"hostname"` - "-",
|
||||||
|
- `"login"` - "Thu Feb 27 10:18",
|
||||||
|
- `"logout"` - "10:18",
|
||||||
|
- `"duration"` - "00:00"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ last | jc --last -p -r
|
<a id="jc.parsers.last.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"user": "kbrazil",
|
|
||||||
"tty": "ttys002",
|
|
||||||
"hostname": "-",
|
|
||||||
"login": "Thu Feb 27 14:31",
|
|
||||||
"logout": "still_logged_in"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "kbrazil",
|
|
||||||
"tty": "ttys003",
|
|
||||||
"hostname": "-",
|
|
||||||
"login": "Thu Feb 27 10:38",
|
|
||||||
"logout": "10:38",
|
|
||||||
"duration": "00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "kbrazil",
|
|
||||||
"tty": "ttys003",
|
|
||||||
"hostname": "-",
|
|
||||||
"login": "Thu Feb 27 10:18",
|
|
||||||
"logout": "10:18",
|
|
||||||
"duration": "00:00"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.last.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ls"></a>
|
||||||
|
|
||||||
# jc.parsers.ls
|
# jc.parsers.ls
|
||||||
|
|
||||||
jc - JSON CLI output utility `ls` and `vdir` command output parser
|
jc - JSON CLI output utility `ls` and `vdir` command output parser
|
||||||
|
|
||||||
Options supported:
|
Options supported:
|
||||||
@ -21,127 +23,137 @@ available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ls | jc --ls
|
$ ls | jc --ls
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ls
|
$ jc ls
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ls', ls_command_output)
|
result = jc.parse('ls', ls_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ls
|
import jc.parsers.ls
|
||||||
result = jc.parsers.ls.parse(ls_command_output)
|
result = jc.parsers.ls.parse(ls_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": string,
|
"filename": string,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"links": integer,
|
"links": integer,
|
||||||
"parent": string,
|
"parent": string,
|
||||||
"owner": string,
|
"owner": string,
|
||||||
"group": string,
|
"group": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"date": string,
|
"date": string,
|
||||||
"epoch": integer, # [0]
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer # [1]
|
"epoch_utc": integer # [1]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] naive timestamp if date field exists and can be converted.
|
[0] naive timestamp if date field exists and can be converted.
|
||||||
[1] timezone aware timestamp if date field is in UTC and can
|
[1] timezone aware timestamp if date field is in UTC and can
|
||||||
be converted.
|
be converted.
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ls /usr/bin | jc --ls -p
|
|
||||||
[
|
$ ls /usr/bin | jc --ls -p
|
||||||
{
|
[
|
||||||
"filename": "apropos"
|
{
|
||||||
},
|
- `"filename"` - "apropos"
|
||||||
{
|
},
|
||||||
"filename": "arch"
|
{
|
||||||
},
|
- `"filename"` - "arch"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"filename"` - "apropos",
|
||||||
|
- `"link_to"` - "whatis",
|
||||||
|
- `"flags"` - "lrwxrwxrwx.",
|
||||||
|
- `"links"` - 1,
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "root",
|
||||||
|
- `"size"` - 6,
|
||||||
|
- `"date"` - "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"filename"` - "ar",
|
||||||
|
- `"flags"` - "-rwxr-xr-x.",
|
||||||
|
- `"links"` - 1,
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "root",
|
||||||
|
- `"size"` - 62744,
|
||||||
|
- `"date"` - "Aug 8 16:14"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"filename"` - "apropos",
|
||||||
|
- `"link_to"` - "whatis",
|
||||||
|
- `"flags"` - "lrwxrwxrwx.",
|
||||||
|
- `"links"` - "1",
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "root",
|
||||||
|
- `"size"` - "6",
|
||||||
|
- `"date"` - "Aug 15 10:53"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"filename"` - "arch",
|
||||||
|
- `"flags"` - "-rwxr-xr-x.",
|
||||||
|
- `"links"` - "1",
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "root",
|
||||||
|
- `"size"` - "33080",
|
||||||
|
- `"date"` - "Aug 19 23:25"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls -p
|
<a id="jc.parsers.ls.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"filename": "apropos",
|
|
||||||
"link_to": "whatis",
|
|
||||||
"flags": "lrwxrwxrwx.",
|
|
||||||
"links": 1,
|
|
||||||
"owner": "root",
|
|
||||||
"group": "root",
|
|
||||||
"size": 6,
|
|
||||||
"date": "Aug 15 10:53"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "ar",
|
|
||||||
"flags": "-rwxr-xr-x.",
|
|
||||||
"links": 1,
|
|
||||||
"owner": "root",
|
|
||||||
"group": "root",
|
|
||||||
"size": 62744,
|
|
||||||
"date": "Aug 8 16:14"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls -p -r
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"filename": "apropos",
|
|
||||||
"link_to": "whatis",
|
|
||||||
"flags": "lrwxrwxrwx.",
|
|
||||||
"links": "1",
|
|
||||||
"owner": "root",
|
|
||||||
"group": "root",
|
|
||||||
"size": "6",
|
|
||||||
"date": "Aug 15 10:53"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"filename": "arch",
|
|
||||||
"flags": "-rwxr-xr-x.",
|
|
||||||
"links": "1",
|
|
||||||
"owner": "root",
|
|
||||||
"group": "root",
|
|
||||||
"size": "33080",
|
|
||||||
"date": "Aug 19 23:25"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ls.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ls_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.ls\_s
|
||||||
|
|
||||||
# jc.parsers.ls_s
|
|
||||||
jc - JSON CLI output utility `ls` and `vdir` command output streaming
|
jc - JSON CLI output utility `ls` and `vdir` command output streaming
|
||||||
parser
|
parser
|
||||||
|
|
||||||
@ -20,96 +22,108 @@ available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ls | jc --ls-s
|
$ ls | jc --ls-s
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parse('ls_s', ls_command_output.splitlines())
|
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ls_s
|
import jc.parsers.ls_s
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"filename": string,
|
"filename": string,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"links": integer,
|
"links": integer,
|
||||||
"parent": string,
|
"parent": string,
|
||||||
"owner": string,
|
"owner": string,
|
||||||
"group": string,
|
"group": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"date": string,
|
"date": string,
|
||||||
"epoch": integer, # [0]
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer, # [1]
|
"epoch_utc": integer, # [1]
|
||||||
|
|
||||||
# Below object only exists if using -qq or ignore_exceptions=True
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
"_jc_meta":
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # false if error parsing
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] naive timestamp if date field exists and can be converted.
|
[0] naive timestamp if date field exists and can be converted.
|
||||||
[1] timezone aware timestamp if date field is in UTC and can
|
[1] timezone aware timestamp if date field is in UTC and can
|
||||||
be converted
|
be converted
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls-s
|
|
||||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","...}
|
$ ls -l /usr/bin | jc --ls-s
|
||||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","...}
|
||||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,...}
|
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
||||||
...
|
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,...}
|
||||||
|
...
|
||||||
|
|
||||||
|
$ ls -l /usr/bin | jc --ls-s -r
|
||||||
|
{"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"roo"..."}
|
||||||
|
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
||||||
|
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...}
|
||||||
|
...
|
||||||
|
|
||||||
$ ls -l /usr/bin | jc --ls-s -r
|
<a id="jc.parsers.ls_s.info"></a>
|
||||||
{"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"roo"..."}
|
|
||||||
{"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...}
|
|
||||||
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...}
|
|
||||||
...
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ls_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse
|
|
||||||
(e.g. sys.stdin or str.splitlines())
|
- `data` - (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
|
||||||
|
|
||||||
raw: (boolean) unprocessed output if True
|
**Yields**:
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
**Returns**:
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
Iterator object
|
||||||
Iterator object
|
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,305 +1,317 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.lsblk"></a>
|
||||||
|
|
||||||
# jc.parsers.lsblk
|
# jc.parsers.lsblk
|
||||||
|
|
||||||
jc - JSON CLI output utility `lsblk` command output parser
|
jc - JSON CLI output utility `lsblk` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ lsblk | jc --lsblk
|
$ lsblk | jc --lsblk
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc lsblk
|
$ jc lsblk
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('lsblk', lsblk_command_output)
|
result = jc.parse('lsblk', lsblk_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.lsblk
|
import jc.parsers.lsblk
|
||||||
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"maj_min": string,
|
"maj_min": string,
|
||||||
"rm": boolean,
|
"rm": boolean,
|
||||||
"size": string,
|
"size": string,
|
||||||
"ro": boolean,
|
"ro": boolean,
|
||||||
"type": string,
|
"type": string,
|
||||||
"mountpoint": string,
|
"mountpoint": string,
|
||||||
"kname": string,
|
"kname": string,
|
||||||
"fstype": string,
|
"fstype": string,
|
||||||
"label": string,
|
"label": string,
|
||||||
"uuid": string,
|
"uuid": string,
|
||||||
"partlabel": string,
|
"partlabel": string,
|
||||||
"partuuid": string,
|
"partuuid": string,
|
||||||
"ra": integer,
|
"ra": integer,
|
||||||
"model": string,
|
"model": string,
|
||||||
"serial": string,
|
"serial": string,
|
||||||
"state": string,
|
"state": string,
|
||||||
"owner": string,
|
"owner": string,
|
||||||
"group": string,
|
"group": string,
|
||||||
"mode": string,
|
"mode": string,
|
||||||
"alignment": integer,
|
"alignment": integer,
|
||||||
"min_io": integer,
|
"min_io": integer,
|
||||||
"opt_io": integer,
|
"opt_io": integer,
|
||||||
"phy_sec": integer,
|
"phy_sec": integer,
|
||||||
"log_sec": integer,
|
"log_sec": integer,
|
||||||
"rota": boolean,
|
"rota": boolean,
|
||||||
"sched": string,
|
"sched": string,
|
||||||
"rq_size": integer,
|
"rq_size": integer,
|
||||||
"disc_aln": integer,
|
"disc_aln": integer,
|
||||||
"disc_gran": string,
|
"disc_gran": string,
|
||||||
"disc_max": string,
|
"disc_max": string,
|
||||||
"disc_zero": boolean,
|
"disc_zero": boolean,
|
||||||
"wsame": string,
|
"wsame": string,
|
||||||
"wwn": string,
|
"wwn": string,
|
||||||
"rand": boolean,
|
"rand": boolean,
|
||||||
"pkname": string,
|
"pkname": string,
|
||||||
"hctl": string,
|
"hctl": string,
|
||||||
"tran": string,
|
"tran": string,
|
||||||
"rev": string,
|
"rev": string,
|
||||||
"vendor": string
|
"vendor": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ lsblk | jc --lsblk -p
|
|
||||||
[
|
$ lsblk | jc --lsblk -p
|
||||||
{
|
[
|
||||||
"name": "sda",
|
{
|
||||||
"maj_min": "8:0",
|
- `"name"` - "sda",
|
||||||
"rm": false,
|
- `"maj_min"` - "8:0",
|
||||||
"size": "20G",
|
- `"rm"` - false,
|
||||||
"ro": false,
|
- `"size"` - "20G",
|
||||||
"type": "disk",
|
- `"ro"` - false,
|
||||||
"mountpoint": null
|
- `"type"` - "disk",
|
||||||
},
|
- `"mountpoint"` - null
|
||||||
{
|
},
|
||||||
"name": "sda1",
|
{
|
||||||
"maj_min": "8:1",
|
- `"name"` - "sda1",
|
||||||
"rm": false,
|
- `"maj_min"` - "8:1",
|
||||||
"size": "1G",
|
- `"rm"` - false,
|
||||||
"ro": false,
|
- `"size"` - "1G",
|
||||||
"type": "part",
|
- `"ro"` - false,
|
||||||
"mountpoint": "/boot"
|
- `"type"` - "part",
|
||||||
},
|
- `"mountpoint"` - "/boot"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\\
|
||||||
|
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\\
|
||||||
|
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\\
|
||||||
|
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"name"` - "sda",
|
||||||
|
- `"maj_min"` - "8:0",
|
||||||
|
- `"rm"` - false,
|
||||||
|
- `"size"` - "20G",
|
||||||
|
- `"ro"` - false,
|
||||||
|
- `"type"` - "disk",
|
||||||
|
- `"mountpoint"` - null,
|
||||||
|
- `"kname"` - "sda",
|
||||||
|
- `"fstype"` - null,
|
||||||
|
- `"label"` - null,
|
||||||
|
- `"uuid"` - null,
|
||||||
|
- `"partlabel"` - null,
|
||||||
|
- `"partuuid"` - null,
|
||||||
|
- `"ra"` - 4096,
|
||||||
|
- `"model"` - "VMware Virtual S",
|
||||||
|
- `"serial"` - null,
|
||||||
|
- `"state"` - "running",
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "disk",
|
||||||
|
- `"mode"` - "brw-rw----",
|
||||||
|
- `"alignment"` - 0,
|
||||||
|
- `"min_io"` - 512,
|
||||||
|
- `"opt_io"` - 0,
|
||||||
|
- `"phy_sec"` - 512,
|
||||||
|
- `"log_sec"` - 512,
|
||||||
|
- `"rota"` - true,
|
||||||
|
- `"sched"` - "deadline",
|
||||||
|
- `"rq_size"` - 128,
|
||||||
|
- `"disc_aln"` - 0,
|
||||||
|
- `"disc_gran"` - "0B",
|
||||||
|
- `"disc_max"` - "0B",
|
||||||
|
- `"disc_zero"` - false,
|
||||||
|
- `"wsame"` - "32M",
|
||||||
|
- `"wwn"` - null,
|
||||||
|
- `"rand"` - true,
|
||||||
|
- `"pkname"` - null,
|
||||||
|
- `"hctl"` - "0:0:0:0",
|
||||||
|
- `"tran"` - "spi",
|
||||||
|
- `"rev"` - "1.0",
|
||||||
|
- `"vendor"` - "VMware,"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "sda1",
|
||||||
|
- `"maj_min"` - "8:1",
|
||||||
|
- `"rm"` - false,
|
||||||
|
- `"size"` - "1G",
|
||||||
|
- `"ro"` - false,
|
||||||
|
- `"type"` - "part",
|
||||||
|
- `"mountpoint"` - "/boot",
|
||||||
|
- `"kname"` - "sda1",
|
||||||
|
- `"fstype"` - "xfs",
|
||||||
|
- `"label"` - null,
|
||||||
|
- `"uuid"` - "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
|
- `"partlabel"` - null,
|
||||||
|
- `"partuuid"` - null,
|
||||||
|
- `"ra"` - 4096,
|
||||||
|
- `"model"` - null,
|
||||||
|
- `"serial"` - null,
|
||||||
|
- `"state"` - null,
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "disk",
|
||||||
|
- `"mode"` - "brw-rw----",
|
||||||
|
- `"alignment"` - 0,
|
||||||
|
- `"min_io"` - 512,
|
||||||
|
- `"opt_io"` - 0,
|
||||||
|
- `"phy_sec"` - 512,
|
||||||
|
- `"log_sec"` - 512,
|
||||||
|
- `"rota"` - true,
|
||||||
|
- `"sched"` - "deadline",
|
||||||
|
- `"rq_size"` - 128,
|
||||||
|
- `"disc_aln"` - 0,
|
||||||
|
- `"disc_gran"` - "0B",
|
||||||
|
- `"disc_max"` - "0B",
|
||||||
|
- `"disc_zero"` - false,
|
||||||
|
- `"wsame"` - "32M",
|
||||||
|
- `"wwn"` - null,
|
||||||
|
- `"rand"` - true,
|
||||||
|
- `"pkname"` - "sda",
|
||||||
|
- `"hctl"` - null,
|
||||||
|
- `"tran"` - null,
|
||||||
|
- `"rev"` - null,
|
||||||
|
- `"vendor"` - null
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\\
|
||||||
|
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\\
|
||||||
|
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\\
|
||||||
|
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"name"` - "sda",
|
||||||
|
- `"maj_min"` - "8:0",
|
||||||
|
- `"rm"` - "0",
|
||||||
|
- `"size"` - "20G",
|
||||||
|
- `"ro"` - "0",
|
||||||
|
- `"type"` - "disk",
|
||||||
|
- `"mountpoint"` - null,
|
||||||
|
- `"kname"` - "sda",
|
||||||
|
- `"fstype"` - null,
|
||||||
|
- `"label"` - null,
|
||||||
|
- `"uuid"` - null,
|
||||||
|
- `"partlabel"` - null,
|
||||||
|
- `"partuuid"` - null,
|
||||||
|
- `"ra"` - "4096",
|
||||||
|
- `"model"` - "VMware Virtual S",
|
||||||
|
- `"serial"` - null,
|
||||||
|
- `"state"` - "running",
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "disk",
|
||||||
|
- `"mode"` - "brw-rw----",
|
||||||
|
- `"alignment"` - "0",
|
||||||
|
- `"min_io"` - "512",
|
||||||
|
- `"opt_io"` - "0",
|
||||||
|
- `"phy_sec"` - "512",
|
||||||
|
- `"log_sec"` - "512",
|
||||||
|
- `"rota"` - "1",
|
||||||
|
- `"sched"` - "deadline",
|
||||||
|
- `"rq_size"` - "128",
|
||||||
|
- `"disc_aln"` - "0",
|
||||||
|
- `"disc_gran"` - "0B",
|
||||||
|
- `"disc_max"` - "0B",
|
||||||
|
- `"disc_zero"` - "0",
|
||||||
|
- `"wsame"` - "32M",
|
||||||
|
- `"wwn"` - null,
|
||||||
|
- `"rand"` - "1",
|
||||||
|
- `"pkname"` - null,
|
||||||
|
- `"hctl"` - "0:0:0:0",
|
||||||
|
- `"tran"` - "spi",
|
||||||
|
- `"rev"` - "1.0",
|
||||||
|
- `"vendor"` - "VMware,"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "sda1",
|
||||||
|
- `"maj_min"` - "8:1",
|
||||||
|
- `"rm"` - "0",
|
||||||
|
- `"size"` - "1G",
|
||||||
|
- `"ro"` - "0",
|
||||||
|
- `"type"` - "part",
|
||||||
|
- `"mountpoint"` - "/boot",
|
||||||
|
- `"kname"` - "sda1",
|
||||||
|
- `"fstype"` - "xfs",
|
||||||
|
- `"label"` - null,
|
||||||
|
- `"uuid"` - "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
||||||
|
- `"partlabel"` - null,
|
||||||
|
- `"partuuid"` - null,
|
||||||
|
- `"ra"` - "4096",
|
||||||
|
- `"model"` - null,
|
||||||
|
- `"serial"` - null,
|
||||||
|
- `"state"` - null,
|
||||||
|
- `"owner"` - "root",
|
||||||
|
- `"group"` - "disk",
|
||||||
|
- `"mode"` - "brw-rw----",
|
||||||
|
- `"alignment"` - "0",
|
||||||
|
- `"min_io"` - "512",
|
||||||
|
- `"opt_io"` - "0",
|
||||||
|
- `"phy_sec"` - "512",
|
||||||
|
- `"log_sec"` - "512",
|
||||||
|
- `"rota"` - "1",
|
||||||
|
- `"sched"` - "deadline",
|
||||||
|
- `"rq_size"` - "128",
|
||||||
|
- `"disc_aln"` - "0",
|
||||||
|
- `"disc_gran"` - "0B",
|
||||||
|
- `"disc_max"` - "0B",
|
||||||
|
- `"disc_zero"` - "0",
|
||||||
|
- `"wsame"` - "32M",
|
||||||
|
- `"wwn"` - null,
|
||||||
|
- `"rand"` - "1",
|
||||||
|
- `"pkname"` - "sda",
|
||||||
|
- `"hctl"` - null,
|
||||||
|
- `"tran"` - null,
|
||||||
|
- `"rev"` - null,
|
||||||
|
- `"vendor"` - null
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\
|
<a id="jc.parsers.lsblk.info"></a>
|
||||||
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\
|
|
||||||
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\
|
|
||||||
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "sda",
|
|
||||||
"maj_min": "8:0",
|
|
||||||
"rm": false,
|
|
||||||
"size": "20G",
|
|
||||||
"ro": false,
|
|
||||||
"type": "disk",
|
|
||||||
"mountpoint": null,
|
|
||||||
"kname": "sda",
|
|
||||||
"fstype": null,
|
|
||||||
"label": null,
|
|
||||||
"uuid": null,
|
|
||||||
"partlabel": null,
|
|
||||||
"partuuid": null,
|
|
||||||
"ra": 4096,
|
|
||||||
"model": "VMware Virtual S",
|
|
||||||
"serial": null,
|
|
||||||
"state": "running",
|
|
||||||
"owner": "root",
|
|
||||||
"group": "disk",
|
|
||||||
"mode": "brw-rw----",
|
|
||||||
"alignment": 0,
|
|
||||||
"min_io": 512,
|
|
||||||
"opt_io": 0,
|
|
||||||
"phy_sec": 512,
|
|
||||||
"log_sec": 512,
|
|
||||||
"rota": true,
|
|
||||||
"sched": "deadline",
|
|
||||||
"rq_size": 128,
|
|
||||||
"disc_aln": 0,
|
|
||||||
"disc_gran": "0B",
|
|
||||||
"disc_max": "0B",
|
|
||||||
"disc_zero": false,
|
|
||||||
"wsame": "32M",
|
|
||||||
"wwn": null,
|
|
||||||
"rand": true,
|
|
||||||
"pkname": null,
|
|
||||||
"hctl": "0:0:0:0",
|
|
||||||
"tran": "spi",
|
|
||||||
"rev": "1.0",
|
|
||||||
"vendor": "VMware,"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sda1",
|
|
||||||
"maj_min": "8:1",
|
|
||||||
"rm": false,
|
|
||||||
"size": "1G",
|
|
||||||
"ro": false,
|
|
||||||
"type": "part",
|
|
||||||
"mountpoint": "/boot",
|
|
||||||
"kname": "sda1",
|
|
||||||
"fstype": "xfs",
|
|
||||||
"label": null,
|
|
||||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
|
||||||
"partlabel": null,
|
|
||||||
"partuuid": null,
|
|
||||||
"ra": 4096,
|
|
||||||
"model": null,
|
|
||||||
"serial": null,
|
|
||||||
"state": null,
|
|
||||||
"owner": "root",
|
|
||||||
"group": "disk",
|
|
||||||
"mode": "brw-rw----",
|
|
||||||
"alignment": 0,
|
|
||||||
"min_io": 512,
|
|
||||||
"opt_io": 0,
|
|
||||||
"phy_sec": 512,
|
|
||||||
"log_sec": 512,
|
|
||||||
"rota": true,
|
|
||||||
"sched": "deadline",
|
|
||||||
"rq_size": 128,
|
|
||||||
"disc_aln": 0,
|
|
||||||
"disc_gran": "0B",
|
|
||||||
"disc_max": "0B",
|
|
||||||
"disc_zero": false,
|
|
||||||
"wsame": "32M",
|
|
||||||
"wwn": null,
|
|
||||||
"rand": true,
|
|
||||||
"pkname": "sda",
|
|
||||||
"hctl": null,
|
|
||||||
"tran": null,
|
|
||||||
"rev": null,
|
|
||||||
"vendor": null
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
$ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\
|
## info Objects
|
||||||
STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\
|
|
||||||
SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\
|
|
||||||
PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "sda",
|
|
||||||
"maj_min": "8:0",
|
|
||||||
"rm": "0",
|
|
||||||
"size": "20G",
|
|
||||||
"ro": "0",
|
|
||||||
"type": "disk",
|
|
||||||
"mountpoint": null,
|
|
||||||
"kname": "sda",
|
|
||||||
"fstype": null,
|
|
||||||
"label": null,
|
|
||||||
"uuid": null,
|
|
||||||
"partlabel": null,
|
|
||||||
"partuuid": null,
|
|
||||||
"ra": "4096",
|
|
||||||
"model": "VMware Virtual S",
|
|
||||||
"serial": null,
|
|
||||||
"state": "running",
|
|
||||||
"owner": "root",
|
|
||||||
"group": "disk",
|
|
||||||
"mode": "brw-rw----",
|
|
||||||
"alignment": "0",
|
|
||||||
"min_io": "512",
|
|
||||||
"opt_io": "0",
|
|
||||||
"phy_sec": "512",
|
|
||||||
"log_sec": "512",
|
|
||||||
"rota": "1",
|
|
||||||
"sched": "deadline",
|
|
||||||
"rq_size": "128",
|
|
||||||
"disc_aln": "0",
|
|
||||||
"disc_gran": "0B",
|
|
||||||
"disc_max": "0B",
|
|
||||||
"disc_zero": "0",
|
|
||||||
"wsame": "32M",
|
|
||||||
"wwn": null,
|
|
||||||
"rand": "1",
|
|
||||||
"pkname": null,
|
|
||||||
"hctl": "0:0:0:0",
|
|
||||||
"tran": "spi",
|
|
||||||
"rev": "1.0",
|
|
||||||
"vendor": "VMware,"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sda1",
|
|
||||||
"maj_min": "8:1",
|
|
||||||
"rm": "0",
|
|
||||||
"size": "1G",
|
|
||||||
"ro": "0",
|
|
||||||
"type": "part",
|
|
||||||
"mountpoint": "/boot",
|
|
||||||
"kname": "sda1",
|
|
||||||
"fstype": "xfs",
|
|
||||||
"label": null,
|
|
||||||
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
|
|
||||||
"partlabel": null,
|
|
||||||
"partuuid": null,
|
|
||||||
"ra": "4096",
|
|
||||||
"model": null,
|
|
||||||
"serial": null,
|
|
||||||
"state": null,
|
|
||||||
"owner": "root",
|
|
||||||
"group": "disk",
|
|
||||||
"mode": "brw-rw----",
|
|
||||||
"alignment": "0",
|
|
||||||
"min_io": "512",
|
|
||||||
"opt_io": "0",
|
|
||||||
"phy_sec": "512",
|
|
||||||
"log_sec": "512",
|
|
||||||
"rota": "1",
|
|
||||||
"sched": "deadline",
|
|
||||||
"rq_size": "128",
|
|
||||||
"disc_aln": "0",
|
|
||||||
"disc_gran": "0B",
|
|
||||||
"disc_max": "0B",
|
|
||||||
"disc_zero": "0",
|
|
||||||
"wsame": "32M",
|
|
||||||
"wwn": null,
|
|
||||||
"rand": "1",
|
|
||||||
"pkname": "sda",
|
|
||||||
"hctl": null,
|
|
||||||
"tran": null,
|
|
||||||
"rev": null,
|
|
||||||
"vendor": null
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.lsblk.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,156 +1,168 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.lsmod"></a>
|
||||||
|
|
||||||
# jc.parsers.lsmod
|
# jc.parsers.lsmod
|
||||||
|
|
||||||
jc - JSON CLI output utility `lsmod` command output parser
|
jc - JSON CLI output utility `lsmod` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ lsmod | jc --lsmod
|
$ lsmod | jc --lsmod
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc lsmod
|
$ jc lsmod
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('lsmod', lsmod_command_output)
|
result = jc.parse('lsmod', lsmod_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.lsmod
|
import jc.parsers.lsmod
|
||||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"module": string,
|
"module": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"used": integer,
|
"used": integer,
|
||||||
"by": [
|
"by": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ lsmod | jc --lsmod -p
|
|
||||||
[
|
$ lsmod | jc --lsmod -p
|
||||||
...
|
[
|
||||||
{
|
...
|
||||||
"module": "nf_nat",
|
{
|
||||||
"size": 26583,
|
- `"module"` - "nf_nat",
|
||||||
"used": 3,
|
- `"size"` - 26583,
|
||||||
"by": [
|
- `"used"` - 3,
|
||||||
"nf_nat_ipv4",
|
- `"by"` - [
|
||||||
"nf_nat_ipv6",
|
"nf_nat_ipv4",
|
||||||
"nf_nat_masquerade_ipv4"
|
"nf_nat_ipv6",
|
||||||
]
|
"nf_nat_masquerade_ipv4"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"module": "iptable_mangle",
|
{
|
||||||
"size": 12695,
|
- `"module"` - "iptable_mangle",
|
||||||
"used": 1
|
- `"size"` - 12695,
|
||||||
},
|
- `"used"` - 1
|
||||||
{
|
},
|
||||||
"module": "iptable_security",
|
{
|
||||||
"size": 12705,
|
- `"module"` - "iptable_security",
|
||||||
"used": 1
|
- `"size"` - 12705,
|
||||||
},
|
- `"used"` - 1
|
||||||
{
|
},
|
||||||
"module": "iptable_raw",
|
{
|
||||||
"size": 12678,
|
- `"module"` - "iptable_raw",
|
||||||
"used": 1
|
- `"size"` - 12678,
|
||||||
},
|
- `"used"` - 1
|
||||||
{
|
},
|
||||||
"module": "nf_conntrack",
|
{
|
||||||
"size": 139224,
|
- `"module"` - "nf_conntrack",
|
||||||
"used": 7,
|
- `"size"` - 139224,
|
||||||
"by": [
|
- `"used"` - 7,
|
||||||
"nf_nat",
|
- `"by"` - [
|
||||||
"nf_nat_ipv4",
|
"nf_nat",
|
||||||
"nf_nat_ipv6",
|
"nf_nat_ipv4",
|
||||||
"xt_conntrack",
|
"nf_nat_ipv6",
|
||||||
"nf_nat_masquerade_ipv4",
|
"xt_conntrack",
|
||||||
"nf_conntrack_ipv4",
|
"nf_nat_masquerade_ipv4",
|
||||||
"nf_conntrack_ipv6"
|
"nf_conntrack_ipv4",
|
||||||
]
|
"nf_conntrack_ipv6"
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ lsmod | jc --lsmod -p -r
|
||||||
|
[
|
||||||
|
...
|
||||||
|
{
|
||||||
|
- `"module"` - "nf_conntrack",
|
||||||
|
- `"size"` - "139224",
|
||||||
|
- `"used"` - "7",
|
||||||
|
- `"by"` - [
|
||||||
|
"nf_nat",
|
||||||
|
"nf_nat_ipv4",
|
||||||
|
"nf_nat_ipv6",
|
||||||
|
"xt_conntrack",
|
||||||
|
"nf_nat_masquerade_ipv4",
|
||||||
|
"nf_conntrack_ipv4",
|
||||||
|
"nf_conntrack_ipv6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"module"` - "ip_set",
|
||||||
|
- `"size"` - "45799",
|
||||||
|
- `"used"` - "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"module"` - "nfnetlink",
|
||||||
|
- `"size"` - "14519",
|
||||||
|
- `"used"` - "1",
|
||||||
|
- `"by"` - [
|
||||||
|
"ip_set"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"module"` - "ebtable_filter",
|
||||||
|
- `"size"` - "12827",
|
||||||
|
- `"used"` - "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"module"` - "ebtables",
|
||||||
|
- `"size"` - "35009",
|
||||||
|
- `"used"` - "2",
|
||||||
|
- `"by"` - [
|
||||||
|
"ebtable_nat",
|
||||||
|
"ebtable_filter"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ lsmod | jc --lsmod -p -r
|
<a id="jc.parsers.lsmod.info"></a>
|
||||||
[
|
|
||||||
...
|
|
||||||
{
|
|
||||||
"module": "nf_conntrack",
|
|
||||||
"size": "139224",
|
|
||||||
"used": "7",
|
|
||||||
"by": [
|
|
||||||
"nf_nat",
|
|
||||||
"nf_nat_ipv4",
|
|
||||||
"nf_nat_ipv6",
|
|
||||||
"xt_conntrack",
|
|
||||||
"nf_nat_masquerade_ipv4",
|
|
||||||
"nf_conntrack_ipv4",
|
|
||||||
"nf_conntrack_ipv6"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "ip_set",
|
|
||||||
"size": "45799",
|
|
||||||
"used": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "nfnetlink",
|
|
||||||
"size": "14519",
|
|
||||||
"used": "1",
|
|
||||||
"by": [
|
|
||||||
"ip_set"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "ebtable_filter",
|
|
||||||
"size": "12827",
|
|
||||||
"used": "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"module": "ebtables",
|
|
||||||
"size": "35009",
|
|
||||||
"used": "2",
|
|
||||||
"by": [
|
|
||||||
"ebtable_nat",
|
|
||||||
"ebtable_filter"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.lsmod.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,150 +1,162 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.lsof"></a>
|
||||||
|
|
||||||
# jc.parsers.lsof
|
# jc.parsers.lsof
|
||||||
|
|
||||||
jc - JSON CLI output utility `lsof` command output parser
|
jc - JSON CLI output utility `lsof` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ lsof | jc --lsof
|
$ lsof | jc --lsof
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc lsof
|
$ jc lsof
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('lsof', lsof_command_output)
|
result = jc.parse('lsof', lsof_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.lsof
|
import jc.parsers.lsof
|
||||||
result = jc.parsers.lsof.parse(lsof_command_output)
|
result = jc.parsers.lsof.parse(lsof_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"command": string,
|
"command": string,
|
||||||
"pid": integer,
|
"pid": integer,
|
||||||
"tid": integer,
|
"tid": integer,
|
||||||
"user": string,
|
"user": string,
|
||||||
"fd": string,
|
"fd": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"device": string,
|
"device": string,
|
||||||
"size_off": integer,
|
"size_off": integer,
|
||||||
"node": integer,
|
"node": integer,
|
||||||
"name": string
|
"name": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ sudo lsof | jc --lsof -p
|
|
||||||
[
|
$ sudo lsof | jc --lsof -p
|
||||||
{
|
[
|
||||||
"command": "systemd",
|
{
|
||||||
"pid": 1,
|
- `"command"` - "systemd",
|
||||||
"tid": null,
|
- `"pid"` - 1,
|
||||||
"user": "root",
|
- `"tid"` - null,
|
||||||
"fd": "cwd",
|
- `"user"` - "root",
|
||||||
"type": "DIR",
|
- `"fd"` - "cwd",
|
||||||
"device": "253,0",
|
- `"type"` - "DIR",
|
||||||
"size_off": 224,
|
- `"device"` - "253,0",
|
||||||
"node": 64,
|
- `"size_off"` - 224,
|
||||||
"name": "/"
|
- `"node"` - 64,
|
||||||
},
|
- `"name"` - "/"
|
||||||
{
|
},
|
||||||
"command": "systemd",
|
{
|
||||||
"pid": 1,
|
- `"command"` - "systemd",
|
||||||
"tid": null,
|
- `"pid"` - 1,
|
||||||
"user": "root",
|
- `"tid"` - null,
|
||||||
"fd": "rtd",
|
- `"user"` - "root",
|
||||||
"type": "DIR",
|
- `"fd"` - "rtd",
|
||||||
"device": "253,0",
|
- `"type"` - "DIR",
|
||||||
"size_off": 224,
|
- `"device"` - "253,0",
|
||||||
"node": 64,
|
- `"size_off"` - 224,
|
||||||
"name": "/"
|
- `"node"` - 64,
|
||||||
},
|
- `"name"` - "/"
|
||||||
{
|
},
|
||||||
"command": "systemd",
|
{
|
||||||
"pid": 1,
|
- `"command"` - "systemd",
|
||||||
"tid": null,
|
- `"pid"` - 1,
|
||||||
"user": "root",
|
- `"tid"` - null,
|
||||||
"fd": "txt",
|
- `"user"` - "root",
|
||||||
"type": "REG",
|
- `"fd"` - "txt",
|
||||||
"device": "253,0",
|
- `"type"` - "REG",
|
||||||
"size_off": 1624520,
|
- `"device"` - "253,0",
|
||||||
"node": 50360451,
|
- `"size_off"` - 1624520,
|
||||||
"name": "/usr/lib/systemd/systemd"
|
- `"node"` - 50360451,
|
||||||
},
|
- `"name"` - "/usr/lib/systemd/systemd"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo lsof | jc --lsof -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"command"` - "systemd",
|
||||||
|
- `"pid"` - "1",
|
||||||
|
- `"tid"` - null,
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"fd"` - "cwd",
|
||||||
|
- `"type"` - "DIR",
|
||||||
|
- `"device"` - "8,2",
|
||||||
|
- `"size_off"` - "4096",
|
||||||
|
- `"node"` - "2",
|
||||||
|
- `"name"` - "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"command"` - "systemd",
|
||||||
|
- `"pid"` - "1",
|
||||||
|
- `"tid"` - null,
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"fd"` - "rtd",
|
||||||
|
- `"type"` - "DIR",
|
||||||
|
- `"device"` - "8,2",
|
||||||
|
- `"size_off"` - "4096",
|
||||||
|
- `"node"` - "2",
|
||||||
|
- `"name"` - "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"command"` - "systemd",
|
||||||
|
- `"pid"` - "1",
|
||||||
|
- `"tid"` - null,
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"fd"` - "txt",
|
||||||
|
- `"type"` - "REG",
|
||||||
|
- `"device"` - "8,2",
|
||||||
|
- `"size_off"` - "1595792",
|
||||||
|
- `"node"` - "668802",
|
||||||
|
- `"name"` - "/lib/systemd/systemd"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ sudo lsof | jc --lsof -p -r
|
<a id="jc.parsers.lsof.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"command": "systemd",
|
|
||||||
"pid": "1",
|
|
||||||
"tid": null,
|
|
||||||
"user": "root",
|
|
||||||
"fd": "cwd",
|
|
||||||
"type": "DIR",
|
|
||||||
"device": "8,2",
|
|
||||||
"size_off": "4096",
|
|
||||||
"node": "2",
|
|
||||||
"name": "/"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"command": "systemd",
|
|
||||||
"pid": "1",
|
|
||||||
"tid": null,
|
|
||||||
"user": "root",
|
|
||||||
"fd": "rtd",
|
|
||||||
"type": "DIR",
|
|
||||||
"device": "8,2",
|
|
||||||
"size_off": "4096",
|
|
||||||
"node": "2",
|
|
||||||
"name": "/"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"command": "systemd",
|
|
||||||
"pid": "1",
|
|
||||||
"tid": null,
|
|
||||||
"user": "root",
|
|
||||||
"fd": "txt",
|
|
||||||
"type": "REG",
|
|
||||||
"device": "8,2",
|
|
||||||
"size_off": "1595792",
|
|
||||||
"node": "668802",
|
|
||||||
"name": "/lib/systemd/systemd"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.lsof.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,292 +1,304 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.lsusb"></a>
|
||||||
|
|
||||||
# jc.parsers.lsusb
|
# jc.parsers.lsusb
|
||||||
|
|
||||||
jc - JSON CLI output utility `lsusb` command output parser
|
jc - JSON CLI output utility `lsusb` command output parser
|
||||||
|
|
||||||
Supports the `-v` option or no options.
|
Supports the `-v` option or no options.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ lsusb -v | jc --lsusb
|
$ lsusb -v | jc --lsusb
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc lsusb -v
|
$ jc lsusb -v
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('lsusb', lsusb_command_output)
|
result = jc.parse('lsusb', lsusb_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.lsusb
|
import jc.parsers.lsusb
|
||||||
result = jc.parsers.lsusb.parse(lsusb_command_output)
|
result = jc.parsers.lsusb.parse(lsusb_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
Note: <item> object keynames are assigned directly from the lsusb
|
Note: <item> object keynames are assigned directly from the lsusb
|
||||||
output. If there are duplicate <item> names in a section, only the
|
output. If there are duplicate <item> names in a section, only the
|
||||||
last one is converted.
|
last one is converted.
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"bus": string,
|
"bus": string,
|
||||||
"device": string,
|
"device": string,
|
||||||
"id": string,
|
"id": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"device_descriptor": {
|
"device_descriptor": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"configuration_descriptor": {
|
"configuration_descriptor": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"interface_association": {
|
"interface_association": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interface_descriptors": [
|
"interface_descriptors": [
|
||||||
{
|
{
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cdc_header": {
|
"cdc_header": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cdc_call_management": {
|
"cdc_call_management": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cdc_acm": {
|
"cdc_acm": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cdc_union": {
|
"cdc_union": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"endpoint_descriptors": [
|
"endpoint_descriptors": [
|
||||||
{
|
{
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hub_descriptor": {
|
"hub_descriptor": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string,
|
string,
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hub_port_status": {
|
"hub_port_status": {
|
||||||
"<item>": {
|
"<item>": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"attributes": [
|
"attributes": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"device_status": {
|
"device_status": {
|
||||||
"value": string,
|
"value": string,
|
||||||
"description": string
|
"description": string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ lsusb -v | jc --lsusb -p
|
|
||||||
[
|
$ lsusb -v | jc --lsusb -p
|
||||||
{
|
[
|
||||||
"bus": "002",
|
{
|
||||||
"device": "001",
|
- `"bus"` - "002",
|
||||||
"id": "1d6b:0001",
|
- `"device"` - "001",
|
||||||
"description": "Linux Foundation 1.1 root hub",
|
- `"id"` - "1d6b:0001",
|
||||||
"device_descriptor": {
|
- `"description"` - "Linux Foundation 1.1 root hub",
|
||||||
"bLength": {
|
- `"device_descriptor"` - {
|
||||||
"value": "18"
|
- `"bLength"` - {
|
||||||
},
|
- `"value"` - "18"
|
||||||
"bDescriptorType": {
|
},
|
||||||
"value": "1"
|
- `"bDescriptorType"` - {
|
||||||
},
|
- `"value"` - "1"
|
||||||
"bcdUSB": {
|
},
|
||||||
"value": "1.10"
|
- `"bcdUSB"` - {
|
||||||
},
|
- `"value"` - "1.10"
|
||||||
...
|
},
|
||||||
"bNumConfigurations": {
|
...
|
||||||
"value": "1"
|
- `"bNumConfigurations"` - {
|
||||||
},
|
- `"value"` - "1"
|
||||||
"configuration_descriptor": {
|
},
|
||||||
"bLength": {
|
- `"configuration_descriptor"` - {
|
||||||
"value": "9"
|
- `"bLength"` - {
|
||||||
},
|
- `"value"` - "9"
|
||||||
...
|
},
|
||||||
"iConfiguration": {
|
...
|
||||||
"value": "0"
|
- `"iConfiguration"` - {
|
||||||
},
|
- `"value"` - "0"
|
||||||
"bmAttributes": {
|
},
|
||||||
"value": "0xe0",
|
- `"bmAttributes"` - {
|
||||||
"attributes": [
|
- `"value"` - "0xe0",
|
||||||
"Self Powered",
|
- `"attributes"` - [
|
||||||
"Remote Wakeup"
|
"Self Powered",
|
||||||
]
|
"Remote Wakeup"
|
||||||
},
|
]
|
||||||
"MaxPower": {
|
},
|
||||||
"description": "0mA"
|
- `"MaxPower"` - {
|
||||||
},
|
- `"description"` - "0mA"
|
||||||
"interface_descriptors": [
|
},
|
||||||
{
|
- `"interface_descriptors"` - [
|
||||||
"bLength": {
|
{
|
||||||
"value": "9"
|
- `"bLength"` - {
|
||||||
},
|
- `"value"` - "9"
|
||||||
...
|
},
|
||||||
"bInterfaceProtocol": {
|
...
|
||||||
"value": "0",
|
- `"bInterfaceProtocol"` - {
|
||||||
"description": "Full speed (or root) hub"
|
- `"value"` - "0",
|
||||||
},
|
- `"description"` - "Full speed (or root) hub"
|
||||||
"iInterface": {
|
},
|
||||||
"value": "0"
|
- `"iInterface"` - {
|
||||||
},
|
- `"value"` - "0"
|
||||||
"endpoint_descriptors": [
|
},
|
||||||
{
|
- `"endpoint_descriptors"` - [
|
||||||
"bLength": {
|
{
|
||||||
"value": "7"
|
- `"bLength"` - {
|
||||||
},
|
- `"value"` - "7"
|
||||||
...
|
},
|
||||||
"bmAttributes": {
|
...
|
||||||
"value": "3",
|
- `"bmAttributes"` - {
|
||||||
"attributes": [
|
- `"value"` - "3",
|
||||||
"Transfer Type Interrupt",
|
- `"attributes"` - [
|
||||||
"Synch Type None",
|
"Transfer Type Interrupt",
|
||||||
"Usage Type Data"
|
"Synch Type None",
|
||||||
]
|
"Usage Type Data"
|
||||||
},
|
]
|
||||||
"wMaxPacketSize": {
|
},
|
||||||
"value": "0x0002",
|
- `"wMaxPacketSize"` - {
|
||||||
"description": "1x 2 bytes"
|
- `"value"` - "0x0002",
|
||||||
},
|
- `"description"` - "1x 2 bytes"
|
||||||
"bInterval": {
|
},
|
||||||
"value": "255"
|
- `"bInterval"` - {
|
||||||
}
|
- `"value"` - "255"
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
},
|
}
|
||||||
"hub_descriptor": {
|
},
|
||||||
"bLength": {
|
- `"hub_descriptor"` - {
|
||||||
"value": "9"
|
- `"bLength"` - {
|
||||||
},
|
- `"value"` - "9"
|
||||||
...
|
},
|
||||||
"wHubCharacteristic": {
|
...
|
||||||
"value": "0x000a",
|
- `"wHubCharacteristic"` - {
|
||||||
"attributes": [
|
- `"value"` - "0x000a",
|
||||||
"No power switching (usb 1.0)",
|
- `"attributes"` - [
|
||||||
"Per-port overcurrent protection"
|
"No power switching (usb 1.0)",
|
||||||
]
|
"Per-port overcurrent protection"
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
"hub_port_status": {
|
...
|
||||||
"Port 1": {
|
- `"hub_port_status"` - {
|
||||||
"value": "0000.0103",
|
"Port 1": {
|
||||||
"attributes": [
|
- `"value"` - "0000.0103",
|
||||||
"power",
|
- `"attributes"` - [
|
||||||
"enable",
|
"power",
|
||||||
"connect"
|
"enable",
|
||||||
]
|
"connect"
|
||||||
},
|
]
|
||||||
"Port 2": {
|
},
|
||||||
"value": "0000.0103",
|
"Port 2": {
|
||||||
"attributes": [
|
- `"value"` - "0000.0103",
|
||||||
"power",
|
- `"attributes"` - [
|
||||||
"enable",
|
"power",
|
||||||
"connect"
|
"enable",
|
||||||
]
|
"connect"
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"device_status": {
|
},
|
||||||
"value": "0x0001",
|
- `"device_status"` - {
|
||||||
"description": "Self Powered"
|
- `"value"` - "0x0001",
|
||||||
}
|
- `"description"` - "Self Powered"
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.lsusb.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.lsusb.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,106 +1,118 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.mount"></a>
|
||||||
|
|
||||||
# jc.parsers.mount
|
# jc.parsers.mount
|
||||||
|
|
||||||
jc - JSON CLI output utility `mount` command output parser
|
jc - JSON CLI output utility `mount` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ mount | jc --mount
|
$ mount | jc --mount
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc mount
|
$ jc mount
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('mount', mount_command_output)
|
result = jc.parse('mount', mount_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.mount
|
import jc.parsers.mount
|
||||||
result = jc.parsers.mount.parse(mount_command_output)
|
result = jc.parsers.mount.parse(mount_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filesystem": string,
|
"filesystem": string,
|
||||||
"mount_point": string,
|
"mount_point": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"access": [
|
"access": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Example:
|
**Example**:
|
||||||
|
|
||||||
$ mount | jc --mount -p
|
|
||||||
[
|
$ mount | jc --mount -p
|
||||||
{
|
[
|
||||||
"filesystem": "sysfs",
|
{
|
||||||
"mount_point": "/sys",
|
- `"filesystem"` - "sysfs",
|
||||||
"type": "sysfs",
|
- `"mount_point"` - "/sys",
|
||||||
"access": [
|
- `"type"` - "sysfs",
|
||||||
"rw",
|
- `"access"` - [
|
||||||
"nosuid",
|
"rw",
|
||||||
"nodev",
|
"nosuid",
|
||||||
"noexec",
|
"nodev",
|
||||||
"relatime"
|
"noexec",
|
||||||
]
|
"relatime"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"filesystem": "proc",
|
{
|
||||||
"mount_point": "/proc",
|
- `"filesystem"` - "proc",
|
||||||
"type": "proc",
|
- `"mount_point"` - "/proc",
|
||||||
"access": [
|
- `"type"` - "proc",
|
||||||
"rw",
|
- `"access"` - [
|
||||||
"nosuid",
|
"rw",
|
||||||
"nodev",
|
"nosuid",
|
||||||
"noexec",
|
"nodev",
|
||||||
"relatime"
|
"noexec",
|
||||||
]
|
"relatime"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"filesystem": "udev",
|
{
|
||||||
"mount_point": "/dev",
|
- `"filesystem"` - "udev",
|
||||||
"type": "devtmpfs",
|
- `"mount_point"` - "/dev",
|
||||||
"access": [
|
- `"type"` - "devtmpfs",
|
||||||
"rw",
|
- `"access"` - [
|
||||||
"nosuid",
|
"rw",
|
||||||
"relatime",
|
"nosuid",
|
||||||
"size=977500k",
|
"relatime",
|
||||||
"nr_inodes=244375",
|
"size=977500k",
|
||||||
"mode=755"
|
"nr_inodes=244375",
|
||||||
]
|
"mode=755"
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.mount.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.mount.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,386 +1,398 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.netstat"></a>
|
||||||
|
|
||||||
# jc.parsers.netstat
|
# jc.parsers.netstat
|
||||||
|
|
||||||
jc - JSON CLI output utility `netstat` command output parser
|
jc - JSON CLI output utility `netstat` command output parser
|
||||||
|
|
||||||
Caveats:
|
Caveats:
|
||||||
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
|
- Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`)
|
||||||
- Use of the `A` option is not supported on OSX when using the `r` option
|
- Use of the `A` option is not supported on OSX when using the `r` option
|
||||||
(e.g. `netstat -rA`)
|
(e.g. `netstat -rA`)
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ netstat | jc --netstat
|
$ netstat | jc --netstat
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc netstat
|
$ jc netstat
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('netstat', netstat_command_output)
|
result = jc.parse('netstat', netstat_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.netstat
|
import jc.parsers.netstat
|
||||||
result = jc.parsers.netstat.parse(netstat_command_output)
|
result = jc.parsers.netstat.parse(netstat_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"proto": string,
|
"proto": string,
|
||||||
"recv_q": integer,
|
"recv_q": integer,
|
||||||
"send_q": integer,
|
"send_q": integer,
|
||||||
"transport_protocol" string,
|
"transport_protocol" string,
|
||||||
"network_protocol": string,
|
"network_protocol": string,
|
||||||
"local_address": string,
|
"local_address": string,
|
||||||
"local_port": string,
|
"local_port": string,
|
||||||
"local_port_num": integer,
|
"local_port_num": integer,
|
||||||
"foreign_address": string,
|
"foreign_address": string,
|
||||||
"foreign_port": string,
|
"foreign_port": string,
|
||||||
"foreign_port_num": integer,
|
"foreign_port_num": integer,
|
||||||
"state": string,
|
"state": string,
|
||||||
"program_name": string,
|
"program_name": string,
|
||||||
"pid": integer,
|
"pid": integer,
|
||||||
"user": string,
|
"user": string,
|
||||||
"security_context": string,
|
"security_context": string,
|
||||||
"refcnt": integer,
|
"refcnt": integer,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"inode": integer,
|
"inode": integer,
|
||||||
"path": string,
|
"path": string,
|
||||||
"kind": string,
|
"kind": string,
|
||||||
"address": string,
|
"address": string,
|
||||||
"unix_inode": string,
|
"unix_inode": string,
|
||||||
"conn": string,
|
"conn": string,
|
||||||
"refs": string,
|
"refs": string,
|
||||||
"nextref": string,
|
"nextref": string,
|
||||||
"name": string,
|
"name": string,
|
||||||
"unit": integer,
|
"unit": integer,
|
||||||
"vendor": integer,
|
"vendor": integer,
|
||||||
"class": integer,
|
"class": integer,
|
||||||
"subcla": integer,
|
"subcla": integer,
|
||||||
"unix_flags": integer,
|
"unix_flags": integer,
|
||||||
"pcbcount": integer,
|
"pcbcount": integer,
|
||||||
"rcvbuf": integer,
|
"rcvbuf": integer,
|
||||||
"sndbuf": integer,
|
"sndbuf": integer,
|
||||||
"rxbytes": integer,
|
"rxbytes": integer,
|
||||||
"txbytes": integer,
|
"txbytes": integer,
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"gateway": string,
|
"gateway": string,
|
||||||
"route_flags": string,
|
"route_flags": string,
|
||||||
"route_flags_pretty": [
|
"route_flags_pretty": [
|
||||||
string,
|
string,
|
||||||
]
|
]
|
||||||
"route_refs": integer,
|
"route_refs": integer,
|
||||||
"use": integer,
|
"use": integer,
|
||||||
"mtu": integer,
|
"mtu": integer,
|
||||||
"expire": string,
|
"expire": string,
|
||||||
"genmask": string,
|
"genmask": string,
|
||||||
"mss": integer,
|
"mss": integer,
|
||||||
"window": integer,
|
"window": integer,
|
||||||
"irtt": integer,
|
"irtt": integer,
|
||||||
"iface": string,
|
"iface": string,
|
||||||
"metric": integer,
|
"metric": integer,
|
||||||
"network": string,
|
"network": string,
|
||||||
"address": string,
|
"address": string,
|
||||||
"ipkts": integer, # - = null
|
"ipkts": integer, # - = null
|
||||||
"ierrs": integer, # - = null
|
"ierrs": integer, # - = null
|
||||||
"idrop": integer, # - = null
|
"idrop": integer, # - = null
|
||||||
"opkts": integer, # - = null
|
"opkts": integer, # - = null
|
||||||
"oerrs": integer, # - = null
|
"oerrs": integer, # - = null
|
||||||
"coll": integer, # - = null
|
"coll": integer, # - = null
|
||||||
"rx_ok": integer,
|
"rx_ok": integer,
|
||||||
"rx_err": integer,
|
"rx_err": integer,
|
||||||
"rx_drp": integer,
|
"rx_drp": integer,
|
||||||
"rx_ovr": integer,
|
"rx_ovr": integer,
|
||||||
"tx_ok": integer,
|
"tx_ok": integer,
|
||||||
"tx_err": integer,
|
"tx_err": integer,
|
||||||
"tx_drp": integer,
|
"tx_drp": integer,
|
||||||
"tx_ovr": integer,
|
"tx_ovr": integer,
|
||||||
"flg": string,
|
"flg": string,
|
||||||
"ibytes": integer,
|
"ibytes": integer,
|
||||||
"obytes": integer,
|
"obytes": integer,
|
||||||
"r_mbuf": integer,
|
"r_mbuf": integer,
|
||||||
"s_mbuf": integer,
|
"s_mbuf": integer,
|
||||||
"r_clus": integer,
|
"r_clus": integer,
|
||||||
"s_clus": integer,
|
"s_clus": integer,
|
||||||
"r_hiwa": integer,
|
"r_hiwa": integer,
|
||||||
"s_hiwa": integer,
|
"s_hiwa": integer,
|
||||||
"r_lowa": integer,
|
"r_lowa": integer,
|
||||||
"s_lowa": integer,
|
"s_lowa": integer,
|
||||||
"r_bcnt": integer,
|
"r_bcnt": integer,
|
||||||
"s_bcnt": integer,
|
"s_bcnt": integer,
|
||||||
"r_bmax": integer,
|
"r_bmax": integer,
|
||||||
"s_bmax": integer,
|
"s_bmax": integer,
|
||||||
"rexmit": integer,
|
"rexmit": integer,
|
||||||
"ooorcv": integer,
|
"ooorcv": integer,
|
||||||
"0_win": integer,
|
"0_win": integer,
|
||||||
"rexmt": float,
|
"rexmt": float,
|
||||||
"persist": float,
|
"persist": float,
|
||||||
"keep": float,
|
"keep": float,
|
||||||
"2msl": float,
|
"2msl": float,
|
||||||
"delack": float,
|
"delack": float,
|
||||||
"rcvtime": float,
|
"rcvtime": float,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
# netstat -apee | jc --netstat -p
|
|
||||||
[
|
# netstat -apee | jc --netstat -p
|
||||||
{
|
[
|
||||||
"proto": "tcp",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "tcp",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "localhost",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "0.0.0.0",
|
- `"local_address"` - "localhost",
|
||||||
"state": "LISTEN",
|
- `"foreign_address"` - "0.0.0.0",
|
||||||
"user": "systemd-resolve",
|
- `"state"` - "LISTEN",
|
||||||
"inode": 26958,
|
- `"user"` - "systemd-resolve",
|
||||||
"program_name": "systemd-resolve",
|
- `"inode"` - 26958,
|
||||||
"kind": "network",
|
- `"program_name"` - "systemd-resolve",
|
||||||
"pid": 887,
|
- `"kind"` - "network",
|
||||||
"local_port": "domain",
|
- `"pid"` - 887,
|
||||||
"foreign_port": "*",
|
- `"local_port"` - "domain",
|
||||||
"transport_protocol": "tcp",
|
- `"foreign_port"` - "*",
|
||||||
"network_protocol": "ipv4"
|
- `"transport_protocol"` - "tcp",
|
||||||
},
|
- `"network_protocol"` - "ipv4"
|
||||||
{
|
},
|
||||||
"proto": "tcp",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "tcp",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "0.0.0.0",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "0.0.0.0",
|
- `"local_address"` - "0.0.0.0",
|
||||||
"state": "LISTEN",
|
- `"foreign_address"` - "0.0.0.0",
|
||||||
"user": "root",
|
- `"state"` - "LISTEN",
|
||||||
"inode": 30499,
|
- `"user"` - "root",
|
||||||
"program_name": "sshd",
|
- `"inode"` - 30499,
|
||||||
"kind": "network",
|
- `"program_name"` - "sshd",
|
||||||
"pid": 1186,
|
- `"kind"` - "network",
|
||||||
"local_port": "ssh",
|
- `"pid"` - 1186,
|
||||||
"foreign_port": "*",
|
- `"local_port"` - "ssh",
|
||||||
"transport_protocol": "tcp",
|
- `"foreign_port"` - "*",
|
||||||
"network_protocol": "ipv4"
|
- `"transport_protocol"` - "tcp",
|
||||||
},
|
- `"network_protocol"` - "ipv4"
|
||||||
{
|
},
|
||||||
"proto": "tcp",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "tcp",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "localhost",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "localhost",
|
- `"local_address"` - "localhost",
|
||||||
"state": "ESTABLISHED",
|
- `"foreign_address"` - "localhost",
|
||||||
"user": "root",
|
- `"state"` - "ESTABLISHED",
|
||||||
"inode": 46829,
|
- `"user"` - "root",
|
||||||
"program_name": "sshd: root",
|
- `"inode"` - 46829,
|
||||||
"kind": "network",
|
- `"program_name"` - "sshd: root",
|
||||||
"pid": 2242,
|
- `"kind"` - "network",
|
||||||
"local_port": "ssh",
|
- `"pid"` - 2242,
|
||||||
"foreign_port": "52186",
|
- `"local_port"` - "ssh",
|
||||||
"transport_protocol": "tcp",
|
- `"foreign_port"` - "52186",
|
||||||
"network_protocol": "ipv4",
|
- `"transport_protocol"` - "tcp",
|
||||||
"foreign_port_num": 52186
|
- `"network_protocol"` - "ipv4",
|
||||||
},
|
- `"foreign_port_num"` - 52186
|
||||||
{
|
},
|
||||||
"proto": "tcp",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "tcp",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "localhost",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "localhost",
|
- `"local_address"` - "localhost",
|
||||||
"state": "ESTABLISHED",
|
- `"foreign_address"` - "localhost",
|
||||||
"user": "root",
|
- `"state"` - "ESTABLISHED",
|
||||||
"inode": 46828,
|
- `"user"` - "root",
|
||||||
"program_name": "ssh",
|
- `"inode"` - 46828,
|
||||||
"kind": "network",
|
- `"program_name"` - "ssh",
|
||||||
"pid": 2241,
|
- `"kind"` - "network",
|
||||||
"local_port": "52186",
|
- `"pid"` - 2241,
|
||||||
"foreign_port": "ssh",
|
- `"local_port"` - "52186",
|
||||||
"transport_protocol": "tcp",
|
- `"foreign_port"` - "ssh",
|
||||||
"network_protocol": "ipv4",
|
- `"transport_protocol"` - "tcp",
|
||||||
"local_port_num": 52186
|
- `"network_protocol"` - "ipv4",
|
||||||
},
|
- `"local_port_num"` - 52186
|
||||||
{
|
},
|
||||||
"proto": "tcp6",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "tcp6",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "[::]",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "[::]",
|
- `"local_address"` - "[::]",
|
||||||
"state": "LISTEN",
|
- `"foreign_address"` - "[::]",
|
||||||
"user": "root",
|
- `"state"` - "LISTEN",
|
||||||
"inode": 30510,
|
- `"user"` - "root",
|
||||||
"program_name": "sshd",
|
- `"inode"` - 30510,
|
||||||
"kind": "network",
|
- `"program_name"` - "sshd",
|
||||||
"pid": 1186,
|
- `"kind"` - "network",
|
||||||
"local_port": "ssh",
|
- `"pid"` - 1186,
|
||||||
"foreign_port": "*",
|
- `"local_port"` - "ssh",
|
||||||
"transport_protocol": "tcp",
|
- `"foreign_port"` - "*",
|
||||||
"network_protocol": "ipv6"
|
- `"transport_protocol"` - "tcp",
|
||||||
},
|
- `"network_protocol"` - "ipv6"
|
||||||
{
|
},
|
||||||
"proto": "udp",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "udp",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "localhost",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "0.0.0.0",
|
- `"local_address"` - "localhost",
|
||||||
"state": null,
|
- `"foreign_address"` - "0.0.0.0",
|
||||||
"user": "systemd-resolve",
|
- `"state"` - null,
|
||||||
"inode": 26957,
|
- `"user"` - "systemd-resolve",
|
||||||
"program_name": "systemd-resolve",
|
- `"inode"` - 26957,
|
||||||
"kind": "network",
|
- `"program_name"` - "systemd-resolve",
|
||||||
"pid": 887,
|
- `"kind"` - "network",
|
||||||
"local_port": "domain",
|
- `"pid"` - 887,
|
||||||
"foreign_port": "*",
|
- `"local_port"` - "domain",
|
||||||
"transport_protocol": "udp",
|
- `"foreign_port"` - "*",
|
||||||
"network_protocol": "ipv4"
|
- `"transport_protocol"` - "udp",
|
||||||
},
|
- `"network_protocol"` - "ipv4"
|
||||||
{
|
},
|
||||||
"proto": "raw6",
|
{
|
||||||
"recv_q": 0,
|
- `"proto"` - "raw6",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "[::]",
|
- `"send_q"` - 0,
|
||||||
"foreign_address": "[::]",
|
- `"local_address"` - "[::]",
|
||||||
"state": "7",
|
- `"foreign_address"` - "[::]",
|
||||||
"user": "systemd-network",
|
- `"state"` - "7",
|
||||||
"inode": 27001,
|
- `"user"` - "systemd-network",
|
||||||
"program_name": "systemd-network",
|
- `"inode"` - 27001,
|
||||||
"kind": "network",
|
- `"program_name"` - "systemd-network",
|
||||||
"pid": 867,
|
- `"kind"` - "network",
|
||||||
"local_port": "ipv6-icmp",
|
- `"pid"` - 867,
|
||||||
"foreign_port": "*",
|
- `"local_port"` - "ipv6-icmp",
|
||||||
"transport_protocol": null,
|
- `"foreign_port"` - "*",
|
||||||
"network_protocol": "ipv6"
|
- `"transport_protocol"` - null,
|
||||||
},
|
- `"network_protocol"` - "ipv6"
|
||||||
{
|
},
|
||||||
"proto": "unix",
|
{
|
||||||
"refcnt": 2,
|
- `"proto"` - "unix",
|
||||||
"flags": null,
|
- `"refcnt"` - 2,
|
||||||
"type": "DGRAM",
|
- `"flags"` - null,
|
||||||
"state": null,
|
- `"type"` - "DGRAM",
|
||||||
"inode": 33322,
|
- `"state"` - null,
|
||||||
"program_name": "systemd",
|
- `"inode"` - 33322,
|
||||||
"path": "/run/user/1000/systemd/notify",
|
- `"program_name"` - "systemd",
|
||||||
"kind": "socket",
|
- `"path"` - "/run/user/1000/systemd/notify",
|
||||||
"pid": 1607
|
- `"kind"` - "socket",
|
||||||
},
|
- `"pid"` - 1607
|
||||||
{
|
},
|
||||||
"proto": "unix",
|
{
|
||||||
"refcnt": 2,
|
- `"proto"` - "unix",
|
||||||
"flags": "ACC",
|
- `"refcnt"` - 2,
|
||||||
"type": "SEQPACKET",
|
- `"flags"` - "ACC",
|
||||||
"state": "LISTENING",
|
- `"type"` - "SEQPACKET",
|
||||||
"inode": 20835,
|
- `"state"` - "LISTENING",
|
||||||
"program_name": "init",
|
- `"inode"` - 20835,
|
||||||
"path": "/run/udev/control",
|
- `"program_name"` - "init",
|
||||||
"kind": "socket",
|
- `"path"` - "/run/udev/control",
|
||||||
"pid": 1
|
- `"kind"` - "socket",
|
||||||
},
|
- `"pid"` - 1
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ netstat -r | jc --netstat -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"destination"` - "default",
|
||||||
|
- `"gateway"` - "gateway",
|
||||||
|
- `"genmask"` - "0.0.0.0",
|
||||||
|
- `"route_flags"` - "UG",
|
||||||
|
- `"mss"` - 0,
|
||||||
|
- `"window"` - 0,
|
||||||
|
- `"irtt"` - 0,
|
||||||
|
- `"iface"` - "ens33",
|
||||||
|
- `"kind"` - "route",
|
||||||
|
- `"route_flags_pretty"` - [
|
||||||
|
"UP",
|
||||||
|
"GATEWAY"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"destination"` - "172.17.0.0",
|
||||||
|
- `"gateway"` - "0.0.0.0",
|
||||||
|
- `"genmask"` - "255.255.0.0",
|
||||||
|
- `"route_flags"` - "U",
|
||||||
|
- `"mss"` - 0,
|
||||||
|
- `"window"` - 0,
|
||||||
|
- `"irtt"` - 0,
|
||||||
|
- `"iface"` - "docker0",
|
||||||
|
- `"kind"` - "route",
|
||||||
|
- `"route_flags_pretty"` - [
|
||||||
|
"UP"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"destination"` - "192.168.71.0",
|
||||||
|
- `"gateway"` - "0.0.0.0",
|
||||||
|
- `"genmask"` - "255.255.255.0",
|
||||||
|
- `"route_flags"` - "U",
|
||||||
|
- `"mss"` - 0,
|
||||||
|
- `"window"` - 0,
|
||||||
|
- `"irtt"` - 0,
|
||||||
|
- `"iface"` - "ens33",
|
||||||
|
- `"kind"` - "route",
|
||||||
|
- `"route_flags_pretty"` - [
|
||||||
|
"UP"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ netstat -i | jc --netstat -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"iface"` - "ens33",
|
||||||
|
- `"mtu"` - 1500,
|
||||||
|
- `"rx_ok"` - 476,
|
||||||
|
- `"rx_err"` - 0,
|
||||||
|
- `"rx_drp"` - 0,
|
||||||
|
- `"rx_ovr"` - 0,
|
||||||
|
- `"tx_ok"` - 312,
|
||||||
|
- `"tx_err"` - 0,
|
||||||
|
- `"tx_drp"` - 0,
|
||||||
|
- `"tx_ovr"` - 0,
|
||||||
|
- `"flg"` - "BMRU",
|
||||||
|
- `"kind"` - "interface"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"iface"` - "lo",
|
||||||
|
- `"mtu"` - 65536,
|
||||||
|
- `"rx_ok"` - 0,
|
||||||
|
- `"rx_err"` - 0,
|
||||||
|
- `"rx_drp"` - 0,
|
||||||
|
- `"rx_ovr"` - 0,
|
||||||
|
- `"tx_ok"` - 0,
|
||||||
|
- `"tx_err"` - 0,
|
||||||
|
- `"tx_drp"` - 0,
|
||||||
|
- `"tx_ovr"` - 0,
|
||||||
|
- `"flg"` - "LRU",
|
||||||
|
- `"kind"` - "interface"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ netstat -r | jc --netstat -p
|
<a id="jc.parsers.netstat.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"destination": "default",
|
|
||||||
"gateway": "gateway",
|
|
||||||
"genmask": "0.0.0.0",
|
|
||||||
"route_flags": "UG",
|
|
||||||
"mss": 0,
|
|
||||||
"window": 0,
|
|
||||||
"irtt": 0,
|
|
||||||
"iface": "ens33",
|
|
||||||
"kind": "route",
|
|
||||||
"route_flags_pretty": [
|
|
||||||
"UP",
|
|
||||||
"GATEWAY"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"destination": "172.17.0.0",
|
|
||||||
"gateway": "0.0.0.0",
|
|
||||||
"genmask": "255.255.0.0",
|
|
||||||
"route_flags": "U",
|
|
||||||
"mss": 0,
|
|
||||||
"window": 0,
|
|
||||||
"irtt": 0,
|
|
||||||
"iface": "docker0",
|
|
||||||
"kind": "route",
|
|
||||||
"route_flags_pretty": [
|
|
||||||
"UP"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"destination": "192.168.71.0",
|
|
||||||
"gateway": "0.0.0.0",
|
|
||||||
"genmask": "255.255.255.0",
|
|
||||||
"route_flags": "U",
|
|
||||||
"mss": 0,
|
|
||||||
"window": 0,
|
|
||||||
"irtt": 0,
|
|
||||||
"iface": "ens33",
|
|
||||||
"kind": "route",
|
|
||||||
"route_flags_pretty": [
|
|
||||||
"UP"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ netstat -i | jc --netstat -p
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"iface": "ens33",
|
|
||||||
"mtu": 1500,
|
|
||||||
"rx_ok": 476,
|
|
||||||
"rx_err": 0,
|
|
||||||
"rx_drp": 0,
|
|
||||||
"rx_ovr": 0,
|
|
||||||
"tx_ok": 312,
|
|
||||||
"tx_err": 0,
|
|
||||||
"tx_drp": 0,
|
|
||||||
"tx_ovr": 0,
|
|
||||||
"flg": "BMRU",
|
|
||||||
"kind": "interface"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"iface": "lo",
|
|
||||||
"mtu": 65536,
|
|
||||||
"rx_ok": 0,
|
|
||||||
"rx_err": 0,
|
|
||||||
"rx_drp": 0,
|
|
||||||
"rx_ovr": 0,
|
|
||||||
"tx_ok": 0,
|
|
||||||
"tx_err": 0,
|
|
||||||
"tx_drp": 0,
|
|
||||||
"tx_ovr": 0,
|
|
||||||
"flg": "LRU",
|
|
||||||
"kind": "interface"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.netstat.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,237 +1,249 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ntpq"></a>
|
||||||
|
|
||||||
# jc.parsers.ntpq
|
# jc.parsers.ntpq
|
||||||
|
|
||||||
jc - JSON CLI output utility `ntpq -p` command output parser
|
jc - JSON CLI output utility `ntpq -p` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ntpq -p | jc --ntpq
|
$ ntpq -p | jc --ntpq
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ntpq -p
|
$ jc ntpq -p
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ntpq', ntpq_command_output)
|
result = jc.parse('ntpq', ntpq_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ntpq
|
import jc.parsers.ntpq
|
||||||
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"state": string, # space/~ converted to null
|
"state": string, # space/~ converted to null
|
||||||
"remote": string,
|
"remote": string,
|
||||||
"refid": string,
|
"refid": string,
|
||||||
"st": integer,
|
"st": integer,
|
||||||
"t": string,
|
"t": string,
|
||||||
"when": integer, # - converted to null
|
"when": integer, # - converted to null
|
||||||
"poll": integer,
|
"poll": integer,
|
||||||
"reach": integer,
|
"reach": integer,
|
||||||
"delay": float,
|
"delay": float,
|
||||||
"offset": float,
|
"offset": float,
|
||||||
"jitter": float
|
"jitter": float
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ntpq -p | jc --ntpq -p
|
|
||||||
[
|
$ ntpq -p | jc --ntpq -p
|
||||||
{
|
[
|
||||||
"remote": "44.190.6.254",
|
{
|
||||||
"refid": "127.67.113.92",
|
- `"remote"` - "44.190.6.254",
|
||||||
"st": 2,
|
- `"refid"` - "127.67.113.92",
|
||||||
"t": "u",
|
- `"st"` - 2,
|
||||||
"when": 1,
|
- `"t"` - "u",
|
||||||
"poll": 64,
|
- `"when"` - 1,
|
||||||
"reach": 1,
|
- `"poll"` - 64,
|
||||||
"delay": 23.399,
|
- `"reach"` - 1,
|
||||||
"offset": -2.805,
|
- `"delay"` - 23.399,
|
||||||
"jitter": 2.131,
|
- `"offset"` - -2.805,
|
||||||
"state": null
|
- `"jitter"` - 2.131,
|
||||||
},
|
- `"state"` - null
|
||||||
{
|
},
|
||||||
"remote": "ntp.wdc1.us.lea",
|
{
|
||||||
"refid": "130.133.1.10",
|
- `"remote"` - "ntp.wdc1.us.lea",
|
||||||
"st": 2,
|
- `"refid"` - "130.133.1.10",
|
||||||
"t": "u",
|
- `"st"` - 2,
|
||||||
"when": null,
|
- `"t"` - "u",
|
||||||
"poll": 64,
|
- `"when"` - null,
|
||||||
"reach": 1,
|
- `"poll"` - 64,
|
||||||
"delay": 93.053,
|
- `"reach"` - 1,
|
||||||
"offset": -0.807,
|
- `"delay"` - 93.053,
|
||||||
"jitter": 2.839,
|
- `"offset"` - -0.807,
|
||||||
"state": null
|
- `"jitter"` - 2.839,
|
||||||
},
|
- `"state"` - null
|
||||||
{
|
},
|
||||||
"remote": "clock.team-cymr",
|
{
|
||||||
"refid": "204.9.54.119",
|
- `"remote"` - "clock.team-cymr",
|
||||||
"st": 2,
|
- `"refid"` - "204.9.54.119",
|
||||||
"t": "u",
|
- `"st"` - 2,
|
||||||
"when": null,
|
- `"t"` - "u",
|
||||||
"poll": 64,
|
- `"when"` - null,
|
||||||
"reach": 1,
|
- `"poll"` - 64,
|
||||||
"delay": 70.337,
|
- `"reach"` - 1,
|
||||||
"offset": -2.909,
|
- `"delay"` - 70.337,
|
||||||
"jitter": 2.6,
|
- `"offset"` - -2.909,
|
||||||
"state": null
|
- `"jitter"` - 2.6,
|
||||||
},
|
- `"state"` - null
|
||||||
{
|
},
|
||||||
"remote": "mirror1.sjc02.s",
|
{
|
||||||
"refid": "216.218.254.202",
|
- `"remote"` - "mirror1.sjc02.s",
|
||||||
"st": 2,
|
- `"refid"` - "216.218.254.202",
|
||||||
"t": "u",
|
- `"st"` - 2,
|
||||||
"when": 2,
|
- `"t"` - "u",
|
||||||
"poll": 64,
|
- `"when"` - 2,
|
||||||
"reach": 1,
|
- `"poll"` - 64,
|
||||||
"delay": 29.325,
|
- `"reach"` - 1,
|
||||||
"offset": 1.044,
|
- `"delay"` - 29.325,
|
||||||
"jitter": 4.069,
|
- `"offset"` - 1.044,
|
||||||
"state": null,
|
- `"jitter"` - 4.069,
|
||||||
}
|
- `"state"` - null,
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ntpq -pn| jc --ntpq -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"remote"` - "44.190.6.254",
|
||||||
|
- `"refid"` - "127.67.113.92",
|
||||||
|
- `"st"` - 2,
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - 66,
|
||||||
|
- `"poll"` - 64,
|
||||||
|
- `"reach"` - 377,
|
||||||
|
- `"delay"` - 22.69,
|
||||||
|
- `"offset"` - -0.392,
|
||||||
|
- `"jitter"` - 2.085,
|
||||||
|
- `"state"` - "+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"remote"` - "108.59.2.24",
|
||||||
|
- `"refid"` - "130.133.1.10",
|
||||||
|
- `"st"` - 2,
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - 63,
|
||||||
|
- `"poll"` - 64,
|
||||||
|
- `"reach"` - 377,
|
||||||
|
- `"delay"` - 90.805,
|
||||||
|
- `"offset"` - 2.84,
|
||||||
|
- `"jitter"` - 1.908,
|
||||||
|
- `"state"` - "-"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"remote"` - "38.229.71.1",
|
||||||
|
- `"refid"` - "204.9.54.119",
|
||||||
|
- `"st"` - 2,
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - 64,
|
||||||
|
- `"poll"` - 64,
|
||||||
|
- `"reach"` - 377,
|
||||||
|
- `"delay"` - 68.699,
|
||||||
|
- `"offset"` - -0.61,
|
||||||
|
- `"jitter"` - 2.576,
|
||||||
|
- `"state"` - "+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"remote"` - "72.5.72.15",
|
||||||
|
- `"refid"` - "216.218.254.202",
|
||||||
|
- `"st"` - 2,
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - 63,
|
||||||
|
- `"poll"` - 64,
|
||||||
|
- `"reach"` - 377,
|
||||||
|
- `"delay"` - 22.654,
|
||||||
|
- `"offset"` - 0.231,
|
||||||
|
- `"jitter"` - 1.964,
|
||||||
|
- `"state"` - "*"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ntpq -pn| jc --ntpq -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"s"` - "+",
|
||||||
|
- `"remote"` - "44.190.6.254",
|
||||||
|
- `"refid"` - "127.67.113.92",
|
||||||
|
- `"st"` - "2",
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - "66",
|
||||||
|
- `"poll"` - "64",
|
||||||
|
- `"reach"` - "377",
|
||||||
|
- `"delay"` - "22.690",
|
||||||
|
- `"offset"` - "-0.392",
|
||||||
|
- `"jitter"` - "2.085"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"s"` - "-",
|
||||||
|
- `"remote"` - "108.59.2.24",
|
||||||
|
- `"refid"` - "130.133.1.10",
|
||||||
|
- `"st"` - "2",
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - "63",
|
||||||
|
- `"poll"` - "64",
|
||||||
|
- `"reach"` - "377",
|
||||||
|
- `"delay"` - "90.805",
|
||||||
|
- `"offset"` - "2.840",
|
||||||
|
- `"jitter"` - "1.908"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"s"` - "+",
|
||||||
|
- `"remote"` - "38.229.71.1",
|
||||||
|
- `"refid"` - "204.9.54.119",
|
||||||
|
- `"st"` - "2",
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - "64",
|
||||||
|
- `"poll"` - "64",
|
||||||
|
- `"reach"` - "377",
|
||||||
|
- `"delay"` - "68.699",
|
||||||
|
- `"offset"` - "-0.610",
|
||||||
|
- `"jitter"` - "2.576"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"s"` - "*",
|
||||||
|
- `"remote"` - "72.5.72.15",
|
||||||
|
- `"refid"` - "216.218.254.202",
|
||||||
|
- `"st"` - "2",
|
||||||
|
- `"t"` - "u",
|
||||||
|
- `"when"` - "63",
|
||||||
|
- `"poll"` - "64",
|
||||||
|
- `"reach"` - "377",
|
||||||
|
- `"delay"` - "22.654",
|
||||||
|
- `"offset"` - "0.231",
|
||||||
|
- `"jitter"` - "1.964"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ ntpq -pn| jc --ntpq -p
|
<a id="jc.parsers.ntpq.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"remote": "44.190.6.254",
|
|
||||||
"refid": "127.67.113.92",
|
|
||||||
"st": 2,
|
|
||||||
"t": "u",
|
|
||||||
"when": 66,
|
|
||||||
"poll": 64,
|
|
||||||
"reach": 377,
|
|
||||||
"delay": 22.69,
|
|
||||||
"offset": -0.392,
|
|
||||||
"jitter": 2.085,
|
|
||||||
"state": "+"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"remote": "108.59.2.24",
|
|
||||||
"refid": "130.133.1.10",
|
|
||||||
"st": 2,
|
|
||||||
"t": "u",
|
|
||||||
"when": 63,
|
|
||||||
"poll": 64,
|
|
||||||
"reach": 377,
|
|
||||||
"delay": 90.805,
|
|
||||||
"offset": 2.84,
|
|
||||||
"jitter": 1.908,
|
|
||||||
"state": "-"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"remote": "38.229.71.1",
|
|
||||||
"refid": "204.9.54.119",
|
|
||||||
"st": 2,
|
|
||||||
"t": "u",
|
|
||||||
"when": 64,
|
|
||||||
"poll": 64,
|
|
||||||
"reach": 377,
|
|
||||||
"delay": 68.699,
|
|
||||||
"offset": -0.61,
|
|
||||||
"jitter": 2.576,
|
|
||||||
"state": "+"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"remote": "72.5.72.15",
|
|
||||||
"refid": "216.218.254.202",
|
|
||||||
"st": 2,
|
|
||||||
"t": "u",
|
|
||||||
"when": 63,
|
|
||||||
"poll": 64,
|
|
||||||
"reach": 377,
|
|
||||||
"delay": 22.654,
|
|
||||||
"offset": 0.231,
|
|
||||||
"jitter": 1.964,
|
|
||||||
"state": "*"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
$ ntpq -pn| jc --ntpq -p -r
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"s": "+",
|
|
||||||
"remote": "44.190.6.254",
|
|
||||||
"refid": "127.67.113.92",
|
|
||||||
"st": "2",
|
|
||||||
"t": "u",
|
|
||||||
"when": "66",
|
|
||||||
"poll": "64",
|
|
||||||
"reach": "377",
|
|
||||||
"delay": "22.690",
|
|
||||||
"offset": "-0.392",
|
|
||||||
"jitter": "2.085"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"s": "-",
|
|
||||||
"remote": "108.59.2.24",
|
|
||||||
"refid": "130.133.1.10",
|
|
||||||
"st": "2",
|
|
||||||
"t": "u",
|
|
||||||
"when": "63",
|
|
||||||
"poll": "64",
|
|
||||||
"reach": "377",
|
|
||||||
"delay": "90.805",
|
|
||||||
"offset": "2.840",
|
|
||||||
"jitter": "1.908"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"s": "+",
|
|
||||||
"remote": "38.229.71.1",
|
|
||||||
"refid": "204.9.54.119",
|
|
||||||
"st": "2",
|
|
||||||
"t": "u",
|
|
||||||
"when": "64",
|
|
||||||
"poll": "64",
|
|
||||||
"reach": "377",
|
|
||||||
"delay": "68.699",
|
|
||||||
"offset": "-0.610",
|
|
||||||
"jitter": "2.576"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"s": "*",
|
|
||||||
"remote": "72.5.72.15",
|
|
||||||
"refid": "216.218.254.202",
|
|
||||||
"st": "2",
|
|
||||||
"t": "u",
|
|
||||||
"when": "63",
|
|
||||||
"poll": "64",
|
|
||||||
"reach": "377",
|
|
||||||
"delay": "22.654",
|
|
||||||
"offset": "0.231",
|
|
||||||
"jitter": "1.964"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ntpq.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, freebsd
|
Compatibility: linux, freebsd
|
||||||
|
@ -1,125 +1,137 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.passwd"></a>
|
||||||
|
|
||||||
# jc.parsers.passwd
|
# jc.parsers.passwd
|
||||||
|
|
||||||
jc - JSON CLI output utility `/etc/passwd` file Parser
|
jc - JSON CLI output utility `/etc/passwd` file Parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat /etc/passwd | jc --passwd
|
$ cat /etc/passwd | jc --passwd
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('passwd', passwd_file_output)
|
result = jc.parse('passwd', passwd_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.passwd
|
import jc.parsers.passwd
|
||||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"username": string,
|
"username": string,
|
||||||
"password": string,
|
"password": string,
|
||||||
"uid": integer,
|
"uid": integer,
|
||||||
"gid": integer,
|
"gid": integer,
|
||||||
"comment": string,
|
"comment": string,
|
||||||
"home": string,
|
"home": string,
|
||||||
"shell": string
|
"shell": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat /etc/passwd | jc --passwd -p
|
|
||||||
[
|
$ cat /etc/passwd | jc --passwd -p
|
||||||
{
|
[
|
||||||
"username": "nobody",
|
{
|
||||||
"password": "*",
|
- `"username"` - "nobody",
|
||||||
"uid": -2,
|
- `"password"` - "*",
|
||||||
"gid": -2,
|
- `"uid"` - -2,
|
||||||
"comment": "Unprivileged User",
|
- `"gid"` - -2,
|
||||||
"home": "/var/empty",
|
- `"comment"` - "Unprivileged User",
|
||||||
"shell": "/usr/bin/false"
|
- `"home"` - "/var/empty",
|
||||||
},
|
- `"shell"` - "/usr/bin/false"
|
||||||
{
|
},
|
||||||
"username": "root",
|
{
|
||||||
"password": "*",
|
- `"username"` - "root",
|
||||||
"uid": 0,
|
- `"password"` - "*",
|
||||||
"gid": 0,
|
- `"uid"` - 0,
|
||||||
"comment": "System Administrator",
|
- `"gid"` - 0,
|
||||||
"home": "/var/root",
|
- `"comment"` - "System Administrator",
|
||||||
"shell": "/bin/sh"
|
- `"home"` - "/var/root",
|
||||||
},
|
- `"shell"` - "/bin/sh"
|
||||||
{
|
},
|
||||||
"username": "daemon",
|
{
|
||||||
"password": "*",
|
- `"username"` - "daemon",
|
||||||
"uid": 1,
|
- `"password"` - "*",
|
||||||
"gid": 1,
|
- `"uid"` - 1,
|
||||||
"comment": "System Services",
|
- `"gid"` - 1,
|
||||||
"home": "/var/root",
|
- `"comment"` - "System Services",
|
||||||
"shell": "/usr/bin/false"
|
- `"home"` - "/var/root",
|
||||||
},
|
- `"shell"` - "/usr/bin/false"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ cat /etc/passwd | jc --passwd -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"username"` - "nobody",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"uid"` - "-2",
|
||||||
|
- `"gid"` - "-2",
|
||||||
|
- `"comment"` - "Unprivileged User",
|
||||||
|
- `"home"` - "/var/empty",
|
||||||
|
- `"shell"` - "/usr/bin/false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"username"` - "root",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"uid"` - "0",
|
||||||
|
- `"gid"` - "0",
|
||||||
|
- `"comment"` - "System Administrator",
|
||||||
|
- `"home"` - "/var/root",
|
||||||
|
- `"shell"` - "/bin/sh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"username"` - "daemon",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"uid"` - "1",
|
||||||
|
- `"gid"` - "1",
|
||||||
|
- `"comment"` - "System Services",
|
||||||
|
- `"home"` - "/var/root",
|
||||||
|
- `"shell"` - "/usr/bin/false"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ cat /etc/passwd | jc --passwd -p -r
|
<a id="jc.parsers.passwd.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"username": "nobody",
|
|
||||||
"password": "*",
|
|
||||||
"uid": "-2",
|
|
||||||
"gid": "-2",
|
|
||||||
"comment": "Unprivileged User",
|
|
||||||
"home": "/var/empty",
|
|
||||||
"shell": "/usr/bin/false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username": "root",
|
|
||||||
"password": "*",
|
|
||||||
"uid": "0",
|
|
||||||
"gid": "0",
|
|
||||||
"comment": "System Administrator",
|
|
||||||
"home": "/var/root",
|
|
||||||
"shell": "/bin/sh"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username": "daemon",
|
|
||||||
"password": "*",
|
|
||||||
"uid": "1",
|
|
||||||
"gid": "1",
|
|
||||||
"comment": "System Services",
|
|
||||||
"home": "/var/root",
|
|
||||||
"shell": "/usr/bin/false"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.passwd.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,193 +1,205 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ping"></a>
|
||||||
|
|
||||||
# jc.parsers.ping
|
# jc.parsers.ping
|
||||||
|
|
||||||
jc - JSON CLI output utility `ping` command output parser
|
jc - JSON CLI output utility `ping` command output parser
|
||||||
|
|
||||||
Supports `ping` and `ping6` output.
|
Supports `ping` and `ping6` output.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
Note: Use the ping `-c` (count) option, otherwise data will not be
|
Note: Use the ping `-c` (count) option, otherwise data will not be
|
||||||
piped to `jc`.
|
piped to `jc`.
|
||||||
|
|
||||||
$ ping -c 3 1.2.3.4 | jc --ping
|
$ ping -c 3 1.2.3.4 | jc --ping
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ping -c 3 1.2.3.4
|
$ jc ping -c 3 1.2.3.4
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ping', ping_command_output)
|
result = jc.parse('ping', ping_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ping
|
import jc.parsers.ping
|
||||||
result = jc.parsers.ping.parse(ping_command_output)
|
result = jc.parsers.ping.parse(ping_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"source_ip": string,
|
"source_ip": string,
|
||||||
"destination_ip": string,
|
"destination_ip": string,
|
||||||
"data_bytes": integer,
|
"data_bytes": integer,
|
||||||
"pattern": string, # null if not set
|
"pattern": string, # null if not set
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"packets_transmitted": integer,
|
"packets_transmitted": integer,
|
||||||
"packets_received": integer,
|
"packets_received": integer,
|
||||||
"packet_loss_percent": float,
|
"packet_loss_percent": float,
|
||||||
"duplicates": integer,
|
"duplicates": integer,
|
||||||
"round_trip_ms_min": float,
|
"round_trip_ms_min": float,
|
||||||
"round_trip_ms_avg": float,
|
"round_trip_ms_avg": float,
|
||||||
"round_trip_ms_max": float,
|
"round_trip_ms_max": float,
|
||||||
"round_trip_ms_stddev": float,
|
"round_trip_ms_stddev": float,
|
||||||
"responses": [
|
"responses": [
|
||||||
{
|
{
|
||||||
"type": string, # [0]
|
"type": string, # [0]
|
||||||
"unparsed_line": string, # [1]
|
"unparsed_line": string, # [1]
|
||||||
"timestamp": float,
|
"timestamp": float,
|
||||||
"bytes": integer,
|
"bytes": integer,
|
||||||
"response_ip": string,
|
"response_ip": string,
|
||||||
"icmp_seq": integer,
|
"icmp_seq": integer,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"time_ms": float,
|
"time_ms": float,
|
||||||
"duplicate": boolean,
|
"duplicate": boolean,
|
||||||
"vr": integer, # [2]
|
"vr": integer, # [2]
|
||||||
"hl": integer, # [2]
|
"hl": integer, # [2]
|
||||||
"tos": integer, # [2]
|
"tos": integer, # [2]
|
||||||
"len": integer, # [2]
|
"len": integer, # [2]
|
||||||
"id": integer, # [2]
|
"id": integer, # [2]
|
||||||
"flg": integer, # [2]
|
"flg": integer, # [2]
|
||||||
"off": integer, # [2]
|
"off": integer, # [2]
|
||||||
"pro": integer, # [2]
|
"pro": integer, # [2]
|
||||||
"cks": ingeger, # [2]
|
"cks": ingeger, # [2]
|
||||||
"src": string,
|
"src": string,
|
||||||
"dst": string
|
"dst": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] 'reply', 'timeout', 'unparsable_line', etc. See
|
[0] 'reply', 'timeout', 'unparsable_line', etc. See
|
||||||
`_error_type.type_map` for all options
|
`_error_type.type_map` for all options
|
||||||
[1] only if an 'unparsable_line' type
|
[1] only if an 'unparsable_line' type
|
||||||
[2] hex value converted to decimal
|
[2] hex value converted to decimal
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ping -c 3 -p ff cnn.com | jc --ping -p
|
|
||||||
{
|
$ ping -c 3 -p ff cnn.com | jc --ping -p
|
||||||
"destination_ip": "151.101.1.67",
|
{
|
||||||
"data_bytes": 56,
|
- `"destination_ip"` - "151.101.1.67",
|
||||||
"pattern": "0xff",
|
- `"data_bytes"` - 56,
|
||||||
"destination": "cnn.com",
|
- `"pattern"` - "0xff",
|
||||||
"packets_transmitted": 3,
|
- `"destination"` - "cnn.com",
|
||||||
"packets_received": 3,
|
- `"packets_transmitted"` - 3,
|
||||||
"packet_loss_percent": 0.0,
|
- `"packets_received"` - 3,
|
||||||
"duplicates": 0,
|
- `"packet_loss_percent"` - 0.0,
|
||||||
"round_trip_ms_min": 28.015,
|
- `"duplicates"` - 0,
|
||||||
"round_trip_ms_avg": 32.848,
|
- `"round_trip_ms_min"` - 28.015,
|
||||||
"round_trip_ms_max": 39.376,
|
- `"round_trip_ms_avg"` - 32.848,
|
||||||
"round_trip_ms_stddev": 4.79,
|
- `"round_trip_ms_max"` - 39.376,
|
||||||
"responses": [
|
- `"round_trip_ms_stddev"` - 4.79,
|
||||||
{
|
- `"responses"` - [
|
||||||
"type": "reply",
|
{
|
||||||
"bytes": 64,
|
- `"type"` - "reply",
|
||||||
"response_ip": "151.101.1.67",
|
- `"bytes"` - 64,
|
||||||
"icmp_seq": 0,
|
- `"response_ip"` - "151.101.1.67",
|
||||||
"ttl": 59,
|
- `"icmp_seq"` - 0,
|
||||||
"time_ms": 28.015,
|
- `"ttl"` - 59,
|
||||||
"duplicate": false
|
- `"time_ms"` - 28.015,
|
||||||
},
|
- `"duplicate"` - false
|
||||||
{
|
},
|
||||||
"type": "reply",
|
{
|
||||||
"bytes": 64,
|
- `"type"` - "reply",
|
||||||
"response_ip": "151.101.1.67",
|
- `"bytes"` - 64,
|
||||||
"icmp_seq": 1,
|
- `"response_ip"` - "151.101.1.67",
|
||||||
"ttl": 59,
|
- `"icmp_seq"` - 1,
|
||||||
"time_ms": 39.376,
|
- `"ttl"` - 59,
|
||||||
"duplicate": false
|
- `"time_ms"` - 39.376,
|
||||||
},
|
- `"duplicate"` - false
|
||||||
{
|
},
|
||||||
"type": "reply",
|
{
|
||||||
"bytes": 64,
|
- `"type"` - "reply",
|
||||||
"response_ip": "151.101.1.67",
|
- `"bytes"` - 64,
|
||||||
"icmp_seq": 2,
|
- `"response_ip"` - "151.101.1.67",
|
||||||
"ttl": 59,
|
- `"icmp_seq"` - 2,
|
||||||
"time_ms": 31.153,
|
- `"ttl"` - 59,
|
||||||
"duplicate": false
|
- `"time_ms"` - 31.153,
|
||||||
}
|
- `"duplicate"` - false
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
|
||||||
|
{
|
||||||
|
- `"destination_ip"` - "151.101.129.67",
|
||||||
|
- `"data_bytes"` - "56",
|
||||||
|
- `"pattern"` - "0xff",
|
||||||
|
- `"destination"` - "cnn.com",
|
||||||
|
- `"packets_transmitted"` - "3",
|
||||||
|
- `"packets_received"` - "3",
|
||||||
|
- `"packet_loss_percent"` - "0.0",
|
||||||
|
- `"duplicates"` - "0",
|
||||||
|
- `"round_trip_ms_min"` - "25.078",
|
||||||
|
- `"round_trip_ms_avg"` - "29.543",
|
||||||
|
- `"round_trip_ms_max"` - "32.553",
|
||||||
|
- `"round_trip_ms_stddev"` - "3.221",
|
||||||
|
- `"responses"` - [
|
||||||
|
{
|
||||||
|
- `"type"` - "reply",
|
||||||
|
- `"bytes"` - "64",
|
||||||
|
- `"response_ip"` - "151.101.129.67",
|
||||||
|
- `"icmp_seq"` - "0",
|
||||||
|
- `"ttl"` - "59",
|
||||||
|
- `"time_ms"` - "25.078",
|
||||||
|
- `"duplicate"` - false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "reply",
|
||||||
|
- `"bytes"` - "64",
|
||||||
|
- `"response_ip"` - "151.101.129.67",
|
||||||
|
- `"icmp_seq"` - "1",
|
||||||
|
- `"ttl"` - "59",
|
||||||
|
- `"time_ms"` - "30.999",
|
||||||
|
- `"duplicate"` - false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"type"` - "reply",
|
||||||
|
- `"bytes"` - "64",
|
||||||
|
- `"response_ip"` - "151.101.129.67",
|
||||||
|
- `"icmp_seq"` - "2",
|
||||||
|
- `"ttl"` - "59",
|
||||||
|
- `"time_ms"` - "32.553",
|
||||||
|
- `"duplicate"` - false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
|
<a id="jc.parsers.ping.info"></a>
|
||||||
{
|
|
||||||
"destination_ip": "151.101.129.67",
|
|
||||||
"data_bytes": "56",
|
|
||||||
"pattern": "0xff",
|
|
||||||
"destination": "cnn.com",
|
|
||||||
"packets_transmitted": "3",
|
|
||||||
"packets_received": "3",
|
|
||||||
"packet_loss_percent": "0.0",
|
|
||||||
"duplicates": "0",
|
|
||||||
"round_trip_ms_min": "25.078",
|
|
||||||
"round_trip_ms_avg": "29.543",
|
|
||||||
"round_trip_ms_max": "32.553",
|
|
||||||
"round_trip_ms_stddev": "3.221",
|
|
||||||
"responses": [
|
|
||||||
{
|
|
||||||
"type": "reply",
|
|
||||||
"bytes": "64",
|
|
||||||
"response_ip": "151.101.129.67",
|
|
||||||
"icmp_seq": "0",
|
|
||||||
"ttl": "59",
|
|
||||||
"time_ms": "25.078",
|
|
||||||
"duplicate": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "reply",
|
|
||||||
"bytes": "64",
|
|
||||||
"response_ip": "151.101.129.67",
|
|
||||||
"icmp_seq": "1",
|
|
||||||
"ttl": "59",
|
|
||||||
"time_ms": "30.999",
|
|
||||||
"duplicate": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "reply",
|
|
||||||
"bytes": "64",
|
|
||||||
"response_ip": "151.101.129.67",
|
|
||||||
"icmp_seq": "2",
|
|
||||||
"ttl": "59",
|
|
||||||
"time_ms": "32.553",
|
|
||||||
"duplicate": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ping.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ping_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.ping\_s
|
||||||
|
|
||||||
# jc.parsers.ping_s
|
|
||||||
jc - JSON CLI output utility `ping` command output streaming parser
|
jc - JSON CLI output utility `ping` command output streaming parser
|
||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
@ -9,113 +11,125 @@ Supports `ping` and `ping6` output.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ping | jc --ping-s
|
$ ping | jc --ping-s
|
||||||
|
|
||||||
> Note: When piping `jc` converted `ping` output to other processes it may
|
> Note: When piping `jc` converted `ping` output to other processes it may
|
||||||
appear the output is hanging due to the OS pipe buffers. This is because
|
appear the output is hanging due to the OS pipe buffers. This is because
|
||||||
`ping` output is too small to quickly fill up the buffer. Use the `-u`
|
`ping` output is too small to quickly fill up the buffer. Use the `-u`
|
||||||
option to unbuffer the `jc` output if you would like immediate output.
|
option to unbuffer the `jc` output if you would like immediate output.
|
||||||
See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parse('ping_s', ping_command_output.splitlines())
|
result = jc.parse('ping_s', ping_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ping_s
|
import jc.parsers.ping_s
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parsers.ping_s.parse(ping_command_output.splitlines())
|
result = jc.parsers.ping_s.parse(ping_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": string, # [0]
|
"type": string, # [0]
|
||||||
"source_ip": string,
|
"source_ip": string,
|
||||||
"destination_ip": string,
|
"destination_ip": string,
|
||||||
"sent_bytes": integer,
|
"sent_bytes": integer,
|
||||||
"pattern": string, # (null if not set)
|
"pattern": string, # (null if not set)
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"timestamp": float,
|
"timestamp": float,
|
||||||
"response_bytes": integer,
|
"response_bytes": integer,
|
||||||
"response_ip": string,
|
"response_ip": string,
|
||||||
"icmp_seq": integer,
|
"icmp_seq": integer,
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"time_ms": float,
|
"time_ms": float,
|
||||||
"duplicate": boolean,
|
"duplicate": boolean,
|
||||||
"packets_transmitted": integer,
|
"packets_transmitted": integer,
|
||||||
"packets_received": integer,
|
"packets_received": integer,
|
||||||
"packet_loss_percent": float,
|
"packet_loss_percent": float,
|
||||||
"duplicates": integer,
|
"duplicates": integer,
|
||||||
"round_trip_ms_min": float,
|
"round_trip_ms_min": float,
|
||||||
"round_trip_ms_avg": float,
|
"round_trip_ms_avg": float,
|
||||||
"round_trip_ms_max": float,
|
"round_trip_ms_max": float,
|
||||||
"round_trip_ms_stddev": float,
|
"round_trip_ms_stddev": float,
|
||||||
|
|
||||||
# Below object only exists if using -qq or ignore_exceptions=True
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
"_jc_meta":
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # false if error parsing
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map`
|
[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map`
|
||||||
for all options.
|
for all options.
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ping 1.1.1.1 | jc --ping-s
|
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
$ ping 1.1.1.1 | jc --ping-s
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||||
...
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
|
||||||
|
...
|
||||||
|
|
||||||
|
$ ping 1.1.1.1 | jc --ping-s -r
|
||||||
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||||
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||||
|
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
||||||
|
...
|
||||||
|
|
||||||
$ ping 1.1.1.1 | jc --ping-s -r
|
<a id="jc.parsers.ping_s.info"></a>
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
|
||||||
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
|
|
||||||
...
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ping_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse
|
|
||||||
(e.g. sys.stdin or str.splitlines())
|
- `data` - (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
|
||||||
|
|
||||||
raw: (boolean) unprocessed output if True
|
**Yields**:
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
**Returns**:
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
Iterator object
|
||||||
Iterator object
|
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,78 +1,90 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.pip_list"></a>
|
||||||
|
|
||||||
|
# jc.parsers.pip\_list
|
||||||
|
|
||||||
# jc.parsers.pip_list
|
|
||||||
jc - JSON CLI output utility `pip-list` command output parser
|
jc - JSON CLI output utility `pip-list` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ pip list | jc --pip-list
|
$ pip list | jc --pip-list
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc pip list
|
$ jc pip list
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('pip_list', pip_list_command_output)
|
result = jc.parse('pip_list', pip_list_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.pip_list
|
import jc.parsers.pip_list
|
||||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"package": string,
|
"package": string,
|
||||||
"version": string,
|
"version": string,
|
||||||
"location": string
|
"location": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ pip list | jc --pip-list -p
|
|
||||||
[
|
$ pip list | jc --pip-list -p
|
||||||
{
|
[
|
||||||
"package": "ansible",
|
{
|
||||||
"version": "2.8.5"
|
- `"package"` - "ansible",
|
||||||
},
|
- `"version"` - "2.8.5"
|
||||||
{
|
},
|
||||||
"package": "antlr4-python3-runtime",
|
{
|
||||||
"version": "4.7.2"
|
- `"package"` - "antlr4-python3-runtime",
|
||||||
},
|
- `"version"` - "4.7.2"
|
||||||
{
|
},
|
||||||
"package": "asn1crypto",
|
{
|
||||||
"version": "0.24.0"
|
- `"package"` - "asn1crypto",
|
||||||
},
|
- `"version"` - "0.24.0"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.pip_list.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.pip_list.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,96 +1,108 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.pip_show"></a>
|
||||||
|
|
||||||
|
# jc.parsers.pip\_show
|
||||||
|
|
||||||
# jc.parsers.pip_show
|
|
||||||
jc - JSON CLI output utility `pip-show` command output parser
|
jc - JSON CLI output utility `pip-show` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ pip show | jc --pip-show
|
$ pip show | jc --pip-show
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc pip show
|
$ jc pip show
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('pip_show', pip_show_command_output)
|
result = jc.parse('pip_show', pip_show_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.pip_show
|
import jc.parsers.pip_show
|
||||||
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"version": string,
|
"version": string,
|
||||||
"summary": string,
|
"summary": string,
|
||||||
"home_page": string,
|
"home_page": string,
|
||||||
"author": string,
|
"author": string,
|
||||||
"author_email": string,
|
"author_email": string,
|
||||||
"license": string,
|
"license": string,
|
||||||
"location": string,
|
"location": string,
|
||||||
"requires": string,
|
"requires": string,
|
||||||
"required_by": string
|
"required_by": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ pip show wrapt jc wheel | jc --pip-show -p
|
|
||||||
[
|
$ pip show wrapt jc wheel | jc --pip-show -p
|
||||||
{
|
[
|
||||||
"name": "wrapt",
|
{
|
||||||
"version": "1.11.2",
|
- `"name"` - "wrapt",
|
||||||
"summary": "Module for decorators, wrappers and monkey patching.",
|
- `"version"` - "1.11.2",
|
||||||
"home_page": "https://github.com/GrahamDumpleton/wrapt",
|
- `"summary"` - "Module for decorators, wrappers and monkey patching.",
|
||||||
"author": "Graham Dumpleton",
|
- `"home_page"` - "https://github.com/GrahamDumpleton/wrapt",
|
||||||
"author_email": "Graham.Dumpleton@gmail.com",
|
- `"author"` - "Graham Dumpleton",
|
||||||
"license": "BSD",
|
- `"author_email"` - "Graham.Dumpleton@gmail.com",
|
||||||
"location": "/usr/local/lib/python3.7/site-packages",
|
- `"license"` - "BSD",
|
||||||
"requires": null,
|
- `"location"` - "/usr/local/lib/python3.7/site-packages",
|
||||||
"required_by": "astroid"
|
- `"requires"` - null,
|
||||||
},
|
- `"required_by"` - "astroid"
|
||||||
{
|
},
|
||||||
"name": "wheel",
|
{
|
||||||
"version": "0.33.4",
|
- `"name"` - "wheel",
|
||||||
"summary": "A built-package format for Python.",
|
- `"version"` - "0.33.4",
|
||||||
"home_page": "https://github.com/pypa/wheel",
|
- `"summary"` - "A built-package format for Python.",
|
||||||
"author": "Daniel Holth",
|
- `"home_page"` - "https://github.com/pypa/wheel",
|
||||||
"author_email": "dholth@fastmail.fm",
|
- `"author"` - "Daniel Holth",
|
||||||
"license": "MIT",
|
- `"author_email"` - "dholth@fastmail.fm",
|
||||||
"location": "/usr/local/lib/python3.7/site-packages",
|
- `"license"` - "MIT",
|
||||||
"requires": null,
|
- `"location"` - "/usr/local/lib/python3.7/site-packages",
|
||||||
"required_by": null
|
- `"requires"` - null,
|
||||||
}
|
- `"required_by"` - null
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.pip_show.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.pip_show.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ps"></a>
|
||||||
|
|
||||||
# jc.parsers.ps
|
# jc.parsers.ps
|
||||||
|
|
||||||
jc - JSON CLI output utility `ps` command output parser
|
jc - JSON CLI output utility `ps` command output parser
|
||||||
|
|
||||||
`ps` options supported:
|
`ps` options supported:
|
||||||
@ -9,229 +11,239 @@ jc - JSON CLI output utility `ps` command output parser
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ps | jc --ps
|
$ ps | jc --ps
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ps
|
$ jc ps
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ps', ps_command_output)
|
result = jc.parse('ps', ps_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ps
|
import jc.parsers.ps
|
||||||
result = jc.parsers.ps.parse(ps_command_output)
|
result = jc.parsers.ps.parse(ps_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"uid": string,
|
"uid": string,
|
||||||
"pid": integer,
|
"pid": integer,
|
||||||
"ppid": integer,
|
"ppid": integer,
|
||||||
"c": integer,
|
"c": integer,
|
||||||
"stime": string,
|
"stime": string,
|
||||||
"tty": string, # ? or ?? = Null
|
"tty": string, # ? or ?? = Null
|
||||||
"tt": string, # ?? = Null
|
"tt": string, # ?? = Null
|
||||||
"time": string,
|
"time": string,
|
||||||
"cmd": string,
|
"cmd": string,
|
||||||
"user": string,
|
"user": string,
|
||||||
"cpu_percent": float,
|
"cpu_percent": float,
|
||||||
"mem_percent": float,
|
"mem_percent": float,
|
||||||
"vsz": integer,
|
"vsz": integer,
|
||||||
"rss": integer,
|
"rss": integer,
|
||||||
"stat": string,
|
"stat": string,
|
||||||
"start": string,
|
"start": string,
|
||||||
"command": string
|
"command": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ps -ef | jc --ps -p
|
|
||||||
[
|
$ ps -ef | jc --ps -p
|
||||||
{
|
[
|
||||||
"uid": "root",
|
{
|
||||||
"pid": 1,
|
- `"uid"` - "root",
|
||||||
"ppid": 0,
|
- `"pid"` - 1,
|
||||||
"c": 0,
|
- `"ppid"` - 0,
|
||||||
"stime": "Nov01",
|
- `"c"` - 0,
|
||||||
"tty": null,
|
- `"stime"` - "Nov01",
|
||||||
"time": "00:00:11",
|
- `"tty"` - null,
|
||||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
- `"time"` - "00:00:11",
|
||||||
},
|
- `"cmd"` - "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
||||||
{
|
},
|
||||||
"uid": "root",
|
{
|
||||||
"pid": 2,
|
- `"uid"` - "root",
|
||||||
"ppid": 0,
|
- `"pid"` - 2,
|
||||||
"c": 0,
|
- `"ppid"` - 0,
|
||||||
"stime": "Nov01",
|
- `"c"` - 0,
|
||||||
"tty": null,
|
- `"stime"` - "Nov01",
|
||||||
"time": "00:00:00",
|
- `"tty"` - null,
|
||||||
"cmd": "[kthreadd]"
|
- `"time"` - "00:00:00",
|
||||||
},
|
- `"cmd"` - "[kthreadd]"
|
||||||
{
|
},
|
||||||
"uid": "root",
|
{
|
||||||
"pid": 4,
|
- `"uid"` - "root",
|
||||||
"ppid": 2,
|
- `"pid"` - 4,
|
||||||
"c": 0,
|
- `"ppid"` - 2,
|
||||||
"stime": "Nov01",
|
- `"c"` - 0,
|
||||||
"tty": null,
|
- `"stime"` - "Nov01",
|
||||||
"time": "00:00:00",
|
- `"tty"` - null,
|
||||||
"cmd": "[kworker/0:0H]"
|
- `"time"` - "00:00:00",
|
||||||
},
|
- `"cmd"` - "[kworker/0:0H]"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ps -ef | jc --ps -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"uid"` - "root",
|
||||||
|
- `"pid"` - "1",
|
||||||
|
- `"ppid"` - "0",
|
||||||
|
- `"c"` - "0",
|
||||||
|
- `"stime"` - "Nov01",
|
||||||
|
- `"tty"` - "?",
|
||||||
|
- `"time"` - "00:00:11",
|
||||||
|
- `"cmd"` - "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"uid"` - "root",
|
||||||
|
- `"pid"` - "2",
|
||||||
|
- `"ppid"` - "0",
|
||||||
|
- `"c"` - "0",
|
||||||
|
- `"stime"` - "Nov01",
|
||||||
|
- `"tty"` - "?",
|
||||||
|
- `"time"` - "00:00:00",
|
||||||
|
- `"cmd"` - "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"uid"` - "root",
|
||||||
|
- `"pid"` - "4",
|
||||||
|
- `"ppid"` - "2",
|
||||||
|
- `"c"` - "0",
|
||||||
|
- `"stime"` - "Nov01",
|
||||||
|
- `"tty"` - "?",
|
||||||
|
- `"time"` - "00:00:00",
|
||||||
|
- `"cmd"` - "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ps axu | jc --ps -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"pid"` - 1,
|
||||||
|
- `"cpu_percent"` - 0.0,
|
||||||
|
- `"mem_percent"` - 0.1,
|
||||||
|
- `"vsz"` - 128072,
|
||||||
|
- `"rss"` - 6784,
|
||||||
|
- `"tty"` - null,
|
||||||
|
- `"stat"` - "Ss",
|
||||||
|
- `"start"` - "Nov09",
|
||||||
|
- `"time"` - "0:08",
|
||||||
|
- `"command"` - "/usr/lib/systemd/systemd --switched-root --system --..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"pid"` - 2,
|
||||||
|
- `"cpu_percent"` - 0.0,
|
||||||
|
- `"mem_percent"` - 0.0,
|
||||||
|
- `"vsz"` - 0,
|
||||||
|
- `"rss"` - 0,
|
||||||
|
- `"tty"` - null,
|
||||||
|
- `"stat"` - "S",
|
||||||
|
- `"start"` - "Nov09",
|
||||||
|
- `"time"` - "0:00",
|
||||||
|
- `"command"` - "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"pid"` - 4,
|
||||||
|
- `"cpu_percent"` - 0.0,
|
||||||
|
- `"mem_percent"` - 0.0,
|
||||||
|
- `"vsz"` - 0,
|
||||||
|
- `"rss"` - 0,
|
||||||
|
- `"tty"` - null,
|
||||||
|
- `"stat"` - "S<",
|
||||||
|
- `"start"` - "Nov09",
|
||||||
|
- `"time"` - "0:00",
|
||||||
|
- `"command"` - "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ps axu | jc --ps -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"pid"` - "1",
|
||||||
|
- `"cpu_percent"` - "0.0",
|
||||||
|
- `"mem_percent"` - "0.1",
|
||||||
|
- `"vsz"` - "128072",
|
||||||
|
- `"rss"` - "6784",
|
||||||
|
- `"tty"` - "?",
|
||||||
|
- `"stat"` - "Ss",
|
||||||
|
- `"start"` - "Nov09",
|
||||||
|
- `"time"` - "0:08",
|
||||||
|
- `"command"` - "/usr/lib/systemd/systemd --switched-root --system --..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"pid"` - "2",
|
||||||
|
- `"cpu_percent"` - "0.0",
|
||||||
|
- `"mem_percent"` - "0.0",
|
||||||
|
- `"vsz"` - "0",
|
||||||
|
- `"rss"` - "0",
|
||||||
|
- `"tty"` - "?",
|
||||||
|
- `"stat"` - "S",
|
||||||
|
- `"start"` - "Nov09",
|
||||||
|
- `"time"` - "0:00",
|
||||||
|
- `"command"` - "[kthreadd]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"pid"` - "4",
|
||||||
|
- `"cpu_percent"` - "0.0",
|
||||||
|
- `"mem_percent"` - "0.0",
|
||||||
|
- `"vsz"` - "0",
|
||||||
|
- `"rss"` - "0",
|
||||||
|
- `"tty"` - "?",
|
||||||
|
- `"stat"` - "S<",
|
||||||
|
- `"start"` - "Nov09",
|
||||||
|
- `"time"` - "0:00",
|
||||||
|
- `"command"` - "[kworker/0:0H]"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ ps -ef | jc --ps -p -r
|
<a id="jc.parsers.ps.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"uid": "root",
|
|
||||||
"pid": "1",
|
|
||||||
"ppid": "0",
|
|
||||||
"c": "0",
|
|
||||||
"stime": "Nov01",
|
|
||||||
"tty": "?",
|
|
||||||
"time": "00:00:11",
|
|
||||||
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uid": "root",
|
|
||||||
"pid": "2",
|
|
||||||
"ppid": "0",
|
|
||||||
"c": "0",
|
|
||||||
"stime": "Nov01",
|
|
||||||
"tty": "?",
|
|
||||||
"time": "00:00:00",
|
|
||||||
"cmd": "[kthreadd]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uid": "root",
|
|
||||||
"pid": "4",
|
|
||||||
"ppid": "2",
|
|
||||||
"c": "0",
|
|
||||||
"stime": "Nov01",
|
|
||||||
"tty": "?",
|
|
||||||
"time": "00:00:00",
|
|
||||||
"cmd": "[kworker/0:0H]"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
$ ps axu | jc --ps -p
|
## info Objects
|
||||||
[
|
|
||||||
{
|
|
||||||
"user": "root",
|
|
||||||
"pid": 1,
|
|
||||||
"cpu_percent": 0.0,
|
|
||||||
"mem_percent": 0.1,
|
|
||||||
"vsz": 128072,
|
|
||||||
"rss": 6784,
|
|
||||||
"tty": null,
|
|
||||||
"stat": "Ss",
|
|
||||||
"start": "Nov09",
|
|
||||||
"time": "0:08",
|
|
||||||
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "root",
|
|
||||||
"pid": 2,
|
|
||||||
"cpu_percent": 0.0,
|
|
||||||
"mem_percent": 0.0,
|
|
||||||
"vsz": 0,
|
|
||||||
"rss": 0,
|
|
||||||
"tty": null,
|
|
||||||
"stat": "S",
|
|
||||||
"start": "Nov09",
|
|
||||||
"time": "0:00",
|
|
||||||
"command": "[kthreadd]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "root",
|
|
||||||
"pid": 4,
|
|
||||||
"cpu_percent": 0.0,
|
|
||||||
"mem_percent": 0.0,
|
|
||||||
"vsz": 0,
|
|
||||||
"rss": 0,
|
|
||||||
"tty": null,
|
|
||||||
"stat": "S<",
|
|
||||||
"start": "Nov09",
|
|
||||||
"time": "0:00",
|
|
||||||
"command": "[kworker/0:0H]"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
$ ps axu | jc --ps -p -r
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"user": "root",
|
|
||||||
"pid": "1",
|
|
||||||
"cpu_percent": "0.0",
|
|
||||||
"mem_percent": "0.1",
|
|
||||||
"vsz": "128072",
|
|
||||||
"rss": "6784",
|
|
||||||
"tty": "?",
|
|
||||||
"stat": "Ss",
|
|
||||||
"start": "Nov09",
|
|
||||||
"time": "0:08",
|
|
||||||
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "root",
|
|
||||||
"pid": "2",
|
|
||||||
"cpu_percent": "0.0",
|
|
||||||
"mem_percent": "0.0",
|
|
||||||
"vsz": "0",
|
|
||||||
"rss": "0",
|
|
||||||
"tty": "?",
|
|
||||||
"stat": "S",
|
|
||||||
"start": "Nov09",
|
|
||||||
"time": "0:00",
|
|
||||||
"command": "[kthreadd]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "root",
|
|
||||||
"pid": "4",
|
|
||||||
"cpu_percent": "0.0",
|
|
||||||
"mem_percent": "0.0",
|
|
||||||
"vsz": "0",
|
|
||||||
"rss": "0",
|
|
||||||
"tty": "?",
|
|
||||||
"stat": "S<",
|
|
||||||
"start": "Nov09",
|
|
||||||
"time": "0:00",
|
|
||||||
"command": "[kworker/0:0H]"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ps.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,139 +1,151 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.route"></a>
|
||||||
|
|
||||||
# jc.parsers.route
|
# jc.parsers.route
|
||||||
|
|
||||||
jc - JSON CLI output utility `route` command output parser
|
jc - JSON CLI output utility `route` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ route | jc --route
|
$ route | jc --route
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc route
|
$ jc route
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('route', route_command_output)
|
result = jc.parse('route', route_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.route
|
import jc.parsers.route
|
||||||
result = jc.parsers.route.parse(route_command_output)
|
result = jc.parsers.route.parse(route_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"destination": string,
|
"destination": string,
|
||||||
"gateway": string,
|
"gateway": string,
|
||||||
"genmask": string,
|
"genmask": string,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"flags_pretty": [
|
"flags_pretty": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
"metric": integer,
|
"metric": integer,
|
||||||
"ref": integer,
|
"ref": integer,
|
||||||
"use": integer,
|
"use": integer,
|
||||||
"mss": integer,
|
"mss": integer,
|
||||||
"window": integer,
|
"window": integer,
|
||||||
"irtt": integer,
|
"irtt": integer,
|
||||||
"iface": string
|
"iface": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ route -ee | jc --route -p
|
|
||||||
[
|
$ route -ee | jc --route -p
|
||||||
{
|
[
|
||||||
"destination": "default",
|
{
|
||||||
"gateway": "_gateway",
|
- `"destination"` - "default",
|
||||||
"genmask": "0.0.0.0",
|
- `"gateway"` - "_gateway",
|
||||||
"flags": "UG",
|
- `"genmask"` - "0.0.0.0",
|
||||||
"metric": 202,
|
- `"flags"` - "UG",
|
||||||
"ref": 0,
|
- `"metric"` - 202,
|
||||||
"use": 0,
|
- `"ref"` - 0,
|
||||||
"iface": "ens33",
|
- `"use"` - 0,
|
||||||
"mss": 0,
|
- `"iface"` - "ens33",
|
||||||
"window": 0,
|
- `"mss"` - 0,
|
||||||
"irtt": 0,
|
- `"window"` - 0,
|
||||||
"flags_pretty": [
|
- `"irtt"` - 0,
|
||||||
"UP",
|
- `"flags_pretty"` - [
|
||||||
"GATEWAY"
|
"UP",
|
||||||
]
|
"GATEWAY"
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"destination": "192.168.71.0",
|
{
|
||||||
"gateway": "0.0.0.0",
|
- `"destination"` - "192.168.71.0",
|
||||||
"genmask": "255.255.255.0",
|
- `"gateway"` - "0.0.0.0",
|
||||||
"flags": "U",
|
- `"genmask"` - "255.255.255.0",
|
||||||
"metric": 202,
|
- `"flags"` - "U",
|
||||||
"ref": 0,
|
- `"metric"` - 202,
|
||||||
"use": 0,
|
- `"ref"` - 0,
|
||||||
"iface": "ens33",
|
- `"use"` - 0,
|
||||||
"mss": 0,
|
- `"iface"` - "ens33",
|
||||||
"window": 0,
|
- `"mss"` - 0,
|
||||||
"irtt": 0,
|
- `"window"` - 0,
|
||||||
"flags_pretty": [
|
- `"irtt"` - 0,
|
||||||
"UP"
|
- `"flags_pretty"` - [
|
||||||
]
|
"UP"
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ route -ee | jc --route -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"destination"` - "default",
|
||||||
|
- `"gateway"` - "_gateway",
|
||||||
|
- `"genmask"` - "0.0.0.0",
|
||||||
|
- `"flags"` - "UG",
|
||||||
|
- `"metric"` - "202",
|
||||||
|
- `"ref"` - "0",
|
||||||
|
- `"use"` - "0",
|
||||||
|
- `"iface"` - "ens33",
|
||||||
|
- `"mss"` - "0",
|
||||||
|
- `"window"` - "0",
|
||||||
|
- `"irtt"` - "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"destination"` - "192.168.71.0",
|
||||||
|
- `"gateway"` - "0.0.0.0",
|
||||||
|
- `"genmask"` - "255.255.255.0",
|
||||||
|
- `"flags"` - "U",
|
||||||
|
- `"metric"` - "202",
|
||||||
|
- `"ref"` - "0",
|
||||||
|
- `"use"` - "0",
|
||||||
|
- `"iface"` - "ens33",
|
||||||
|
- `"mss"` - "0",
|
||||||
|
- `"window"` - "0",
|
||||||
|
- `"irtt"` - "0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ route -ee | jc --route -p -r
|
<a id="jc.parsers.route.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"destination": "default",
|
|
||||||
"gateway": "_gateway",
|
|
||||||
"genmask": "0.0.0.0",
|
|
||||||
"flags": "UG",
|
|
||||||
"metric": "202",
|
|
||||||
"ref": "0",
|
|
||||||
"use": "0",
|
|
||||||
"iface": "ens33",
|
|
||||||
"mss": "0",
|
|
||||||
"window": "0",
|
|
||||||
"irtt": "0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"destination": "192.168.71.0",
|
|
||||||
"gateway": "0.0.0.0",
|
|
||||||
"genmask": "255.255.255.0",
|
|
||||||
"flags": "U",
|
|
||||||
"metric": "202",
|
|
||||||
"ref": "0",
|
|
||||||
"use": "0",
|
|
||||||
"iface": "ens33",
|
|
||||||
"mss": "0",
|
|
||||||
"window": "0",
|
|
||||||
"irtt": "0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.route.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.rpm_qi"></a>
|
||||||
|
|
||||||
|
# jc.parsers.rpm\_qi
|
||||||
|
|
||||||
# jc.parsers.rpm_qi
|
|
||||||
jc - JSON CLI output utility `rpm -qi` command output parser
|
jc - JSON CLI output utility `rpm -qi` command output parser
|
||||||
|
|
||||||
Works with `rpm -qi [package]` or `rpm -qia`.
|
Works with `rpm -qi [package]` or `rpm -qia`.
|
||||||
@ -13,180 +15,190 @@ only available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ rpm -qia | jc --rpm-qi
|
$ rpm -qia | jc --rpm-qi
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc rpm -qia
|
$ jc rpm -qia
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('rpm_qi', rpm_qi_command_output)
|
result = jc.parse('rpm_qi', rpm_qi_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.rpm_qi
|
import jc.parsers.rpm_qi
|
||||||
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"epoch": integer,
|
"epoch": integer,
|
||||||
"version": string,
|
"version": string,
|
||||||
"release": string,
|
"release": string,
|
||||||
"architecture": string,
|
"architecture": string,
|
||||||
"install_date": string,
|
"install_date": string,
|
||||||
"install_date_epoch": integer, # [0]
|
"install_date_epoch": integer, # [0]
|
||||||
"install_date_epoch_utc": integer, # [1]
|
"install_date_epoch_utc": integer, # [1]
|
||||||
"group": string,
|
"group": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"license": string,
|
"license": string,
|
||||||
"signature": string,
|
"signature": string,
|
||||||
"source_rpm": string,
|
"source_rpm": string,
|
||||||
"build_date": string,
|
"build_date": string,
|
||||||
"build_epoch": integer, # [0]
|
"build_epoch": integer, # [0]
|
||||||
"build_epoch_utc": integer, # [1]
|
"build_epoch_utc": integer, # [1]
|
||||||
"build_host": string,
|
"build_host": string,
|
||||||
"relocations": string,
|
"relocations": string,
|
||||||
"packager": string,
|
"packager": string,
|
||||||
"vendor": string,
|
"vendor": string,
|
||||||
"url": string,
|
"url": string,
|
||||||
"summary": string,
|
"summary": string,
|
||||||
"description": string
|
"description": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] naive timestamp
|
[0] naive timestamp
|
||||||
[1] Aware timestamp if timezone is UTC
|
[1] Aware timestamp if timezone is UTC
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ rpm -qia | jc --rpm-qi -p
|
|
||||||
[
|
$ rpm -qia | jc --rpm-qi -p
|
||||||
{
|
[
|
||||||
"name": "make",
|
{
|
||||||
"epoch": 1,
|
- `"name"` - "make",
|
||||||
"version": "3.82",
|
- `"epoch"` - 1,
|
||||||
"release": "24.el7",
|
- `"version"` - "3.82",
|
||||||
"architecture": "x86_64",
|
- `"release"` - "24.el7",
|
||||||
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
|
- `"architecture"` - "x86_64",
|
||||||
"group": "Development/Tools",
|
- `"install_date"` - "Wed 16 Oct 2019 09:21:42 AM PDT",
|
||||||
"size": 1160660,
|
- `"group"` - "Development/Tools",
|
||||||
"license": "GPLv2+",
|
- `"size"` - 1160660,
|
||||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
- `"license"` - "GPLv2+",
|
||||||
"source_rpm": "make-3.82-24.el7.src.rpm",
|
- `"signature"` - "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
||||||
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
- `"source_rpm"` - "make-3.82-24.el7.src.rpm",
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
- `"build_date"` - "Thu 08 Aug 2019 05:47:25 PM PDT",
|
||||||
"relocations": "(not relocatable)",
|
- `"build_host"` - "x86-01.bsys.centos.org",
|
||||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
- `"relocations"` - "(not relocatable)",
|
||||||
"vendor": "CentOS",
|
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
|
||||||
"url": "http://www.gnu.org/software/make/",
|
- `"vendor"` - "CentOS",
|
||||||
"summary": "A GNU tool which simplifies the build process for ...",
|
- `"url"` - "http://www.gnu.org/software/make/",
|
||||||
"description": "A GNU tool for controlling the generation of ex...",
|
- `"summary"` - "A GNU tool which simplifies the build process for ...",
|
||||||
"build_epoch": 1565311645,
|
- `"description"` - "A GNU tool for controlling the generation of ex...",
|
||||||
"build_epoch_utc": null,
|
- `"build_epoch"` - 1565311645,
|
||||||
"install_date_epoch": 1571242902,
|
- `"build_epoch_utc"` - null,
|
||||||
"install_date_epoch_utc": null
|
- `"install_date_epoch"` - 1571242902,
|
||||||
},
|
- `"install_date_epoch_utc"` - null
|
||||||
{
|
},
|
||||||
"name": "kbd-legacy",
|
{
|
||||||
"version": "1.15.5",
|
- `"name"` - "kbd-legacy",
|
||||||
"release": "15.el7",
|
- `"version"` - "1.15.5",
|
||||||
"architecture": "noarch",
|
- `"release"` - "15.el7",
|
||||||
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
|
- `"architecture"` - "noarch",
|
||||||
"group": "System Environment/Base",
|
- `"install_date"` - "Thu 15 Aug 2019 10:53:08 AM PDT",
|
||||||
"size": 503608,
|
- `"group"` - "System Environment/Base",
|
||||||
"license": "GPLv2+",
|
- `"size"` - 503608,
|
||||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
- `"license"` - "GPLv2+",
|
||||||
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
- `"signature"` - "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
||||||
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
- `"source_rpm"` - "kbd-1.15.5-15.el7.src.rpm",
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
- `"build_date"` - "Tue 30 Oct 2018 03:40:00 PM PDT",
|
||||||
"relocations": "(not relocatable)",
|
- `"build_host"` - "x86-01.bsys.centos.org",
|
||||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
- `"relocations"` - "(not relocatable)",
|
||||||
"vendor": "CentOS",
|
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
|
||||||
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
- `"vendor"` - "CentOS",
|
||||||
"summary": "Legacy data for kbd package",
|
- `"url"` - "http://ftp.altlinux.org/pub/people/legion/kbd",
|
||||||
"description": "The kbd-legacy package contains original keymap...",
|
- `"summary"` - "Legacy data for kbd package",
|
||||||
"build_epoch": 1540939200,
|
- `"description"` - "The kbd-legacy package contains original keymap...",
|
||||||
"build_epoch_utc": null,
|
- `"build_epoch"` - 1540939200,
|
||||||
"install_date_epoch": 1565891588,
|
- `"build_epoch_utc"` - null,
|
||||||
"install_date_epoch_utc": null
|
- `"install_date_epoch"` - 1565891588,
|
||||||
},
|
- `"install_date_epoch_utc"` - null
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ rpm -qia | jc --rpm-qi -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"name"` - "make",
|
||||||
|
- `"epoch"` - "1",
|
||||||
|
- `"version"` - "3.82",
|
||||||
|
- `"release"` - "24.el7",
|
||||||
|
- `"architecture"` - "x86_64",
|
||||||
|
- `"install_date"` - "Wed 16 Oct 2019 09:21:42 AM PDT",
|
||||||
|
- `"group"` - "Development/Tools",
|
||||||
|
- `"size"` - "1160660",
|
||||||
|
- `"license"` - "GPLv2+",
|
||||||
|
- `"signature"` - "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
||||||
|
- `"source_rpm"` - "make-3.82-24.el7.src.rpm",
|
||||||
|
- `"build_date"` - "Thu 08 Aug 2019 05:47:25 PM PDT",
|
||||||
|
- `"build_host"` - "x86-01.bsys.centos.org",
|
||||||
|
- `"relocations"` - "(not relocatable)",
|
||||||
|
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
|
||||||
|
- `"vendor"` - "CentOS",
|
||||||
|
- `"url"` - "http://www.gnu.org/software/make/",
|
||||||
|
- `"summary"` - "A GNU tool which simplifies the build process for...",
|
||||||
|
- `"description"` - "A GNU tool for controlling the generation of exe..."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"name"` - "kbd-legacy",
|
||||||
|
- `"version"` - "1.15.5",
|
||||||
|
- `"release"` - "15.el7",
|
||||||
|
- `"architecture"` - "noarch",
|
||||||
|
- `"install_date"` - "Thu 15 Aug 2019 10:53:08 AM PDT",
|
||||||
|
- `"group"` - "System Environment/Base",
|
||||||
|
- `"size"` - "503608",
|
||||||
|
- `"license"` - "GPLv2+",
|
||||||
|
- `"signature"` - "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
||||||
|
- `"source_rpm"` - "kbd-1.15.5-15.el7.src.rpm",
|
||||||
|
- `"build_date"` - "Tue 30 Oct 2018 03:40:00 PM PDT",
|
||||||
|
- `"build_host"` - "x86-01.bsys.centos.org",
|
||||||
|
- `"relocations"` - "(not relocatable)",
|
||||||
|
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
|
||||||
|
- `"vendor"` - "CentOS",
|
||||||
|
- `"url"` - "http://ftp.altlinux.org/pub/people/legion/kbd",
|
||||||
|
- `"summary"` - "Legacy data for kbd package",
|
||||||
|
- `"description"` - "The kbd-legacy package contains original keymaps..."
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ rpm -qia | jc --rpm-qi -p -r
|
<a id="jc.parsers.rpm_qi.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "make",
|
|
||||||
"epoch": "1",
|
|
||||||
"version": "3.82",
|
|
||||||
"release": "24.el7",
|
|
||||||
"architecture": "x86_64",
|
|
||||||
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
|
|
||||||
"group": "Development/Tools",
|
|
||||||
"size": "1160660",
|
|
||||||
"license": "GPLv2+",
|
|
||||||
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
|
|
||||||
"source_rpm": "make-3.82-24.el7.src.rpm",
|
|
||||||
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
|
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
|
||||||
"relocations": "(not relocatable)",
|
|
||||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
|
||||||
"vendor": "CentOS",
|
|
||||||
"url": "http://www.gnu.org/software/make/",
|
|
||||||
"summary": "A GNU tool which simplifies the build process for...",
|
|
||||||
"description": "A GNU tool for controlling the generation of exe..."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "kbd-legacy",
|
|
||||||
"version": "1.15.5",
|
|
||||||
"release": "15.el7",
|
|
||||||
"architecture": "noarch",
|
|
||||||
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
|
|
||||||
"group": "System Environment/Base",
|
|
||||||
"size": "503608",
|
|
||||||
"license": "GPLv2+",
|
|
||||||
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
|
|
||||||
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
|
|
||||||
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
|
|
||||||
"build_host": "x86-01.bsys.centos.org",
|
|
||||||
"relocations": "(not relocatable)",
|
|
||||||
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
|
|
||||||
"vendor": "CentOS",
|
|
||||||
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
|
|
||||||
"summary": "Legacy data for kbd package",
|
|
||||||
"description": "The kbd-legacy package contains original keymaps..."
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.rpm_qi.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.sfdisk"></a>
|
||||||
|
|
||||||
# jc.parsers.sfdisk
|
# jc.parsers.sfdisk
|
||||||
|
|
||||||
jc - JSON CLI output utility `sfdisk` command output parser
|
jc - JSON CLI output utility `sfdisk` command output parser
|
||||||
|
|
||||||
Supports the following `sfdisk` options:
|
Supports the following `sfdisk` options:
|
||||||
@ -14,220 +16,230 @@ Supports the following `sfdisk` options:
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
# sfdisk -l | jc --sfdisk
|
# sfdisk -l | jc --sfdisk
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
# jc sfdisk -l
|
# jc sfdisk -l
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('sfdisk', sfdisk_command_output)
|
result = jc.parse('sfdisk', sfdisk_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.sfdisk
|
import jc.parsers.sfdisk
|
||||||
result = jc.parsers.sfdisk.parse(sfdisk_command_output)
|
result = jc.parsers.sfdisk.parse(sfdisk_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"disk": string,
|
"disk": string,
|
||||||
"disk_size": string,
|
"disk_size": string,
|
||||||
"free_disk_size": string,
|
"free_disk_size": string,
|
||||||
"bytes": integer,
|
"bytes": integer,
|
||||||
"free_bytes": integer,
|
"free_bytes": integer,
|
||||||
"sectors": integer,
|
"sectors": integer,
|
||||||
"free_sectors": integer,
|
"free_sectors": integer,
|
||||||
"cylinders": integer,
|
"cylinders": integer,
|
||||||
"heads": integer,
|
"heads": integer,
|
||||||
"sectors_per_track": integer,
|
"sectors_per_track": integer,
|
||||||
"units": string,
|
"units": string,
|
||||||
"logical_sector_size": integer,
|
"logical_sector_size": integer,
|
||||||
"physical_sector_size": integer,
|
"physical_sector_size": integer,
|
||||||
"min_io_size": integer,
|
"min_io_size": integer,
|
||||||
"optimal_io_size": integer,
|
"optimal_io_size": integer,
|
||||||
"disk_label_type": string,
|
"disk_label_type": string,
|
||||||
"disk_identifier": string,
|
"disk_identifier": string,
|
||||||
"disk_model": string,
|
"disk_model": string,
|
||||||
"partitions": [
|
"partitions": [
|
||||||
{
|
{
|
||||||
"device": string,
|
"device": string,
|
||||||
"boot": boolean,
|
"boot": boolean,
|
||||||
"start": integer,
|
"start": integer,
|
||||||
"end": integer,
|
"end": integer,
|
||||||
"size": string, # [0]
|
"size": string, # [0]
|
||||||
"cyls": integer,
|
"cyls": integer,
|
||||||
"mib": integer,
|
"mib": integer,
|
||||||
"blocks": integer,
|
"blocks": integer,
|
||||||
"sectors": integer,
|
"sectors": integer,
|
||||||
"id": string,
|
"id": string,
|
||||||
"system": string,
|
"system": string,
|
||||||
"type": string
|
"type": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] will be integer when using deprecated -d sfdisk option
|
[0] will be integer when using deprecated -d sfdisk option
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
# sfdisk -l | jc --sfdisk -p
|
|
||||||
[
|
# sfdisk -l | jc --sfdisk -p
|
||||||
{
|
[
|
||||||
"disk": "/dev/sda",
|
{
|
||||||
"cylinders": 2610,
|
- `"disk"` - "/dev/sda",
|
||||||
"heads": 255,
|
- `"cylinders"` - 2610,
|
||||||
"sectors_per_track": 63,
|
- `"heads"` - 255,
|
||||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, ...",
|
- `"sectors_per_track"` - 63,
|
||||||
"partitions": [
|
- `"units"` - "cylinders of 8225280 bytes, blocks of 1024 bytes, ...",
|
||||||
{
|
- `"partitions"` - [
|
||||||
"device": "/dev/sda1",
|
{
|
||||||
"boot": true,
|
- `"device"` - "/dev/sda1",
|
||||||
"start": 0,
|
- `"boot"` - true,
|
||||||
"end": 130,
|
- `"start"` - 0,
|
||||||
"cyls": 131,
|
- `"end"` - 130,
|
||||||
"blocks": 1048576,
|
- `"cyls"` - 131,
|
||||||
"id": "83",
|
- `"blocks"` - 1048576,
|
||||||
"system": "Linux"
|
- `"id"` - "83",
|
||||||
},
|
- `"system"` - "Linux"
|
||||||
{
|
},
|
||||||
"device": "/dev/sda2",
|
{
|
||||||
"boot": false,
|
- `"device"` - "/dev/sda2",
|
||||||
"start": 130,
|
- `"boot"` - false,
|
||||||
"end": 2610,
|
- `"start"` - 130,
|
||||||
"cyls": 2481,
|
- `"end"` - 2610,
|
||||||
"blocks": 19921920,
|
- `"cyls"` - 2481,
|
||||||
"id": "8e",
|
- `"blocks"` - 19921920,
|
||||||
"system": "Linux LVM"
|
- `"id"` - "8e",
|
||||||
},
|
- `"system"` - "Linux LVM"
|
||||||
{
|
},
|
||||||
"device": "/dev/sda3",
|
{
|
||||||
"boot": false,
|
- `"device"` - "/dev/sda3",
|
||||||
"start": 0,
|
- `"boot"` - false,
|
||||||
"end": null,
|
- `"start"` - 0,
|
||||||
"cyls": 0,
|
- `"end"` - null,
|
||||||
"blocks": 0,
|
- `"cyls"` - 0,
|
||||||
"id": "0",
|
- `"blocks"` - 0,
|
||||||
"system": "Empty"
|
- `"id"` - "0",
|
||||||
},
|
- `"system"` - "Empty"
|
||||||
{
|
},
|
||||||
"device": "/dev/sda4",
|
{
|
||||||
"boot": false,
|
- `"device"` - "/dev/sda4",
|
||||||
"start": 0,
|
- `"boot"` - false,
|
||||||
"end": null,
|
- `"start"` - 0,
|
||||||
"cyls": 0,
|
- `"end"` - null,
|
||||||
"blocks": 0,
|
- `"cyls"` - 0,
|
||||||
"id": "0",
|
- `"blocks"` - 0,
|
||||||
"system": "Empty"
|
- `"id"` - "0",
|
||||||
}
|
- `"system"` - "Empty"
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
{
|
},
|
||||||
"disk": "/dev/mapper/centos-root",
|
{
|
||||||
"cylinders": 2218,
|
- `"disk"` - "/dev/mapper/centos-root",
|
||||||
"heads": 255,
|
- `"cylinders"` - 2218,
|
||||||
"sectors_per_track": 63
|
- `"heads"` - 255,
|
||||||
},
|
- `"sectors_per_track"` - 63
|
||||||
{
|
},
|
||||||
"disk": "/dev/mapper/centos-swap",
|
{
|
||||||
"cylinders": 261,
|
- `"disk"` - "/dev/mapper/centos-swap",
|
||||||
"heads": 255,
|
- `"cylinders"` - 261,
|
||||||
"sectors_per_track": 63
|
- `"heads"` - 255,
|
||||||
}
|
- `"sectors_per_track"` - 63
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
# sfdisk -l | jc --sfdisk -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"disk"` - "/dev/sda",
|
||||||
|
- `"cylinders"` - "2610",
|
||||||
|
- `"heads"` - "255",
|
||||||
|
- `"sectors_per_track"` - "63",
|
||||||
|
- `"units"` - "cylinders of 8225280 bytes, blocks of 1024 bytes, co...",
|
||||||
|
- `"partitions"` - [
|
||||||
|
{
|
||||||
|
- `"device"` - "/dev/sda1",
|
||||||
|
- `"boot"` - "*",
|
||||||
|
- `"start"` - "0+",
|
||||||
|
- `"end"` - "130-",
|
||||||
|
- `"cyls"` - "131-",
|
||||||
|
- `"blocks"` - "1048576",
|
||||||
|
- `"id"` - "83",
|
||||||
|
- `"system"` - "Linux"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "/dev/sda2",
|
||||||
|
- `"boot"` - null,
|
||||||
|
- `"start"` - "130+",
|
||||||
|
- `"end"` - "2610-",
|
||||||
|
- `"cyls"` - "2481-",
|
||||||
|
- `"blocks"` - "19921920",
|
||||||
|
- `"id"` - "8e",
|
||||||
|
- `"system"` - "Linux LVM"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "/dev/sda3",
|
||||||
|
- `"boot"` - null,
|
||||||
|
- `"start"` - "0",
|
||||||
|
- `"end"` - "-",
|
||||||
|
- `"cyls"` - "0",
|
||||||
|
- `"blocks"` - "0",
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"system"` - "Empty"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"device"` - "/dev/sda4",
|
||||||
|
- `"boot"` - null,
|
||||||
|
- `"start"` - "0",
|
||||||
|
- `"end"` - "-",
|
||||||
|
- `"cyls"` - "0",
|
||||||
|
- `"blocks"` - "0",
|
||||||
|
- `"id"` - "0",
|
||||||
|
- `"system"` - "Empty"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"disk"` - "/dev/mapper/centos-root",
|
||||||
|
- `"cylinders"` - "2218",
|
||||||
|
- `"heads"` - "255",
|
||||||
|
- `"sectors_per_track"` - "63"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"disk"` - "/dev/mapper/centos-swap",
|
||||||
|
- `"cylinders"` - "261",
|
||||||
|
- `"heads"` - "255",
|
||||||
|
- `"sectors_per_track"` - "63"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
# sfdisk -l | jc --sfdisk -p -r
|
<a id="jc.parsers.sfdisk.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"disk": "/dev/sda",
|
|
||||||
"cylinders": "2610",
|
|
||||||
"heads": "255",
|
|
||||||
"sectors_per_track": "63",
|
|
||||||
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, co...",
|
|
||||||
"partitions": [
|
|
||||||
{
|
|
||||||
"device": "/dev/sda1",
|
|
||||||
"boot": "*",
|
|
||||||
"start": "0+",
|
|
||||||
"end": "130-",
|
|
||||||
"cyls": "131-",
|
|
||||||
"blocks": "1048576",
|
|
||||||
"id": "83",
|
|
||||||
"system": "Linux"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sda2",
|
|
||||||
"boot": null,
|
|
||||||
"start": "130+",
|
|
||||||
"end": "2610-",
|
|
||||||
"cyls": "2481-",
|
|
||||||
"blocks": "19921920",
|
|
||||||
"id": "8e",
|
|
||||||
"system": "Linux LVM"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sda3",
|
|
||||||
"boot": null,
|
|
||||||
"start": "0",
|
|
||||||
"end": "-",
|
|
||||||
"cyls": "0",
|
|
||||||
"blocks": "0",
|
|
||||||
"id": "0",
|
|
||||||
"system": "Empty"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"device": "/dev/sda4",
|
|
||||||
"boot": null,
|
|
||||||
"start": "0",
|
|
||||||
"end": "-",
|
|
||||||
"cyls": "0",
|
|
||||||
"blocks": "0",
|
|
||||||
"id": "0",
|
|
||||||
"system": "Empty"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"disk": "/dev/mapper/centos-root",
|
|
||||||
"cylinders": "2218",
|
|
||||||
"heads": "255",
|
|
||||||
"sectors_per_track": "63"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"disk": "/dev/mapper/centos-swap",
|
|
||||||
"cylinders": "261",
|
|
||||||
"heads": "255",
|
|
||||||
"sectors_per_track": "63"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.sfdisk.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,132 +1,144 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.shadow"></a>
|
||||||
|
|
||||||
# jc.parsers.shadow
|
# jc.parsers.shadow
|
||||||
|
|
||||||
jc - JSON CLI output utility `/etc/shadow` file parser
|
jc - JSON CLI output utility `/etc/shadow` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ sudo cat /etc/shadow | jc --shadow
|
$ sudo cat /etc/shadow | jc --shadow
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('shadow', shadow_file_output)
|
result = jc.parse('shadow', shadow_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.shadow
|
import jc.parsers.shadow
|
||||||
result = jc.parsers.shadow.parse(shadow_file_output)
|
result = jc.parsers.shadow.parse(shadow_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"username": string,
|
"username": string,
|
||||||
"password": string,
|
"password": string,
|
||||||
"last_changed": integer,
|
"last_changed": integer,
|
||||||
"minimum": integer,
|
"minimum": integer,
|
||||||
"maximum": integer,
|
"maximum": integer,
|
||||||
"warn": integer,
|
"warn": integer,
|
||||||
"inactive": integer,
|
"inactive": integer,
|
||||||
"expire": integer
|
"expire": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ sudo cat /etc/shadow | jc --shadow -p
|
|
||||||
[
|
$ sudo cat /etc/shadow | jc --shadow -p
|
||||||
{
|
[
|
||||||
"username": "root",
|
{
|
||||||
"password": "*",
|
- `"username"` - "root",
|
||||||
"last_changed": 18113,
|
- `"password"` - "*",
|
||||||
"minimum": 0,
|
- `"last_changed"` - 18113,
|
||||||
"maximum": 99999,
|
- `"minimum"` - 0,
|
||||||
"warn": 7,
|
- `"maximum"` - 99999,
|
||||||
"inactive": null,
|
- `"warn"` - 7,
|
||||||
"expire": null
|
- `"inactive"` - null,
|
||||||
},
|
- `"expire"` - null
|
||||||
{
|
},
|
||||||
"username": "daemon",
|
{
|
||||||
"password": "*",
|
- `"username"` - "daemon",
|
||||||
"last_changed": 18113,
|
- `"password"` - "*",
|
||||||
"minimum": 0,
|
- `"last_changed"` - 18113,
|
||||||
"maximum": 99999,
|
- `"minimum"` - 0,
|
||||||
"warn": 7,
|
- `"maximum"` - 99999,
|
||||||
"inactive": null,
|
- `"warn"` - 7,
|
||||||
"expire": null
|
- `"inactive"` - null,
|
||||||
},
|
- `"expire"` - null
|
||||||
{
|
},
|
||||||
"username": "bin",
|
{
|
||||||
"password": "*",
|
- `"username"` - "bin",
|
||||||
"last_changed": 18113,
|
- `"password"` - "*",
|
||||||
"minimum": 0,
|
- `"last_changed"` - 18113,
|
||||||
"maximum": 99999,
|
- `"minimum"` - 0,
|
||||||
"warn": 7,
|
- `"maximum"` - 99999,
|
||||||
"inactive": null,
|
- `"warn"` - 7,
|
||||||
"expire": null
|
- `"inactive"` - null,
|
||||||
},
|
- `"expire"` - null
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo cat /etc/shadow | jc --shadow -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"username"` - "root",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"last_changed"` - "18113",
|
||||||
|
- `"minimum"` - "0",
|
||||||
|
- `"maximum"` - "99999",
|
||||||
|
- `"warn"` - "7",
|
||||||
|
- `"inactive"` - "",
|
||||||
|
- `"expire"` - ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"username"` - "daemon",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"last_changed"` - "18113",
|
||||||
|
- `"minimum"` - "0",
|
||||||
|
- `"maximum"` - "99999",
|
||||||
|
- `"warn"` - "7",
|
||||||
|
- `"inactive"` - "",
|
||||||
|
- `"expire"` - ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"username"` - "bin",
|
||||||
|
- `"password"` - "*",
|
||||||
|
- `"last_changed"` - "18113",
|
||||||
|
- `"minimum"` - "0",
|
||||||
|
- `"maximum"` - "99999",
|
||||||
|
- `"warn"` - "7",
|
||||||
|
- `"inactive"` - "",
|
||||||
|
- `"expire"` - ""
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ sudo cat /etc/shadow | jc --shadow -p -r
|
<a id="jc.parsers.shadow.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"username": "root",
|
|
||||||
"password": "*",
|
|
||||||
"last_changed": "18113",
|
|
||||||
"minimum": "0",
|
|
||||||
"maximum": "99999",
|
|
||||||
"warn": "7",
|
|
||||||
"inactive": "",
|
|
||||||
"expire": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username": "daemon",
|
|
||||||
"password": "*",
|
|
||||||
"last_changed": "18113",
|
|
||||||
"minimum": "0",
|
|
||||||
"maximum": "99999",
|
|
||||||
"warn": "7",
|
|
||||||
"inactive": "",
|
|
||||||
"expire": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username": "bin",
|
|
||||||
"password": "*",
|
|
||||||
"last_changed": "18113",
|
|
||||||
"minimum": "0",
|
|
||||||
"maximum": "99999",
|
|
||||||
"warn": "7",
|
|
||||||
"inactive": "",
|
|
||||||
"expire": ""
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.shadow.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, aix, freebsd
|
Compatibility: linux, darwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ss"></a>
|
||||||
|
|
||||||
# jc.parsers.ss
|
# jc.parsers.ss
|
||||||
|
|
||||||
jc - JSON CLI output utility `ss` command output parser
|
jc - JSON CLI output utility `ss` command output parser
|
||||||
|
|
||||||
Extended information options like -e and -p are not supported and may cause
|
Extended information options like -e and -p are not supported and may cause
|
||||||
@ -8,304 +10,314 @@ parsing irregularities.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ss | jc --ss
|
$ ss | jc --ss
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ss
|
$ jc ss
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ss', ss_command_output)
|
result = jc.parse('ss', ss_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ss
|
import jc.parsers.ss
|
||||||
result = jc.parsers.ss.parse(ss_command_output)
|
result = jc.parsers.ss.parse(ss_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
Information from https://www.cyberciti.biz/files/ss.html used to define
|
Information from https://www.cyberciti.biz/files/ss.html used to define
|
||||||
field names
|
field names
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"netid": string,
|
"netid": string,
|
||||||
"state": string,
|
"state": string,
|
||||||
"recv_q": integer,
|
"recv_q": integer,
|
||||||
"send_q": integer,
|
"send_q": integer,
|
||||||
"local_address": string,
|
"local_address": string,
|
||||||
"local_port": string,
|
"local_port": string,
|
||||||
"local_port_num": integer,
|
"local_port_num": integer,
|
||||||
"peer_address": string,
|
"peer_address": string,
|
||||||
"peer_port": string,
|
"peer_port": string,
|
||||||
"peer_port_num": integer,
|
"peer_port_num": integer,
|
||||||
"interface": string,
|
"interface": string,
|
||||||
"link_layer" string,
|
"link_layer" string,
|
||||||
"channel": string,
|
"channel": string,
|
||||||
"path": string,
|
"path": string,
|
||||||
"pid": integer
|
"pid": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ sudo ss -a | jc --ss -p
|
|
||||||
[
|
$ sudo ss -a | jc --ss -p
|
||||||
{
|
[
|
||||||
"netid": "nl",
|
{
|
||||||
"state": "UNCONN",
|
- `"netid"` - "nl",
|
||||||
"recv_q": 0,
|
- `"state"` - "UNCONN",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"peer_address": "*",
|
- `"send_q"` - 0,
|
||||||
"channel": "rtnl:kernel"
|
- `"peer_address"` - "*",
|
||||||
},
|
- `"channel"` - "rtnl:kernel"
|
||||||
{
|
},
|
||||||
"netid": "nl",
|
{
|
||||||
"state": "UNCONN",
|
- `"netid"` - "nl",
|
||||||
"recv_q": 0,
|
- `"state"` - "UNCONN",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"peer_address": "*",
|
- `"send_q"` - 0,
|
||||||
"pid": 893,
|
- `"peer_address"` - "*",
|
||||||
"channel": "rtnl:systemd-resolve"
|
- `"pid"` - 893,
|
||||||
},
|
- `"channel"` - "rtnl:systemd-resolve"
|
||||||
...
|
},
|
||||||
{
|
...
|
||||||
"netid": "p_raw",
|
{
|
||||||
"state": "UNCONN",
|
- `"netid"` - "p_raw",
|
||||||
"recv_q": 0,
|
- `"state"` - "UNCONN",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"peer_address": "*",
|
- `"send_q"` - 0,
|
||||||
"link_layer": "LLDP",
|
- `"peer_address"` - "*",
|
||||||
"interface": "ens33"
|
- `"link_layer"` - "LLDP",
|
||||||
},
|
- `"interface"` - "ens33"
|
||||||
{
|
},
|
||||||
"netid": "u_dgr",
|
{
|
||||||
"state": "UNCONN",
|
- `"netid"` - "u_dgr",
|
||||||
"recv_q": 0,
|
- `"state"` - "UNCONN",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_port": "93066",
|
- `"send_q"` - 0,
|
||||||
"peer_address": "*",
|
- `"local_port"` - "93066",
|
||||||
"peer_port": "0",
|
- `"peer_address"` - "*",
|
||||||
"path": "/run/user/1000/systemd/notify"
|
- `"peer_port"` - "0",
|
||||||
},
|
- `"path"` - "/run/user/1000/systemd/notify"
|
||||||
{
|
},
|
||||||
"netid": "u_seq",
|
{
|
||||||
"state": "LISTEN",
|
- `"netid"` - "u_seq",
|
||||||
"recv_q": 0,
|
- `"state"` - "LISTEN",
|
||||||
"send_q": 128,
|
- `"recv_q"` - 0,
|
||||||
"local_port": "20699",
|
- `"send_q"` - 128,
|
||||||
"peer_address": "*",
|
- `"local_port"` - "20699",
|
||||||
"peer_port": "0",
|
- `"peer_address"` - "*",
|
||||||
"path": "/run/udev/control"
|
- `"peer_port"` - "0",
|
||||||
},
|
- `"path"` - "/run/udev/control"
|
||||||
...
|
},
|
||||||
{
|
...
|
||||||
"netid": "icmp6",
|
{
|
||||||
"state": "UNCONN",
|
- `"netid"` - "icmp6",
|
||||||
"recv_q": 0,
|
- `"state"` - "UNCONN",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "*",
|
- `"send_q"` - 0,
|
||||||
"local_port": "ipv6-icmp",
|
- `"local_address"` - "*",
|
||||||
"peer_address": "*",
|
- `"local_port"` - "ipv6-icmp",
|
||||||
"peer_port": "*",
|
- `"peer_address"` - "*",
|
||||||
"interface": "ens33"
|
- `"peer_port"` - "*",
|
||||||
},
|
- `"interface"` - "ens33"
|
||||||
{
|
},
|
||||||
"netid": "udp",
|
{
|
||||||
"state": "UNCONN",
|
- `"netid"` - "udp",
|
||||||
"recv_q": 0,
|
- `"state"` - "UNCONN",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "127.0.0.53",
|
- `"send_q"` - 0,
|
||||||
"local_port": "domain",
|
- `"local_address"` - "127.0.0.53",
|
||||||
"peer_address": "0.0.0.0",
|
- `"local_port"` - "domain",
|
||||||
"peer_port": "*",
|
- `"peer_address"` - "0.0.0.0",
|
||||||
"interface": "lo"
|
- `"peer_port"` - "*",
|
||||||
},
|
- `"interface"` - "lo"
|
||||||
{
|
},
|
||||||
"netid": "tcp",
|
{
|
||||||
"state": "LISTEN",
|
- `"netid"` - "tcp",
|
||||||
"recv_q": 0,
|
- `"state"` - "LISTEN",
|
||||||
"send_q": 128,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "127.0.0.53",
|
- `"send_q"` - 128,
|
||||||
"local_port": "domain",
|
- `"local_address"` - "127.0.0.53",
|
||||||
"peer_address": "0.0.0.0",
|
- `"local_port"` - "domain",
|
||||||
"peer_port": "*",
|
- `"peer_address"` - "0.0.0.0",
|
||||||
"interface": "lo"
|
- `"peer_port"` - "*",
|
||||||
},
|
- `"interface"` - "lo"
|
||||||
{
|
},
|
||||||
"netid": "tcp",
|
{
|
||||||
"state": "LISTEN",
|
- `"netid"` - "tcp",
|
||||||
"recv_q": 0,
|
- `"state"` - "LISTEN",
|
||||||
"send_q": 128,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "0.0.0.0",
|
- `"send_q"` - 128,
|
||||||
"local_port": "ssh",
|
- `"local_address"` - "0.0.0.0",
|
||||||
"peer_address": "0.0.0.0",
|
- `"local_port"` - "ssh",
|
||||||
"peer_port": "*"
|
- `"peer_address"` - "0.0.0.0",
|
||||||
},
|
- `"peer_port"` - "*"
|
||||||
{
|
},
|
||||||
"netid": "tcp",
|
{
|
||||||
"state": "LISTEN",
|
- `"netid"` - "tcp",
|
||||||
"recv_q": 0,
|
- `"state"` - "LISTEN",
|
||||||
"send_q": 128,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "[::]",
|
- `"send_q"` - 128,
|
||||||
"local_port": "ssh",
|
- `"local_address"` - "[::]",
|
||||||
"peer_address": "[::]",
|
- `"local_port"` - "ssh",
|
||||||
"peer_port": "*"
|
- `"peer_address"` - "[::]",
|
||||||
},
|
- `"peer_port"` - "*"
|
||||||
{
|
},
|
||||||
"netid": "v_str",
|
{
|
||||||
"state": "ESTAB",
|
- `"netid"` - "v_str",
|
||||||
"recv_q": 0,
|
- `"state"` - "ESTAB",
|
||||||
"send_q": 0,
|
- `"recv_q"` - 0,
|
||||||
"local_address": "999900439",
|
- `"send_q"` - 0,
|
||||||
"local_port": "1023",
|
- `"local_address"` - "999900439",
|
||||||
"peer_address": "0",
|
- `"local_port"` - "1023",
|
||||||
"peer_port": "976",
|
- `"peer_address"` - "0",
|
||||||
"local_port_num": 1023,
|
- `"peer_port"` - "976",
|
||||||
"peer_port_num": 976
|
- `"local_port_num"` - 1023,
|
||||||
}
|
- `"peer_port_num"` - 976
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ sudo ss -a | jc --ss -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"netid"` - "nl",
|
||||||
|
- `"state"` - "UNCONN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"peer_address"` - "*",
|
||||||
|
- `"channel"` - "rtnl:kernel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "nl",
|
||||||
|
- `"state"` - "UNCONN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"peer_address"` - "*",
|
||||||
|
- `"pid"` - "893",
|
||||||
|
- `"channel"` - "rtnl:systemd-resolve"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
{
|
||||||
|
- `"netid"` - "p_raw",
|
||||||
|
- `"state"` - "UNCONN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"peer_address"` - "*",
|
||||||
|
- `"link_layer"` - "LLDP",
|
||||||
|
- `"interface"` - "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "u_dgr",
|
||||||
|
- `"state"` - "UNCONN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"local_port"` - "93066",
|
||||||
|
- `"peer_address"` - "*",
|
||||||
|
- `"peer_port"` - "0",
|
||||||
|
- `"path"` - "/run/user/1000/systemd/notify"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "u_seq",
|
||||||
|
- `"state"` - "LISTEN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "128",
|
||||||
|
- `"local_port"` - "20699",
|
||||||
|
- `"peer_address"` - "*",
|
||||||
|
- `"peer_port"` - "0",
|
||||||
|
- `"path"` - "/run/udev/control"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
{
|
||||||
|
- `"netid"` - "icmp6",
|
||||||
|
- `"state"` - "UNCONN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"local_address"` - "*",
|
||||||
|
- `"local_port"` - "ipv6-icmp",
|
||||||
|
- `"peer_address"` - "*",
|
||||||
|
- `"peer_port"` - "*",
|
||||||
|
- `"interface"` - "ens33"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "udp",
|
||||||
|
- `"state"` - "UNCONN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"local_address"` - "127.0.0.53",
|
||||||
|
- `"local_port"` - "domain",
|
||||||
|
- `"peer_address"` - "0.0.0.0",
|
||||||
|
- `"peer_port"` - "*",
|
||||||
|
- `"interface"` - "lo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "tcp",
|
||||||
|
- `"state"` - "LISTEN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "128",
|
||||||
|
- `"local_address"` - "127.0.0.53",
|
||||||
|
- `"local_port"` - "domain",
|
||||||
|
- `"peer_address"` - "0.0.0.0",
|
||||||
|
- `"peer_port"` - "*",
|
||||||
|
- `"interface"` - "lo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "tcp",
|
||||||
|
- `"state"` - "LISTEN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "128",
|
||||||
|
- `"local_address"` - "0.0.0.0",
|
||||||
|
- `"local_port"` - "ssh",
|
||||||
|
- `"peer_address"` - "0.0.0.0",
|
||||||
|
- `"peer_port"` - "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "tcp",
|
||||||
|
- `"state"` - "LISTEN",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "128",
|
||||||
|
- `"local_address"` - "[::]",
|
||||||
|
- `"local_port"` - "ssh",
|
||||||
|
- `"peer_address"` - "[::]",
|
||||||
|
- `"peer_port"` - "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"netid"` - "v_str",
|
||||||
|
- `"state"` - "ESTAB",
|
||||||
|
- `"recv_q"` - "0",
|
||||||
|
- `"send_q"` - "0",
|
||||||
|
- `"local_address"` - "999900439",
|
||||||
|
- `"local_port"` - "1023",
|
||||||
|
- `"peer_address"` - "0",
|
||||||
|
- `"peer_port"` - "976"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ sudo ss -a | jc --ss -p -r
|
<a id="jc.parsers.ss.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"netid": "nl",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"peer_address": "*",
|
|
||||||
"channel": "rtnl:kernel"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "nl",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"peer_address": "*",
|
|
||||||
"pid": "893",
|
|
||||||
"channel": "rtnl:systemd-resolve"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
{
|
|
||||||
"netid": "p_raw",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"peer_address": "*",
|
|
||||||
"link_layer": "LLDP",
|
|
||||||
"interface": "ens33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "u_dgr",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_port": "93066",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "0",
|
|
||||||
"path": "/run/user/1000/systemd/notify"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "u_seq",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_port": "20699",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "0",
|
|
||||||
"path": "/run/udev/control"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
{
|
|
||||||
"netid": "icmp6",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_address": "*",
|
|
||||||
"local_port": "ipv6-icmp",
|
|
||||||
"peer_address": "*",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "ens33"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "udp",
|
|
||||||
"state": "UNCONN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_address": "127.0.0.53",
|
|
||||||
"local_port": "domain",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "lo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_address": "127.0.0.53",
|
|
||||||
"local_port": "domain",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*",
|
|
||||||
"interface": "lo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_address": "0.0.0.0",
|
|
||||||
"local_port": "ssh",
|
|
||||||
"peer_address": "0.0.0.0",
|
|
||||||
"peer_port": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "tcp",
|
|
||||||
"state": "LISTEN",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "128",
|
|
||||||
"local_address": "[::]",
|
|
||||||
"local_port": "ssh",
|
|
||||||
"peer_address": "[::]",
|
|
||||||
"peer_port": "*"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"netid": "v_str",
|
|
||||||
"state": "ESTAB",
|
|
||||||
"recv_q": "0",
|
|
||||||
"send_q": "0",
|
|
||||||
"local_address": "999900439",
|
|
||||||
"local_port": "1023",
|
|
||||||
"peer_address": "0",
|
|
||||||
"peer_port": "976"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ss.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.stat"></a>
|
||||||
|
|
||||||
# jc.parsers.stat
|
# jc.parsers.stat
|
||||||
|
|
||||||
jc - JSON CLI output utility `stat` command output parser
|
jc - JSON CLI output utility `stat` command output parser
|
||||||
|
|
||||||
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||||
@ -11,191 +13,201 @@ only available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ stat * | jc --stat
|
$ stat * | jc --stat
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc stat *
|
$ jc stat *
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('stat', stat_command_output)
|
result = jc.parse('stat', stat_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.stat
|
import jc.parsers.stat
|
||||||
result = jc.parsers.stat.parse(stat_command_output)
|
result = jc.parsers.stat.parse(stat_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"file": string,
|
"file": string,
|
||||||
"link_to" string,
|
"link_to" string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"blocks": integer,
|
"blocks": integer,
|
||||||
"io_blocks": integer,
|
"io_blocks": integer,
|
||||||
"type": string,
|
"type": string,
|
||||||
"device": string,
|
"device": string,
|
||||||
"inode": integer,
|
"inode": integer,
|
||||||
"links": integer,
|
"links": integer,
|
||||||
"access": string,
|
"access": string,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"uid": integer,
|
"uid": integer,
|
||||||
"user": string,
|
"user": string,
|
||||||
"gid": integer,
|
"gid": integer,
|
||||||
"group": string,
|
"group": string,
|
||||||
"access_time": string, # - = null
|
"access_time": string, # - = null
|
||||||
"access_time_epoch": integer, # naive timestamp
|
"access_time_epoch": integer, # naive timestamp
|
||||||
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"modify_time": string, # - = null
|
"modify_time": string, # - = null
|
||||||
"modify_time_epoch": integer, # naive timestamp
|
"modify_time_epoch": integer, # naive timestamp
|
||||||
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"change_time": string, # - = null
|
"change_time": string, # - = null
|
||||||
"change_time_epoch": integer, # naive timestamp
|
"change_time_epoch": integer, # naive timestamp
|
||||||
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"birth_time": string, # - = null
|
"birth_time": string, # - = null
|
||||||
"birth_time_epoch": integer, # naive timestamp
|
"birth_time_epoch": integer, # naive timestamp
|
||||||
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"unix_device": integer,
|
"unix_device": integer,
|
||||||
"rdev": integer,
|
"rdev": integer,
|
||||||
"block_size": integer,
|
"block_size": integer,
|
||||||
"unix_flags": string
|
"unix_flags": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ stat /bin/* | jc --stat -p
|
|
||||||
[
|
$ stat /bin/* | jc --stat -p
|
||||||
{
|
[
|
||||||
"file": "/bin/bash",
|
{
|
||||||
"size": 1113504,
|
- `"file"` - "/bin/bash",
|
||||||
"blocks": 2176,
|
- `"size"` - 1113504,
|
||||||
"io_blocks": 4096,
|
- `"blocks"` - 2176,
|
||||||
"type": "regular file",
|
- `"io_blocks"` - 4096,
|
||||||
"device": "802h/2050d",
|
- `"type"` - "regular file",
|
||||||
"inode": 131099,
|
- `"device"` - "802h/2050d",
|
||||||
"links": 1,
|
- `"inode"` - 131099,
|
||||||
"access": "0755",
|
- `"links"` - 1,
|
||||||
"flags": "-rwxr-xr-x",
|
- `"access"` - "0755",
|
||||||
"uid": 0,
|
- `"flags"` - "-rwxr-xr-x",
|
||||||
"user": "root",
|
- `"uid"` - 0,
|
||||||
"gid": 0,
|
- `"user"` - "root",
|
||||||
"group": "root",
|
- `"gid"` - 0,
|
||||||
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
- `"group"` - "root",
|
||||||
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
- `"access_time"` - "2019-11-14 08:18:03.509681766 +0000",
|
||||||
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
- `"modify_time"` - "2019-06-06 22:28:15.000000000 +0000",
|
||||||
"birth_time": null,
|
- `"change_time"` - "2019-08-12 17:21:29.521945390 +0000",
|
||||||
"access_time_epoch": 1573748283,
|
- `"birth_time"` - null,
|
||||||
"access_time_epoch_utc": 1573719483,
|
- `"access_time_epoch"` - 1573748283,
|
||||||
"modify_time_epoch": 1559885295,
|
- `"access_time_epoch_utc"` - 1573719483,
|
||||||
"modify_time_epoch_utc": 1559860095,
|
- `"modify_time_epoch"` - 1559885295,
|
||||||
"change_time_epoch": 1565655689,
|
- `"modify_time_epoch_utc"` - 1559860095,
|
||||||
"change_time_epoch_utc": 1565630489,
|
- `"change_time_epoch"` - 1565655689,
|
||||||
"birth_time_epoch": null,
|
- `"change_time_epoch_utc"` - 1565630489,
|
||||||
"birth_time_epoch_utc": null
|
- `"birth_time_epoch"` - null,
|
||||||
},
|
- `"birth_time_epoch_utc"` - null
|
||||||
{
|
},
|
||||||
"file": "/bin/btrfs",
|
{
|
||||||
"size": 716464,
|
- `"file"` - "/bin/btrfs",
|
||||||
"blocks": 1400,
|
- `"size"` - 716464,
|
||||||
"io_blocks": 4096,
|
- `"blocks"` - 1400,
|
||||||
"type": "regular file",
|
- `"io_blocks"` - 4096,
|
||||||
"device": "802h/2050d",
|
- `"type"` - "regular file",
|
||||||
"inode": 131100,
|
- `"device"` - "802h/2050d",
|
||||||
"links": 1,
|
- `"inode"` - 131100,
|
||||||
"access": "0755",
|
- `"links"` - 1,
|
||||||
"flags": "-rwxr-xr-x",
|
- `"access"` - "0755",
|
||||||
"uid": 0,
|
- `"flags"` - "-rwxr-xr-x",
|
||||||
"user": "root",
|
- `"uid"` - 0,
|
||||||
"gid": 0,
|
- `"user"` - "root",
|
||||||
"group": "root",
|
- `"gid"` - 0,
|
||||||
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
- `"group"` - "root",
|
||||||
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
- `"access_time"` - "2019-11-14 08:18:28.990834276 +0000",
|
||||||
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
- `"modify_time"` - "2018-03-12 23:04:27.000000000 +0000",
|
||||||
"birth_time": null,
|
- `"change_time"` - "2019-08-12 17:21:29.545944399 +0000",
|
||||||
"access_time_epoch": 1573748308,
|
- `"birth_time"` - null,
|
||||||
"access_time_epoch_utc": 1573719508,
|
- `"access_time_epoch"` - 1573748308,
|
||||||
"modify_time_epoch": 1520921067,
|
- `"access_time_epoch_utc"` - 1573719508,
|
||||||
"modify_time_epoch_utc": 1520895867,
|
- `"modify_time_epoch"` - 1520921067,
|
||||||
"change_time_epoch": 1565655689,
|
- `"modify_time_epoch_utc"` - 1520895867,
|
||||||
"change_time_epoch_utc": 1565630489,
|
- `"change_time_epoch"` - 1565655689,
|
||||||
"birth_time_epoch": null,
|
- `"change_time_epoch_utc"` - 1565630489,
|
||||||
"birth_time_epoch_utc": null
|
- `"birth_time_epoch"` - null,
|
||||||
},
|
- `"birth_time_epoch_utc"` - null
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
$ stat /bin/* | jc --stat -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"file"` - "/bin/bash",
|
||||||
|
- `"size"` - "1113504",
|
||||||
|
- `"blocks"` - "2176",
|
||||||
|
- `"io_blocks"` - "4096",
|
||||||
|
- `"type"` - "regular file",
|
||||||
|
- `"device"` - "802h/2050d",
|
||||||
|
- `"inode"` - "131099",
|
||||||
|
- `"links"` - "1",
|
||||||
|
- `"access"` - "0755",
|
||||||
|
- `"flags"` - "-rwxr-xr-x",
|
||||||
|
- `"uid"` - "0",
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"gid"` - "0",
|
||||||
|
- `"group"` - "root",
|
||||||
|
- `"access_time"` - "2019-11-14 08:18:03.509681766 +0000",
|
||||||
|
- `"modify_time"` - "2019-06-06 22:28:15.000000000 +0000",
|
||||||
|
- `"change_time"` - "2019-08-12 17:21:29.521945390 +0000",
|
||||||
|
- `"birth_time"` - null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"file"` - "/bin/btrfs",
|
||||||
|
- `"size"` - "716464",
|
||||||
|
- `"blocks"` - "1400",
|
||||||
|
- `"io_blocks"` - "4096",
|
||||||
|
- `"type"` - "regular file",
|
||||||
|
- `"device"` - "802h/2050d",
|
||||||
|
- `"inode"` - "131100",
|
||||||
|
- `"links"` - "1",
|
||||||
|
- `"access"` - "0755",
|
||||||
|
- `"flags"` - "-rwxr-xr-x",
|
||||||
|
- `"uid"` - "0",
|
||||||
|
- `"user"` - "root",
|
||||||
|
- `"gid"` - "0",
|
||||||
|
- `"group"` - "root",
|
||||||
|
- `"access_time"` - "2019-11-14 08:18:28.990834276 +0000",
|
||||||
|
- `"modify_time"` - "2018-03-12 23:04:27.000000000 +0000",
|
||||||
|
- `"change_time"` - "2019-08-12 17:21:29.545944399 +0000",
|
||||||
|
- `"birth_time"` - null
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
$ stat /bin/* | jc --stat -p -r
|
<a id="jc.parsers.stat.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"file": "/bin/bash",
|
|
||||||
"size": "1113504",
|
|
||||||
"blocks": "2176",
|
|
||||||
"io_blocks": "4096",
|
|
||||||
"type": "regular file",
|
|
||||||
"device": "802h/2050d",
|
|
||||||
"inode": "131099",
|
|
||||||
"links": "1",
|
|
||||||
"access": "0755",
|
|
||||||
"flags": "-rwxr-xr-x",
|
|
||||||
"uid": "0",
|
|
||||||
"user": "root",
|
|
||||||
"gid": "0",
|
|
||||||
"group": "root",
|
|
||||||
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
|
||||||
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
|
||||||
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
|
||||||
"birth_time": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"file": "/bin/btrfs",
|
|
||||||
"size": "716464",
|
|
||||||
"blocks": "1400",
|
|
||||||
"io_blocks": "4096",
|
|
||||||
"type": "regular file",
|
|
||||||
"device": "802h/2050d",
|
|
||||||
"inode": "131100",
|
|
||||||
"links": "1",
|
|
||||||
"access": "0755",
|
|
||||||
"flags": "-rwxr-xr-x",
|
|
||||||
"uid": "0",
|
|
||||||
"user": "root",
|
|
||||||
"gid": "0",
|
|
||||||
"group": "root",
|
|
||||||
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
|
||||||
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
|
||||||
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
|
||||||
"birth_time": null
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.stat.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.stat_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.stat\_s
|
||||||
|
|
||||||
# jc.parsers.stat_s
|
|
||||||
jc - JSON CLI output utility `stat` command output streaming parser
|
jc - JSON CLI output utility `stat` command output streaming parser
|
||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
@ -13,107 +15,119 @@ only available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ stat * | jc --stat-s
|
$ stat * | jc --stat-s
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parse('stat_s', stat_command_output.splitlines())
|
result = jc.parse('stat_s', stat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.stat_s
|
import jc.parsers.stat_s
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parsers.stat_s.parse(stat_command_output.splitlines())
|
result = jc.parsers.stat_s.parse(stat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"file": string,
|
"file": string,
|
||||||
"link_to" string,
|
"link_to" string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"blocks": integer,
|
"blocks": integer,
|
||||||
"io_blocks": integer,
|
"io_blocks": integer,
|
||||||
"type": string,
|
"type": string,
|
||||||
"device": string,
|
"device": string,
|
||||||
"inode": integer,
|
"inode": integer,
|
||||||
"links": integer,
|
"links": integer,
|
||||||
"access": string,
|
"access": string,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"uid": integer,
|
"uid": integer,
|
||||||
"user": string,
|
"user": string,
|
||||||
"gid": integer,
|
"gid": integer,
|
||||||
"group": string,
|
"group": string,
|
||||||
"access_time": string, # - = null
|
"access_time": string, # - = null
|
||||||
"access_time_epoch": integer, # naive timestamp
|
"access_time_epoch": integer, # naive timestamp
|
||||||
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
"access_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"modify_time": string, # - = null
|
"modify_time": string, # - = null
|
||||||
"modify_time_epoch": integer, # naive timestamp
|
"modify_time_epoch": integer, # naive timestamp
|
||||||
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
"modify_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"change_time": string, # - = null
|
"change_time": string, # - = null
|
||||||
"change_time_epoch": integer, # naive timestamp
|
"change_time_epoch": integer, # naive timestamp
|
||||||
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
"change_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"birth_time": string, # - = null
|
"birth_time": string, # - = null
|
||||||
"birth_time_epoch": integer, # naive timestamp
|
"birth_time_epoch": integer, # naive timestamp
|
||||||
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
"birth_time_epoch_utc": integer, # timezone-aware timestamp
|
||||||
"unix_device": integer,
|
"unix_device": integer,
|
||||||
"rdev": integer,
|
"rdev": integer,
|
||||||
"block_size": integer,
|
"block_size": integer,
|
||||||
"unix_flags": string,
|
"unix_flags": string,
|
||||||
|
|
||||||
# Below object only exists if using -qq or ignore_exceptions=True
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
"_jc_meta":
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # false if error parsing
|
"success": boolean, # false if error parsing
|
||||||
"error": string, # exists if "success" is false
|
"error": string, # exists if "success" is false
|
||||||
"line": string # exists if "success" is false
|
"line": string # exists if "success" is false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ stat | jc --stat-s
|
|
||||||
{"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...}
|
$ stat | jc --stat-s
|
||||||
|
{"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...}
|
||||||
|
|
||||||
|
$ stat | jc --stat-s -r
|
||||||
|
{"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...}
|
||||||
|
|
||||||
$ stat | jc --stat-s -r
|
<a id="jc.parsers.stat_s.info"></a>
|
||||||
{"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.stat_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse
|
|
||||||
(e.g. sys.stdin or str.splitlines())
|
- `data` - (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
|
||||||
|
|
||||||
raw: (boolean) unprocessed output if True
|
**Yields**:
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
**Returns**:
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
Iterator object
|
||||||
Iterator object
|
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,88 +1,100 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.sysctl"></a>
|
||||||
|
|
||||||
# jc.parsers.sysctl
|
# jc.parsers.sysctl
|
||||||
|
|
||||||
jc - JSON CLI output utility `sysctl -a` command output parser
|
jc - JSON CLI output utility `sysctl -a` command output parser
|
||||||
|
|
||||||
Note: Since `sysctl` output is not easily parsable only a very simple
|
Note: Since `sysctl` output is not easily parsable only a very simple
|
||||||
key/value object will be output. An attempt is made to convert obvious
|
key/value object will be output. An attempt is made to convert obvious
|
||||||
integers and floats. If no conversion is desired, use the `-r`
|
integers and floats. If no conversion is desired, use the `-r`
|
||||||
command-line argument or the `raw=True` argument in `parse()`.
|
command-line argument or the `raw=True` argument in `parse()`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ sysctl -a | jc --sysctl
|
$ sysctl -a | jc --sysctl
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc sysctl -a
|
$ jc sysctl -a
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('sysctl', sysctl_command_output)
|
result = jc.parse('sysctl', sysctl_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.sysctl
|
import jc.parsers.sysctl
|
||||||
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string/integer/float, # best guess based on value
|
"key1": string/integer/float, # best guess based on value
|
||||||
"key2": string/integer/float,
|
"key2": string/integer/float,
|
||||||
"key3": string/integer/float
|
"key3": string/integer/float
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ sysctl -a | jc --sysctl -p
|
|
||||||
{
|
$ sysctl -a | jc --sysctl -p
|
||||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
{
|
||||||
"user.bc_base_max": 99,
|
- `"user.cs_path"` - "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
"user.bc_dim_max": 2048,
|
- `"user.bc_base_max"` - 99,
|
||||||
"user.bc_scale_max": 99,
|
- `"user.bc_dim_max"` - 2048,
|
||||||
"user.bc_string_max": 1000,
|
- `"user.bc_scale_max"` - 99,
|
||||||
"user.coll_weights_max": 2,
|
- `"user.bc_string_max"` - 1000,
|
||||||
"user.expr_nest_max": 32
|
- `"user.coll_weights_max"` - 2,
|
||||||
...
|
- `"user.expr_nest_max"` - 32
|
||||||
}
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
$ sysctl -a | jc --sysctl -p -r
|
||||||
|
{
|
||||||
|
- `"user.cs_path"` - "/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
|
- `"user.bc_base_max"` - "99",
|
||||||
|
- `"user.bc_dim_max"` - "2048",
|
||||||
|
- `"user.bc_scale_max"` - "99",
|
||||||
|
- `"user.bc_string_max"` - "1000",
|
||||||
|
- `"user.coll_weights_max"` - "2",
|
||||||
|
- `"user.expr_nest_max"` - "32",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
$ sysctl -a | jc --sysctl -p -r
|
<a id="jc.parsers.sysctl.info"></a>
|
||||||
{
|
|
||||||
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
|
|
||||||
"user.bc_base_max": "99",
|
|
||||||
"user.bc_dim_max": "2048",
|
|
||||||
"user.bc_scale_max": "99",
|
|
||||||
"user.bc_string_max": "1000",
|
|
||||||
"user.coll_weights_max": "2",
|
|
||||||
"user.expr_nest_max": "32",
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.sysctl.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,89 +1,101 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.systemctl"></a>
|
||||||
|
|
||||||
# jc.parsers.systemctl
|
# jc.parsers.systemctl
|
||||||
|
|
||||||
jc - JSON CLI output utility `systemctl` command output parser
|
jc - JSON CLI output utility `systemctl` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ systemctl | jc --systemctl
|
$ systemctl | jc --systemctl
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc systemctl
|
$ jc systemctl
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('systemctl', systemctl_command_output)
|
result = jc.parse('systemctl', systemctl_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.systemctl
|
import jc.parsers.systemctl
|
||||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"unit": string,
|
"unit": string,
|
||||||
"load": string,
|
"load": string,
|
||||||
"active": string,
|
"active": string,
|
||||||
"sub": string,
|
"sub": string,
|
||||||
"description": string
|
"description": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ systemctl -a | jc --systemctl -p
|
|
||||||
[
|
$ systemctl -a | jc --systemctl -p
|
||||||
{
|
[
|
||||||
"unit": "proc-sys-fs-binfmt_misc.automount",
|
{
|
||||||
"load": "loaded",
|
- `"unit"` - "proc-sys-fs-binfmt_misc.automount",
|
||||||
"active": "active",
|
- `"load"` - "loaded",
|
||||||
"sub": "waiting",
|
- `"active"` - "active",
|
||||||
"description": "Arbitrary Executable File Formats File System ..."
|
- `"sub"` - "waiting",
|
||||||
},
|
- `"description"` - "Arbitrary Executable File Formats File System ..."
|
||||||
{
|
},
|
||||||
"unit": "dev-block-8:2.device",
|
{
|
||||||
"load": "loaded",
|
- `"unit"` - "dev-block-8:2.device",
|
||||||
"active": "active",
|
- `"load"` - "loaded",
|
||||||
"sub": "plugged",
|
- `"active"` - "active",
|
||||||
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM o..."
|
- `"sub"` - "plugged",
|
||||||
},
|
- `"description"` - "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM o..."
|
||||||
{
|
},
|
||||||
"unit": "dev-cdrom.device",
|
{
|
||||||
"load": "loaded",
|
- `"unit"` - "dev-cdrom.device",
|
||||||
"active": "active",
|
- `"load"` - "loaded",
|
||||||
"sub": "plugged",
|
- `"active"` - "active",
|
||||||
"description": "VMware_Virtual_IDE_CDROM_Drive"
|
- `"sub"` - "plugged",
|
||||||
},
|
- `"description"` - "VMware_Virtual_IDE_CDROM_Drive"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.systemctl.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.systemctl.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,106 +1,118 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.systemctl_lj"></a>
|
||||||
|
|
||||||
|
# jc.parsers.systemctl\_lj
|
||||||
|
|
||||||
# jc.parsers.systemctl_lj
|
|
||||||
jc - JSON CLI output utility `systemctl list-jobs` command output parser
|
jc - JSON CLI output utility `systemctl list-jobs` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ systemctl list-jobs | jc --systemctl-lj
|
$ systemctl list-jobs | jc --systemctl-lj
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc systemctl list-jobs
|
$ jc systemctl list-jobs
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('systemctl_lj', systemctl_lj_command_output)
|
result = jc.parse('systemctl_lj', systemctl_lj_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.systemctl_lj
|
import jc.parsers.systemctl_lj
|
||||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"job": integer,
|
"job": integer,
|
||||||
"unit": string,
|
"unit": string,
|
||||||
"type": string,
|
"type": string,
|
||||||
"state": string
|
"state": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ systemctl list-jobs| jc --systemctl-lj -p
|
|
||||||
[
|
$ systemctl list-jobs| jc --systemctl-lj -p
|
||||||
{
|
[
|
||||||
"job": 3543,
|
{
|
||||||
"unit": "nginxAfterGlusterfs.service",
|
- `"job"` - 3543,
|
||||||
"type": "start",
|
- `"unit"` - "nginxAfterGlusterfs.service",
|
||||||
"state": "waiting"
|
- `"type"` - "start",
|
||||||
},
|
- `"state"` - "waiting"
|
||||||
{
|
},
|
||||||
"job": 3545,
|
{
|
||||||
"unit": "glusterReadyForLocalhostMount.service",
|
- `"job"` - 3545,
|
||||||
"type": "start",
|
- `"unit"` - "glusterReadyForLocalhostMount.service",
|
||||||
"state": "running"
|
- `"type"` - "start",
|
||||||
},
|
- `"state"` - "running"
|
||||||
{
|
},
|
||||||
"job": 3506,
|
{
|
||||||
"unit": "nginx.service",
|
- `"job"` - 3506,
|
||||||
"type": "start",
|
- `"unit"` - "nginx.service",
|
||||||
"state": "waiting"
|
- `"type"` - "start",
|
||||||
}
|
- `"state"` - "waiting"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ systemctl list-jobs| jc --systemctl-lj -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"job"` - "3543",
|
||||||
|
- `"unit"` - "nginxAfterGlusterfs.service",
|
||||||
|
- `"type"` - "start",
|
||||||
|
- `"state"` - "waiting"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"job"` - "3545",
|
||||||
|
- `"unit"` - "glusterReadyForLocalhostMount.service",
|
||||||
|
- `"type"` - "start",
|
||||||
|
- `"state"` - "running"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"job"` - "3506",
|
||||||
|
- `"unit"` - "nginx.service",
|
||||||
|
- `"type"` - "start",
|
||||||
|
- `"state"` - "waiting"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ systemctl list-jobs| jc --systemctl-lj -p -r
|
<a id="jc.parsers.systemctl_lj.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"job": "3543",
|
|
||||||
"unit": "nginxAfterGlusterfs.service",
|
|
||||||
"type": "start",
|
|
||||||
"state": "waiting"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"job": "3545",
|
|
||||||
"unit": "glusterReadyForLocalhostMount.service",
|
|
||||||
"type": "start",
|
|
||||||
"state": "running"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"job": "3506",
|
|
||||||
"unit": "nginx.service",
|
|
||||||
"type": "start",
|
|
||||||
"state": "waiting"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.systemctl_lj.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,82 +1,94 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.systemctl_ls"></a>
|
||||||
|
|
||||||
|
# jc.parsers.systemctl\_ls
|
||||||
|
|
||||||
# jc.parsers.systemctl_ls
|
|
||||||
jc - JSON CLI output utility `systemctl list-sockets` command output
|
jc - JSON CLI output utility `systemctl list-sockets` command output
|
||||||
parser
|
parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ systemctl list-sockets | jc --systemctl-ls
|
$ systemctl list-sockets | jc --systemctl-ls
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc systemctl list-sockets
|
$ jc systemctl list-sockets
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('systemctl_ls', systemctl_ls_command_output)
|
result = jc.parse('systemctl_ls', systemctl_ls_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.systemctl_ls
|
import jc.parsers.systemctl_ls
|
||||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"listen": string,
|
"listen": string,
|
||||||
"unit": string,
|
"unit": string,
|
||||||
"activates": string
|
"activates": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ systemctl list-sockets | jc --systemctl-ls -p
|
|
||||||
[
|
$ systemctl list-sockets | jc --systemctl-ls -p
|
||||||
{
|
[
|
||||||
"listen": "/dev/log",
|
{
|
||||||
"unit": "systemd-journald.socket",
|
- `"listen"` - "/dev/log",
|
||||||
"activates": "systemd-journald.service"
|
- `"unit"` - "systemd-journald.socket",
|
||||||
},
|
- `"activates"` - "systemd-journald.service"
|
||||||
{
|
},
|
||||||
"listen": "/run/dbus/system_bus_socket",
|
{
|
||||||
"unit": "dbus.socket",
|
- `"listen"` - "/run/dbus/system_bus_socket",
|
||||||
"activates": "dbus.service"
|
- `"unit"` - "dbus.socket",
|
||||||
},
|
- `"activates"` - "dbus.service"
|
||||||
{
|
},
|
||||||
"listen": "/run/dmeventd-client",
|
{
|
||||||
"unit": "dm-event.socket",
|
- `"listen"` - "/run/dmeventd-client",
|
||||||
"activates": "dm-event.service"
|
- `"unit"` - "dm-event.socket",
|
||||||
},
|
- `"activates"` - "dm-event.service"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.systemctl_ls.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.systemctl_ls.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,78 +1,90 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.systemctl_luf"></a>
|
||||||
|
|
||||||
|
# jc.parsers.systemctl\_luf
|
||||||
|
|
||||||
# jc.parsers.systemctl_luf
|
|
||||||
jc - JSON CLI output utility `systemctl list-unit-files` command output
|
jc - JSON CLI output utility `systemctl list-unit-files` command output
|
||||||
parser
|
parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ systemctl list-unit-files | jc --systemctl-luf
|
$ systemctl list-unit-files | jc --systemctl-luf
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc systemctl list-unit-files
|
$ jc systemctl list-unit-files
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('systemctl_luf', systemctl_luf_command_output)
|
result = jc.parse('systemctl_luf', systemctl_luf_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.systemctl_luf
|
import jc.parsers.systemctl_luf
|
||||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"unit_file": string,
|
"unit_file": string,
|
||||||
"state": string
|
"state": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ systemctl list-unit-files | jc --systemctl-luf -p
|
|
||||||
[
|
$ systemctl list-unit-files | jc --systemctl-luf -p
|
||||||
{
|
[
|
||||||
"unit_file": "proc-sys-fs-binfmt_misc.automount",
|
{
|
||||||
"state": "static"
|
- `"unit_file"` - "proc-sys-fs-binfmt_misc.automount",
|
||||||
},
|
- `"state"` - "static"
|
||||||
{
|
},
|
||||||
"unit_file": "dev-hugepages.mount",
|
{
|
||||||
"state": "static"
|
- `"unit_file"` - "dev-hugepages.mount",
|
||||||
},
|
- `"state"` - "static"
|
||||||
{
|
},
|
||||||
"unit_file": "dev-mqueue.mount",
|
{
|
||||||
"state": "static"
|
- `"unit_file"` - "dev-mqueue.mount",
|
||||||
},
|
- `"state"` - "static"
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.systemctl_luf.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.systemctl_luf.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.systeminfo"></a>
|
||||||
|
|
||||||
# jc.parsers.systeminfo
|
# jc.parsers.systeminfo
|
||||||
|
|
||||||
jc - JSON CLI output utility `systeminfo` command output parser
|
jc - JSON CLI output utility `systeminfo` command output parser
|
||||||
|
|
||||||
Blank or missing elements are set to `null`.
|
Blank or missing elements are set to `null`.
|
||||||
@ -15,228 +17,238 @@ the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ systeminfo | jc --systeminfo
|
$ systeminfo | jc --systeminfo
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('systeminfo', systeminfo_command_output)
|
result = jc.parse('systeminfo', systeminfo_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.systeminfo
|
import jc.parsers.systeminfo
|
||||||
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
|
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"host_name": string,
|
"host_name": string,
|
||||||
"os_name": string,
|
"os_name": string,
|
||||||
"os_version": string,
|
"os_version": string,
|
||||||
"os_manufacturer": string,
|
"os_manufacturer": string,
|
||||||
"os_configuration": string,
|
"os_configuration": string,
|
||||||
"os_build_type": string,
|
"os_build_type": string,
|
||||||
"registered_owner": string,
|
"registered_owner": string,
|
||||||
"registered_organization": string,
|
"registered_organization": string,
|
||||||
"product_id": string,
|
"product_id": string,
|
||||||
"original_install_date": string,
|
"original_install_date": string,
|
||||||
"original_install_date_epoch": integer, # [0]
|
"original_install_date_epoch": integer, # [0]
|
||||||
"original_install_date_epoch_utc": integer, # [1]
|
"original_install_date_epoch_utc": integer, # [1]
|
||||||
"system_boot_time": string,
|
"system_boot_time": string,
|
||||||
"system_boot_time_epoch": integer, # [0]
|
"system_boot_time_epoch": integer, # [0]
|
||||||
"system_boot_time_epoch_utc": integer, # [1]
|
"system_boot_time_epoch_utc": integer, # [1]
|
||||||
"system_manufacturer": string,
|
"system_manufacturer": string,
|
||||||
"system_model": string,
|
"system_model": string,
|
||||||
"system_type": string,
|
"system_type": string,
|
||||||
"processors": [
|
"processors": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"bios_version": string,
|
"bios_version": string,
|
||||||
"windows_directory": string,
|
"windows_directory": string,
|
||||||
"system_directory": string,
|
"system_directory": string,
|
||||||
"boot_device": string,
|
"boot_device": string,
|
||||||
"system_locale": string,
|
"system_locale": string,
|
||||||
"input_locale": string,
|
"input_locale": string,
|
||||||
"time_zone": string,
|
"time_zone": string,
|
||||||
"total_physical_memory_mb": string,
|
"total_physical_memory_mb": string,
|
||||||
"available_physical_memory_mb": integer,
|
"available_physical_memory_mb": integer,
|
||||||
"virtual_memory_max_size_mb": integer,
|
"virtual_memory_max_size_mb": integer,
|
||||||
"virtual_memory_available_mb": integer,
|
"virtual_memory_available_mb": integer,
|
||||||
"virtual_memory_in_use_mb": integer,
|
"virtual_memory_in_use_mb": integer,
|
||||||
"page_file_locations": string,
|
"page_file_locations": string,
|
||||||
"domain": string,
|
"domain": string,
|
||||||
"logon_server": string,
|
"logon_server": string,
|
||||||
"hotfixs": [
|
"hotfixs": [
|
||||||
string
|
string
|
||||||
],
|
],
|
||||||
"network_cards": [
|
"network_cards": [
|
||||||
{
|
{
|
||||||
"name": string,
|
"name": string,
|
||||||
"connection_name": string,
|
"connection_name": string,
|
||||||
"status": string,
|
"status": string,
|
||||||
"dhcp_enabled": boolean,
|
"dhcp_enabled": boolean,
|
||||||
"dhcp_server": string,
|
"dhcp_server": string,
|
||||||
"ip_addresses": [
|
"ip_addresses": [
|
||||||
string
|
string
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hyperv_requirements": {
|
"hyperv_requirements": {
|
||||||
"vm_monitor_mode_extensions": boolean,
|
"vm_monitor_mode_extensions": boolean,
|
||||||
"virtualization_enabled_in_firmware": boolean,
|
"virtualization_enabled_in_firmware": boolean,
|
||||||
"second_level_address_translation": boolean,
|
"second_level_address_translation": boolean,
|
||||||
"data_execution_prevention_available": boolean
|
"data_execution_prevention_available": boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] naive timestamp
|
[0] naive timestamp
|
||||||
[1] timezone-aware timestamp
|
[1] timezone-aware timestamp
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ systeminfo | jc --systeminfo -p
|
|
||||||
{
|
$ systeminfo | jc --systeminfo -p
|
||||||
"host_name": "TESTLAPTOP",
|
{
|
||||||
"os_name": "Microsoft Windows 10 Enterprise",
|
- `"host_name"` - "TESTLAPTOP",
|
||||||
"os_version": "10.0.17134 N/A Build 17134",
|
- `"os_name"` - "Microsoft Windows 10 Enterprise",
|
||||||
"os_manufacturer": "Microsoft Corporation",
|
- `"os_version"` - "10.0.17134 N/A Build 17134",
|
||||||
"os_configuration": "Member Workstation",
|
- `"os_manufacturer"` - "Microsoft Corporation",
|
||||||
"os_build_type": "Multiprocessor Free",
|
- `"os_configuration"` - "Member Workstation",
|
||||||
"registered_owner": "Test, Inc.",
|
- `"os_build_type"` - "Multiprocessor Free",
|
||||||
"registered_organization": "Test, Inc.",
|
- `"registered_owner"` - "Test, Inc.",
|
||||||
"product_id": "11111-11111-11111-AA111",
|
- `"registered_organization"` - "Test, Inc.",
|
||||||
"original_install_date": "3/26/2019, 3:51:30 PM",
|
- `"product_id"` - "11111-11111-11111-AA111",
|
||||||
"system_boot_time": "3/30/2021, 6:13:59 AM",
|
- `"original_install_date"` - "3/26/2019, 3:51:30 PM",
|
||||||
"system_manufacturer": "Dell Inc.",
|
- `"system_boot_time"` - "3/30/2021, 6:13:59 AM",
|
||||||
"system_model": "Precision 5530",
|
- `"system_manufacturer"` - "Dell Inc.",
|
||||||
"system_type": "x64-based PC",
|
- `"system_model"` - "Precision 5530",
|
||||||
"processors": [
|
- `"system_type"` - "x64-based PC",
|
||||||
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
|
- `"processors"` - [
|
||||||
],
|
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
|
||||||
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
|
],
|
||||||
"windows_directory": "C:\WINDOWS",
|
- `"bios_version"` - "Dell Inc. 1.16.2, 4/21/2020",
|
||||||
"system_directory": "C:\WINDOWS\system32",
|
- `"windows_directory"` - "C:\\WINDOWS",
|
||||||
"boot_device": "\Device\HarddiskVolume2",
|
- `"system_directory"` - "C:\\WINDOWS\\system32",
|
||||||
"system_locale": "en-us;English (United States)",
|
- `"boot_device"` - "\\Device\\HarddiskVolume2",
|
||||||
"input_locale": "en-us;English (United States)",
|
- `"system_locale"` - "en-us;English (United States)",
|
||||||
"time_zone": "(UTC+00:00) UTC",
|
- `"input_locale"` - "en-us;English (United States)",
|
||||||
"total_physical_memory_mb": 32503,
|
- `"time_zone"` - "(UTC+00:00) UTC",
|
||||||
"available_physical_memory_mb": 19743,
|
- `"total_physical_memory_mb"` - 32503,
|
||||||
"virtual_memory_max_size_mb": 37367,
|
- `"available_physical_memory_mb"` - 19743,
|
||||||
"virtual_memory_available_mb": 22266,
|
- `"virtual_memory_max_size_mb"` - 37367,
|
||||||
"virtual_memory_in_use_mb": 15101,
|
- `"virtual_memory_available_mb"` - 22266,
|
||||||
"page_file_locations": "C:\pagefile.sys",
|
- `"virtual_memory_in_use_mb"` - 15101,
|
||||||
"domain": "test.com",
|
- `"page_file_locations"` - "C:\\pagefile.sys",
|
||||||
"logon_server": "\\TESTDC01",
|
- `"domain"` - "test.com",
|
||||||
"hotfixs": [
|
- `"logon_server"` - "\\\\TESTDC01",
|
||||||
"KB2693643",
|
- `"hotfixs"` - [
|
||||||
"KB4601054"
|
"KB2693643",
|
||||||
],
|
"KB4601054"
|
||||||
"network_cards": [
|
],
|
||||||
{
|
- `"network_cards"` - [
|
||||||
"name": "Intel(R) Wireless-AC 9260 160MHz",
|
{
|
||||||
"connection_name": "Wi-Fi",
|
- `"name"` - "Intel(R) Wireless-AC 9260 160MHz",
|
||||||
"status": null,
|
- `"connection_name"` - "Wi-Fi",
|
||||||
"dhcp_enabled": true,
|
- `"status"` - null,
|
||||||
"dhcp_server": "192.168.2.1",
|
- `"dhcp_enabled"` - true,
|
||||||
"ip_addresses": [
|
- `"dhcp_server"` - "192.168.2.1",
|
||||||
"192.168.2.219"
|
- `"ip_addresses"` - [
|
||||||
]
|
"192.168.2.219"
|
||||||
}
|
]
|
||||||
],
|
}
|
||||||
"hyperv_requirements": {
|
],
|
||||||
"vm_monitor_mode_extensions": true,
|
- `"hyperv_requirements"` - {
|
||||||
"virtualization_enabled_in_firmware": true,
|
- `"vm_monitor_mode_extensions"` - true,
|
||||||
"second_level_address_translation": false,
|
- `"virtualization_enabled_in_firmware"` - true,
|
||||||
"data_execution_prevention_available": true
|
- `"second_level_address_translation"` - false,
|
||||||
},
|
- `"data_execution_prevention_available"` - true
|
||||||
"original_install_date_epoch": 1553640690,
|
},
|
||||||
"original_install_date_epoch_utc": 1553615490,
|
- `"original_install_date_epoch"` - 1553640690,
|
||||||
"system_boot_time_epoch": 1617110039,
|
- `"original_install_date_epoch_utc"` - 1553615490,
|
||||||
"system_boot_time_epoch_utc": 1617084839
|
- `"system_boot_time_epoch"` - 1617110039,
|
||||||
}
|
- `"system_boot_time_epoch_utc"` - 1617084839
|
||||||
|
}
|
||||||
|
|
||||||
|
$ systeminfo | jc --systeminfo -p -r
|
||||||
|
{
|
||||||
|
- `"host_name"` - "TESTLAPTOP",
|
||||||
|
- `"os_name"` - "Microsoft Windows 10 Enterprise",
|
||||||
|
- `"os_version"` - "10.0.17134 N/A Build 17134",
|
||||||
|
- `"os_manufacturer"` - "Microsoft Corporation",
|
||||||
|
- `"os_configuration"` - "Member Workstation",
|
||||||
|
- `"os_build_type"` - "Multiprocessor Free",
|
||||||
|
- `"registered_owner"` - "Test, Inc.",
|
||||||
|
- `"registered_organization"` - "Test, Inc.",
|
||||||
|
- `"product_id"` - "11111-11111-11111-AA111",
|
||||||
|
- `"original_install_date"` - "3/26/2019, 3:51:30 PM",
|
||||||
|
- `"system_boot_time"` - "3/30/2021, 6:13:59 AM",
|
||||||
|
- `"system_manufacturer"` - "Dell Inc.",
|
||||||
|
- `"system_model"` - "Precision 5530",
|
||||||
|
- `"system_type"` - "x64-based PC",
|
||||||
|
- `"processors"` - [
|
||||||
|
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
|
||||||
|
],
|
||||||
|
- `"bios_version"` - "Dell Inc. 1.16.2, 4/21/2020",
|
||||||
|
- `"windows_directory"` - "C:\\WINDOWS",
|
||||||
|
- `"system_directory"` - "C:\\WINDOWS\\system32",
|
||||||
|
- `"boot_device"` - "\\Device\\HarddiskVolume2",
|
||||||
|
- `"system_locale"` - "en-us;English (United States)",
|
||||||
|
- `"input_locale"` - "en-us;English (United States)",
|
||||||
|
- `"time_zone"` - "(UTC+00:00) UTC",
|
||||||
|
- `"total_physical_memory_mb"` - "32,503 MB",
|
||||||
|
- `"available_physical_memory_mb"` - "19,743 MB",
|
||||||
|
- `"virtual_memory_max_size_mb"` - "37,367 MB",
|
||||||
|
- `"virtual_memory_available_mb"` - "22,266 MB",
|
||||||
|
- `"virtual_memory_in_use_mb"` - "15,101 MB",
|
||||||
|
- `"page_file_locations"` - "C:\\pagefile.sys",
|
||||||
|
- `"domain"` - "test.com",
|
||||||
|
- `"logon_server"` - "\\\\TESTDC01",
|
||||||
|
- `"hotfixs"` - [
|
||||||
|
"KB2693643",
|
||||||
|
"KB4601054"
|
||||||
|
],
|
||||||
|
- `"network_cards"` - [
|
||||||
|
{
|
||||||
|
- `"name"` - "Intel(R) Wireless-AC 9260 160MHz",
|
||||||
|
- `"connection_name"` - "Wi-Fi",
|
||||||
|
- `"status"` - "",
|
||||||
|
- `"dhcp_enabled"` - "Yes",
|
||||||
|
- `"dhcp_server"` - "192.168.2.1",
|
||||||
|
- `"ip_addresses"` - [
|
||||||
|
"192.168.2.219"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"hyperv_requirements"` - {
|
||||||
|
- `"vm_monitor_mode_extensions"` - "Yes",
|
||||||
|
- `"virtualization_enabled_in_firmware"` - "Yes",
|
||||||
|
- `"second_level_address_translation"` - "No",
|
||||||
|
- `"data_execution_prevention_available"` - "Yes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ systeminfo | jc --systeminfo -p -r
|
<a id="jc.parsers.systeminfo.info"></a>
|
||||||
{
|
|
||||||
"host_name": "TESTLAPTOP",
|
|
||||||
"os_name": "Microsoft Windows 10 Enterprise",
|
|
||||||
"os_version": "10.0.17134 N/A Build 17134",
|
|
||||||
"os_manufacturer": "Microsoft Corporation",
|
|
||||||
"os_configuration": "Member Workstation",
|
|
||||||
"os_build_type": "Multiprocessor Free",
|
|
||||||
"registered_owner": "Test, Inc.",
|
|
||||||
"registered_organization": "Test, Inc.",
|
|
||||||
"product_id": "11111-11111-11111-AA111",
|
|
||||||
"original_install_date": "3/26/2019, 3:51:30 PM",
|
|
||||||
"system_boot_time": "3/30/2021, 6:13:59 AM",
|
|
||||||
"system_manufacturer": "Dell Inc.",
|
|
||||||
"system_model": "Precision 5530",
|
|
||||||
"system_type": "x64-based PC",
|
|
||||||
"processors": [
|
|
||||||
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
|
|
||||||
],
|
|
||||||
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
|
|
||||||
"windows_directory": "C:\WINDOWS",
|
|
||||||
"system_directory": "C:\WINDOWS\system32",
|
|
||||||
"boot_device": "\Device\HarddiskVolume2",
|
|
||||||
"system_locale": "en-us;English (United States)",
|
|
||||||
"input_locale": "en-us;English (United States)",
|
|
||||||
"time_zone": "(UTC+00:00) UTC",
|
|
||||||
"total_physical_memory_mb": "32,503 MB",
|
|
||||||
"available_physical_memory_mb": "19,743 MB",
|
|
||||||
"virtual_memory_max_size_mb": "37,367 MB",
|
|
||||||
"virtual_memory_available_mb": "22,266 MB",
|
|
||||||
"virtual_memory_in_use_mb": "15,101 MB",
|
|
||||||
"page_file_locations": "C:\pagefile.sys",
|
|
||||||
"domain": "test.com",
|
|
||||||
"logon_server": "\\TESTDC01",
|
|
||||||
"hotfixs": [
|
|
||||||
"KB2693643",
|
|
||||||
"KB4601054"
|
|
||||||
],
|
|
||||||
"network_cards": [
|
|
||||||
{
|
|
||||||
"name": "Intel(R) Wireless-AC 9260 160MHz",
|
|
||||||
"connection_name": "Wi-Fi",
|
|
||||||
"status": "",
|
|
||||||
"dhcp_enabled": "Yes",
|
|
||||||
"dhcp_server": "192.168.2.1",
|
|
||||||
"ip_addresses": [
|
|
||||||
"192.168.2.219"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"hyperv_requirements": {
|
|
||||||
"vm_monitor_mode_extensions": "Yes",
|
|
||||||
"virtualization_enabled_in_firmware": "Yes",
|
|
||||||
"second_level_address_translation": "No",
|
|
||||||
"data_execution_prevention_available": "Yes"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.systeminfo.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: win32
|
Compatibility: win32
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.time"></a>
|
||||||
|
|
||||||
# jc.parsers.time
|
# jc.parsers.time
|
||||||
|
|
||||||
jc - JSON CLI output utility `/usr/bin/time` command output parser
|
jc - JSON CLI output utility `/usr/bin/time` command output parser
|
||||||
|
|
||||||
Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be
|
Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be
|
||||||
@ -10,154 +12,164 @@ Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT`
|
|||||||
so `jc` can receive it.
|
so `jc` can receive it.
|
||||||
|
|
||||||
Note: `/usr/bin/time` is similar but different from the Bash builtin
|
Note: `/usr/bin/time` is similar but different from the Bash builtin
|
||||||
`time` command.
|
`time` command.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \
|
$ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \\
|
||||||
jc --time -p
|
jc --time -p
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('time', time_command_output)
|
result = jc.parse('time', time_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.time
|
import jc.parsers.time
|
||||||
result = jc.parsers.time.parse(time_command_output)
|
result = jc.parsers.time.parse(time_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||||
https://man7.org/linux/man-pages/man1/time.1.html
|
https://man7.org/linux/man-pages/man1/time.1.html
|
||||||
|
|
||||||
{
|
{
|
||||||
"real_time": float,
|
"real_time": float,
|
||||||
"user_time": float,
|
"user_time": float,
|
||||||
"system_time": float,
|
"system_time": float,
|
||||||
"elapsed_time": string,
|
"elapsed_time": string,
|
||||||
"elapsed_time_hours": integer,
|
"elapsed_time_hours": integer,
|
||||||
"elapsed_time_minutes": integer,
|
"elapsed_time_minutes": integer,
|
||||||
"elapsed_time_seconds": integer,
|
"elapsed_time_seconds": integer,
|
||||||
"elapsed_time_centiseconds": integer,
|
"elapsed_time_centiseconds": integer,
|
||||||
"elapsed_time_total_seconds": float,
|
"elapsed_time_total_seconds": float,
|
||||||
"cpu_percent": integer, # null if ?
|
"cpu_percent": integer, # null if ?
|
||||||
"average_shared_text_size": integer,
|
"average_shared_text_size": integer,
|
||||||
"average_unshared_data_size": integer,
|
"average_unshared_data_size": integer,
|
||||||
"average_unshared_stack_size": integer,
|
"average_unshared_stack_size": integer,
|
||||||
"average_shared_memory_size": integer,
|
"average_shared_memory_size": integer,
|
||||||
"maximum_resident_set_size": integer,
|
"maximum_resident_set_size": integer,
|
||||||
"block_input_operations": integer, # [0]
|
"block_input_operations": integer, # [0]
|
||||||
"block_output_operations": integer, # [1]
|
"block_output_operations": integer, # [1]
|
||||||
"major_pagefaults": integer,
|
"major_pagefaults": integer,
|
||||||
"minor_pagefaults": integer,
|
"minor_pagefaults": integer,
|
||||||
"swaps": integer,
|
"swaps": integer,
|
||||||
"page_reclaims": integer,
|
"page_reclaims": integer,
|
||||||
"page_faults": integer,
|
"page_faults": integer,
|
||||||
"messages_sent": integer,
|
"messages_sent": integer,
|
||||||
"messages_received": integer,
|
"messages_received": integer,
|
||||||
"signals_received": integer,
|
"signals_received": integer,
|
||||||
"voluntary_context_switches": integer,
|
"voluntary_context_switches": integer,
|
||||||
"involuntary_context_switches": integer
|
"involuntary_context_switches": integer
|
||||||
"command_being_timed": string,
|
"command_being_timed": string,
|
||||||
"average_stack_size": integer,
|
"average_stack_size": integer,
|
||||||
"average_total_size": integer,
|
"average_total_size": integer,
|
||||||
"average_resident_set_size": integer,
|
"average_resident_set_size": integer,
|
||||||
"signals_delivered": integer,
|
"signals_delivered": integer,
|
||||||
"page_size": integer,
|
"page_size": integer,
|
||||||
"exit_status": integer
|
"exit_status": integer
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] aka File system inputs
|
[0] aka File system inputs
|
||||||
[1] aka File system outputs
|
[1] aka File system outputs
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \
|
|
||||||
jc --time -p
|
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \\
|
||||||
{
|
jc --time -p
|
||||||
"command_being_timed": "sleep 2",
|
{
|
||||||
"user_time": 0.0,
|
- `"command_being_timed"` - "sleep 2",
|
||||||
"system_time": 0.0,
|
- `"user_time"` - 0.0,
|
||||||
"cpu_percent": 0,
|
- `"system_time"` - 0.0,
|
||||||
"elapsed_time": "0:02.00",
|
- `"cpu_percent"` - 0,
|
||||||
"average_shared_text_size": 0,
|
- `"elapsed_time"` - "0:02.00",
|
||||||
"average_unshared_data_size": 0,
|
- `"average_shared_text_size"` - 0,
|
||||||
"average_stack_size": 0,
|
- `"average_unshared_data_size"` - 0,
|
||||||
"average_total_size": 0,
|
- `"average_stack_size"` - 0,
|
||||||
"maximum_resident_set_size": 2084,
|
- `"average_total_size"` - 0,
|
||||||
"average_resident_set_size": 0,
|
- `"maximum_resident_set_size"` - 2084,
|
||||||
"major_pagefaults": 0,
|
- `"average_resident_set_size"` - 0,
|
||||||
"minor_pagefaults": 72,
|
- `"major_pagefaults"` - 0,
|
||||||
"voluntary_context_switches": 2,
|
- `"minor_pagefaults"` - 72,
|
||||||
"involuntary_context_switches": 1,
|
- `"voluntary_context_switches"` - 2,
|
||||||
"swaps": 0,
|
- `"involuntary_context_switches"` - 1,
|
||||||
"block_input_operations": 0,
|
- `"swaps"` - 0,
|
||||||
"block_output_operations": 0,
|
- `"block_input_operations"` - 0,
|
||||||
"messages_sent": 0,
|
- `"block_output_operations"` - 0,
|
||||||
"messages_received": 0,
|
- `"messages_sent"` - 0,
|
||||||
"signals_delivered": 0,
|
- `"messages_received"` - 0,
|
||||||
"page_size": 4096,
|
- `"signals_delivered"` - 0,
|
||||||
"exit_status": 0,
|
- `"page_size"` - 4096,
|
||||||
"elapsed_time_hours": 0,
|
- `"exit_status"` - 0,
|
||||||
"elapsed_time_minutes": 0,
|
- `"elapsed_time_hours"` - 0,
|
||||||
"elapsed_time_seconds": 2,
|
- `"elapsed_time_minutes"` - 0,
|
||||||
"elapsed_time_centiseconds": 50,
|
- `"elapsed_time_seconds"` - 2,
|
||||||
"elapsed_time_total_seconds": 2.5
|
- `"elapsed_time_centiseconds"` - 50,
|
||||||
}
|
- `"elapsed_time_total_seconds"` - 2.5
|
||||||
|
}
|
||||||
|
|
||||||
|
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \\
|
||||||
|
jc --time -p -r
|
||||||
|
{
|
||||||
|
- `"command_being_timed"` - "\"sleep 2\"",
|
||||||
|
- `"user_time"` - "0.00",
|
||||||
|
- `"system_time"` - "0.00",
|
||||||
|
- `"cpu_percent"` - "0",
|
||||||
|
- `"elapsed_time"` - "0:02.00",
|
||||||
|
- `"average_shared_text_size"` - "0",
|
||||||
|
- `"average_unshared_data_size"` - "0",
|
||||||
|
- `"average_stack_size"` - "0",
|
||||||
|
- `"average_total_size"` - "0",
|
||||||
|
- `"maximum_resident_set_size"` - "2084",
|
||||||
|
- `"average_resident_set_size"` - "0",
|
||||||
|
- `"major_pagefaults"` - "0",
|
||||||
|
- `"minor_pagefaults"` - "72",
|
||||||
|
- `"voluntary_context_switches"` - "2",
|
||||||
|
- `"involuntary_context_switches"` - "0",
|
||||||
|
- `"swaps"` - "0",
|
||||||
|
- `"block_input_operations"` - "0",
|
||||||
|
- `"block_output_operations"` - "0",
|
||||||
|
- `"messages_sent"` - "0",
|
||||||
|
- `"messages_received"` - "0",
|
||||||
|
- `"signals_delivered"` - "0",
|
||||||
|
- `"page_size"` - "4096",
|
||||||
|
- `"exit_status"` - "0"
|
||||||
|
}
|
||||||
|
|
||||||
$ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \
|
<a id="jc.parsers.time.info"></a>
|
||||||
jc --time -p -r
|
|
||||||
{
|
|
||||||
"command_being_timed": ""sleep 2"",
|
|
||||||
"user_time": "0.00",
|
|
||||||
"system_time": "0.00",
|
|
||||||
"cpu_percent": "0",
|
|
||||||
"elapsed_time": "0:02.00",
|
|
||||||
"average_shared_text_size": "0",
|
|
||||||
"average_unshared_data_size": "0",
|
|
||||||
"average_stack_size": "0",
|
|
||||||
"average_total_size": "0",
|
|
||||||
"maximum_resident_set_size": "2084",
|
|
||||||
"average_resident_set_size": "0",
|
|
||||||
"major_pagefaults": "0",
|
|
||||||
"minor_pagefaults": "72",
|
|
||||||
"voluntary_context_switches": "2",
|
|
||||||
"involuntary_context_switches": "0",
|
|
||||||
"swaps": "0",
|
|
||||||
"block_input_operations": "0",
|
|
||||||
"block_output_operations": "0",
|
|
||||||
"messages_sent": "0",
|
|
||||||
"messages_received": "0",
|
|
||||||
"signals_delivered": "0",
|
|
||||||
"page_size": "4096",
|
|
||||||
"exit_status": "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.time.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.timedatectl"></a>
|
||||||
|
|
||||||
# jc.parsers.timedatectl
|
# jc.parsers.timedatectl
|
||||||
|
|
||||||
jc - JSON CLI output utility `timedatectl` command output parser
|
jc - JSON CLI output utility `timedatectl` command output parser
|
||||||
|
|
||||||
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
||||||
@ -8,88 +10,98 @@ available if the `universal_time` field is available.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ timedatectl | jc --timedatectl
|
$ timedatectl | jc --timedatectl
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc timedatectl
|
$ jc timedatectl
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('timedatectl', timedatectl_command_output)
|
result = jc.parse('timedatectl', timedatectl_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.timedatectl
|
import jc.parsers.timedatectl
|
||||||
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"local_time": string,
|
"local_time": string,
|
||||||
"universal_time": string,
|
"universal_time": string,
|
||||||
"epoch_utc": integer, # timezone-aware
|
"epoch_utc": integer, # timezone-aware
|
||||||
"rtc_time": string,
|
"rtc_time": string,
|
||||||
"time_zone": string,
|
"time_zone": string,
|
||||||
"ntp_enabled": boolean,
|
"ntp_enabled": boolean,
|
||||||
"ntp_synchronized": boolean,
|
"ntp_synchronized": boolean,
|
||||||
"system_clock_synchronized": boolean,
|
"system_clock_synchronized": boolean,
|
||||||
"systemd-timesyncd.service_active": boolean,
|
"systemd-timesyncd.service_active": boolean,
|
||||||
"rtc_in_local_tz": boolean,
|
"rtc_in_local_tz": boolean,
|
||||||
"dst_active": boolean
|
"dst_active": boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ timedatectl | jc --timedatectl -p
|
|
||||||
{
|
$ timedatectl | jc --timedatectl -p
|
||||||
"local_time": "Tue 2020-03-10 17:53:21 PDT",
|
{
|
||||||
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
|
- `"local_time"` - "Tue 2020-03-10 17:53:21 PDT",
|
||||||
"rtc_time": "Wed 2020-03-11 00:53:21",
|
- `"universal_time"` - "Wed 2020-03-11 00:53:21 UTC",
|
||||||
"time_zone": "America/Los_Angeles (PDT, -0700)",
|
- `"rtc_time"` - "Wed 2020-03-11 00:53:21",
|
||||||
"ntp_enabled": true,
|
- `"time_zone"` - "America/Los_Angeles (PDT, -0700)",
|
||||||
"ntp_synchronized": true,
|
- `"ntp_enabled"` - true,
|
||||||
"rtc_in_local_tz": false,
|
- `"ntp_synchronized"` - true,
|
||||||
"dst_active": true,
|
- `"rtc_in_local_tz"` - false,
|
||||||
"epoch_utc": 1583888001
|
- `"dst_active"` - true,
|
||||||
}
|
- `"epoch_utc"` - 1583888001
|
||||||
|
}
|
||||||
|
|
||||||
|
$ timedatectl | jc --timedatectl -p -r
|
||||||
|
{
|
||||||
|
- `"local_time"` - "Tue 2020-03-10 17:53:21 PDT",
|
||||||
|
- `"universal_time"` - "Wed 2020-03-11 00:53:21 UTC",
|
||||||
|
- `"rtc_time"` - "Wed 2020-03-11 00:53:21",
|
||||||
|
- `"time_zone"` - "America/Los_Angeles (PDT, -0700)",
|
||||||
|
- `"ntp_enabled"` - "yes",
|
||||||
|
- `"ntp_synchronized"` - "yes",
|
||||||
|
- `"rtc_in_local_tz"` - "no",
|
||||||
|
- `"dst_active"` - "yes"
|
||||||
|
}
|
||||||
|
|
||||||
$ timedatectl | jc --timedatectl -p -r
|
<a id="jc.parsers.timedatectl.info"></a>
|
||||||
{
|
|
||||||
"local_time": "Tue 2020-03-10 17:53:21 PDT",
|
|
||||||
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
|
|
||||||
"rtc_time": "Wed 2020-03-11 00:53:21",
|
|
||||||
"time_zone": "America/Los_Angeles (PDT, -0700)",
|
|
||||||
"ntp_enabled": "yes",
|
|
||||||
"ntp_synchronized": "yes",
|
|
||||||
"rtc_in_local_tz": "no",
|
|
||||||
"dst_active": "yes"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.timedatectl.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,162 +1,174 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.tracepath"></a>
|
||||||
|
|
||||||
# jc.parsers.tracepath
|
# jc.parsers.tracepath
|
||||||
|
|
||||||
jc - JSON CLI output utility `tracepath` command output parser
|
jc - JSON CLI output utility `tracepath` command output parser
|
||||||
|
|
||||||
Supports `tracepath` and `tracepath6` output.
|
Supports `tracepath` and `tracepath6` output.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ tracepath 1.2.3.4 | jc --tracepath
|
$ tracepath 1.2.3.4 | jc --tracepath
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc tracepath 1.2.3.4
|
$ jc tracepath 1.2.3.4
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('tracepath', tracepath_command_output)
|
result = jc.parse('tracepath', tracepath_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.tracepath
|
import jc.parsers.tracepath
|
||||||
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"pmtu": integer,
|
"pmtu": integer,
|
||||||
"forward_hops": integer,
|
"forward_hops": integer,
|
||||||
"return_hops": integer,
|
"return_hops": integer,
|
||||||
"hops": [
|
"hops": [
|
||||||
{
|
{
|
||||||
"ttl": integer,
|
"ttl": integer,
|
||||||
"guess": boolean,
|
"guess": boolean,
|
||||||
"host": string,
|
"host": string,
|
||||||
"reply_ms": float,
|
"reply_ms": float,
|
||||||
"pmtu": integer,
|
"pmtu": integer,
|
||||||
"asymmetric_difference": integer,
|
"asymmetric_difference": integer,
|
||||||
"reached": boolean
|
"reached": boolean
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
|
|
||||||
{
|
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
|
||||||
"pmtu": 1480,
|
{
|
||||||
"forward_hops": 2,
|
- `"pmtu"` - 1480,
|
||||||
"return_hops": 2,
|
- `"forward_hops"` - 2,
|
||||||
"hops": [
|
- `"return_hops"` - 2,
|
||||||
{
|
- `"hops"` - [
|
||||||
"ttl": 1,
|
{
|
||||||
"guess": true,
|
- `"ttl"` - 1,
|
||||||
"host": "[LOCALHOST]",
|
- `"guess"` - true,
|
||||||
"reply_ms": null,
|
- `"host"` - "[LOCALHOST]",
|
||||||
"pmtu": 1500,
|
- `"reply_ms"` - null,
|
||||||
"asymmetric_difference": null,
|
- `"pmtu"` - 1500,
|
||||||
"reached": false
|
- `"asymmetric_difference"` - null,
|
||||||
},
|
- `"reached"` - false
|
||||||
{
|
},
|
||||||
"ttl": 1,
|
{
|
||||||
"guess": false,
|
- `"ttl"` - 1,
|
||||||
"host": "dust.inr.ac.ru",
|
- `"guess"` - false,
|
||||||
"reply_ms": 0.411,
|
- `"host"` - "dust.inr.ac.ru",
|
||||||
"pmtu": null,
|
- `"reply_ms"` - 0.411,
|
||||||
"asymmetric_difference": null,
|
- `"pmtu"` - null,
|
||||||
"reached": false
|
- `"asymmetric_difference"` - null,
|
||||||
},
|
- `"reached"` - false
|
||||||
{
|
},
|
||||||
"ttl": 2,
|
{
|
||||||
"guess": false,
|
- `"ttl"` - 2,
|
||||||
"host": "dust.inr.ac.ru",
|
- `"guess"` - false,
|
||||||
"reply_ms": 0.39,
|
- `"host"` - "dust.inr.ac.ru",
|
||||||
"pmtu": 1480,
|
- `"reply_ms"` - 0.39,
|
||||||
"asymmetric_difference": 1,
|
- `"pmtu"` - 1480,
|
||||||
"reached": false
|
- `"asymmetric_difference"` - 1,
|
||||||
},
|
- `"reached"` - false
|
||||||
{
|
},
|
||||||
"ttl": 2,
|
{
|
||||||
"guess": false,
|
- `"ttl"` - 2,
|
||||||
"host": "3ffe:2400:0:109::2",
|
- `"guess"` - false,
|
||||||
"reply_ms": 463.514,
|
- `"host"` - "3ffe:2400:0:109::2",
|
||||||
"pmtu": null,
|
- `"reply_ms"` - 463.514,
|
||||||
"asymmetric_difference": null,
|
- `"pmtu"` - null,
|
||||||
"reached": true
|
- `"asymmetric_difference"` - null,
|
||||||
}
|
- `"reached"` - true
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
|
||||||
|
{
|
||||||
|
- `"pmtu"` - "1480",
|
||||||
|
- `"forward_hops"` - "2",
|
||||||
|
- `"return_hops"` - "2",
|
||||||
|
- `"hops"` - [
|
||||||
|
{
|
||||||
|
- `"ttl"` - "1",
|
||||||
|
- `"guess"` - true,
|
||||||
|
- `"host"` - "[LOCALHOST]",
|
||||||
|
- `"reply_ms"` - null,
|
||||||
|
- `"pmtu"` - "1500",
|
||||||
|
- `"asymmetric_difference"` - null,
|
||||||
|
- `"reached"` - false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"ttl"` - "1",
|
||||||
|
- `"guess"` - false,
|
||||||
|
- `"host"` - "dust.inr.ac.ru",
|
||||||
|
- `"reply_ms"` - "0.411",
|
||||||
|
- `"pmtu"` - null,
|
||||||
|
- `"asymmetric_difference"` - null,
|
||||||
|
- `"reached"` - false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"ttl"` - "2",
|
||||||
|
- `"guess"` - false,
|
||||||
|
- `"host"` - "dust.inr.ac.ru",
|
||||||
|
- `"reply_ms"` - "0.390",
|
||||||
|
- `"pmtu"` - "1480",
|
||||||
|
- `"asymmetric_difference"` - "1",
|
||||||
|
- `"reached"` - false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"ttl"` - "2",
|
||||||
|
- `"guess"` - false,
|
||||||
|
- `"host"` - "3ffe:2400:0:109::2",
|
||||||
|
- `"reply_ms"` - "463.514",
|
||||||
|
- `"pmtu"` - null,
|
||||||
|
- `"asymmetric_difference"` - null,
|
||||||
|
- `"reached"` - true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
|
<a id="jc.parsers.tracepath.info"></a>
|
||||||
{
|
|
||||||
"pmtu": "1480",
|
|
||||||
"forward_hops": "2",
|
|
||||||
"return_hops": "2",
|
|
||||||
"hops": [
|
|
||||||
{
|
|
||||||
"ttl": "1",
|
|
||||||
"guess": true,
|
|
||||||
"host": "[LOCALHOST]",
|
|
||||||
"reply_ms": null,
|
|
||||||
"pmtu": "1500",
|
|
||||||
"asymmetric_difference": null,
|
|
||||||
"reached": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ttl": "1",
|
|
||||||
"guess": false,
|
|
||||||
"host": "dust.inr.ac.ru",
|
|
||||||
"reply_ms": "0.411",
|
|
||||||
"pmtu": null,
|
|
||||||
"asymmetric_difference": null,
|
|
||||||
"reached": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ttl": "2",
|
|
||||||
"guess": false,
|
|
||||||
"host": "dust.inr.ac.ru",
|
|
||||||
"reply_ms": "0.390",
|
|
||||||
"pmtu": "1480",
|
|
||||||
"asymmetric_difference": "1",
|
|
||||||
"reached": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ttl": "2",
|
|
||||||
"guess": false,
|
|
||||||
"host": "3ffe:2400:0:109::2",
|
|
||||||
"reply_ms": "463.514",
|
|
||||||
"pmtu": null,
|
|
||||||
"asymmetric_difference": null,
|
|
||||||
"reached": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.tracepath.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,151 +1,211 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.traceroute"></a>
|
||||||
|
|
||||||
# jc.parsers.traceroute
|
# jc.parsers.traceroute
|
||||||
|
|
||||||
jc - JSON CLI output utility `traceroute` command output parser
|
jc - JSON CLI output utility `traceroute` command output parser
|
||||||
|
|
||||||
Supports `traceroute` and `traceroute6` output.
|
Supports `traceroute` and `traceroute6` output.
|
||||||
|
|
||||||
Note: On some operating systems you will need to redirect `STDERR` to
|
Note: On some operating systems you will need to redirect `STDERR` to
|
||||||
`STDOUT` for destination info since the header line is sent to
|
`STDOUT` for destination info since the header line is sent to
|
||||||
`STDERR`. A warning message will be printed to `STDERR` if the
|
`STDERR`. A warning message will be printed to `STDERR` if the
|
||||||
header row is not found.
|
header row is not found.
|
||||||
|
|
||||||
e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
|
e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute`
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ traceroute 1.2.3.4 | jc --traceroute
|
$ traceroute 1.2.3.4 | jc --traceroute
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc traceroute 1.2.3.4
|
$ jc traceroute 1.2.3.4
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('traceroute', traceroute_command_output)
|
result = jc.parse('traceroute', traceroute_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.traceroute
|
import jc.parsers.traceroute
|
||||||
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"destination_ip": string,
|
"destination_ip": string,
|
||||||
"destination_name": string,
|
"destination_name": string,
|
||||||
"hops": [
|
"hops": [
|
||||||
{
|
{
|
||||||
"hop": integer,
|
"hop": integer,
|
||||||
"probes": [
|
"probes": [
|
||||||
{
|
{
|
||||||
"annotation": string,
|
"annotation": string,
|
||||||
"asn": integer,
|
"asn": integer,
|
||||||
"ip": string,
|
"ip": string,
|
||||||
"name": string,
|
"name": string,
|
||||||
"rtt": float
|
"rtt": float
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ traceroute google.com | jc --traceroute -p
|
|
||||||
{
|
$ traceroute google.com | jc --traceroute -p
|
||||||
"destination_ip": "216.58.194.46",
|
{
|
||||||
"destination_name": "google.com",
|
- `"destination_ip"` - "216.58.194.46",
|
||||||
"hops": [
|
- `"destination_name"` - "google.com",
|
||||||
{
|
- `"hops"` - [
|
||||||
"hop": 1,
|
{
|
||||||
"probes": [
|
- `"hop"` - 1,
|
||||||
{
|
- `"probes"` - [
|
||||||
"annotation": null,
|
{
|
||||||
"asn": null,
|
- `"annotation"` - null,
|
||||||
"ip": "216.230.231.141",
|
- `"asn"` - null,
|
||||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
- `"ip"` - "216.230.231.141",
|
||||||
"rtt": 198.574
|
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
|
||||||
},
|
- `"rtt"` - 198.574
|
||||||
{
|
},
|
||||||
"annotation": null,
|
{
|
||||||
"asn": null,
|
- `"annotation"` - null,
|
||||||
"ip": "216.230.231.141",
|
- `"asn"` - null,
|
||||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
- `"ip"` - "216.230.231.141",
|
||||||
"rtt": null
|
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
|
||||||
},
|
- `"rtt"` - null
|
||||||
{
|
},
|
||||||
"annotation": null,
|
{
|
||||||
"asn": null,
|
- `"annotation"` - null,
|
||||||
"ip": "216.230.231.141",
|
- `"asn"` - null,
|
||||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
- `"ip"` - "216.230.231.141",
|
||||||
"rtt": 198.65
|
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
|
||||||
}
|
- `"rtt"` - 198.65
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
}
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ traceroute google.com | jc --traceroute -p -r
|
||||||
|
{
|
||||||
|
- `"destination_ip"` - "216.58.194.46",
|
||||||
|
- `"destination_name"` - "google.com",
|
||||||
|
- `"hops"` - [
|
||||||
|
{
|
||||||
|
- `"hop"` - "1",
|
||||||
|
- `"probes"` - [
|
||||||
|
{
|
||||||
|
- `"annotation"` - null,
|
||||||
|
- `"asn"` - null,
|
||||||
|
- `"ip"` - "216.230.231.141",
|
||||||
|
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
|
||||||
|
- `"rtt"` - "198.574"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"annotation"` - null,
|
||||||
|
- `"asn"` - null,
|
||||||
|
- `"ip"` - "216.230.231.141",
|
||||||
|
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
|
||||||
|
- `"rtt"` - null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"annotation"` - null,
|
||||||
|
- `"asn"` - null,
|
||||||
|
- `"ip"` - "216.230.231.141",
|
||||||
|
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
|
||||||
|
- `"rtt"` - "198.650"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
$ traceroute google.com | jc --traceroute -p -r
|
<a id="jc.parsers.traceroute.info"></a>
|
||||||
{
|
|
||||||
"destination_ip": "216.58.194.46",
|
|
||||||
"destination_name": "google.com",
|
|
||||||
"hops": [
|
|
||||||
{
|
|
||||||
"hop": "1",
|
|
||||||
"probes": [
|
|
||||||
{
|
|
||||||
"annotation": null,
|
|
||||||
"asn": null,
|
|
||||||
"ip": "216.230.231.141",
|
|
||||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
||||||
"rtt": "198.574"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"annotation": null,
|
|
||||||
"asn": null,
|
|
||||||
"ip": "216.230.231.141",
|
|
||||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
||||||
"rtt": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"annotation": null,
|
|
||||||
"asn": null,
|
|
||||||
"ip": "216.230.231.141",
|
|
||||||
"name": "216-230-231-141.static.houston.tx.oplink.net",
|
|
||||||
"rtt": "198.650"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.traceroute.__version__"></a>
|
||||||
|
|
||||||
|
#### \_\_version\_\_
|
||||||
|
|
||||||
|
Copyright (C) 2015 Luis Benitez
|
||||||
|
|
||||||
|
Parses the output of a traceroute execution into an AST (Abstract Syntax Tree).
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Luis Benitez
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
<a id="jc.parsers.traceroute._Hop"></a>
|
||||||
|
|
||||||
|
## \_Hop Objects
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
class _Hop(object)
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id="jc.parsers.traceroute._Hop.add_probe"></a>
|
||||||
|
|
||||||
|
#### add\_probe
|
||||||
|
|
||||||
|
```python
|
||||||
|
def add_probe(probe)
|
||||||
|
```
|
||||||
|
|
||||||
|
Adds a Probe instance to this hop's results.
|
||||||
|
|
||||||
|
<a id="jc.parsers.traceroute.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
|
```python
|
||||||
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,231 +1,243 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ufw"></a>
|
||||||
|
|
||||||
# jc.parsers.ufw
|
# jc.parsers.ufw
|
||||||
|
|
||||||
jc - JSON CLI output utility `ufw status` command output parser
|
jc - JSON CLI output utility `ufw status` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ufw status | jc --ufw
|
$ ufw status | jc --ufw
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ufw status
|
$ jc ufw status
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ufw', ufw_command_output)
|
result = jc.parse('ufw', ufw_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ufw
|
import jc.parsers.ufw
|
||||||
result = jc.parsers.ufw.parse(ufw_command_output)
|
result = jc.parsers.ufw.parse(ufw_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"status": string,
|
"status": string,
|
||||||
"logging": string,
|
"logging": string,
|
||||||
"logging_level": string,
|
"logging_level": string,
|
||||||
"default": string,
|
"default": string,
|
||||||
"new_profiles": string,
|
"new_profiles": string,
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"action": string,
|
"action": string,
|
||||||
"action_direction": string, # null if blank
|
"action_direction": string, # null if blank
|
||||||
"index": integer, # null if blank
|
"index": integer, # null if blank
|
||||||
"network_protocol": string,
|
"network_protocol": string,
|
||||||
"to_ip": string,
|
"to_ip": string,
|
||||||
"to_ip_prefix": integer,
|
"to_ip_prefix": integer,
|
||||||
"to_interface": string,
|
"to_interface": string,
|
||||||
"to_transport": string,
|
"to_transport": string,
|
||||||
"to_ports": [
|
"to_ports": [
|
||||||
integer
|
integer
|
||||||
],
|
],
|
||||||
"to_port_ranges": [
|
"to_port_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer,
|
"start": integer,
|
||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"to_service": string, # [0]
|
"to_service": string, # [0]
|
||||||
"from_ip": string,
|
"from_ip": string,
|
||||||
"from_ip_prefix": integer,
|
"from_ip_prefix": integer,
|
||||||
"from_interface": string,
|
"from_interface": string,
|
||||||
"from_transport": string,
|
"from_transport": string,
|
||||||
"from_ports": [
|
"from_ports": [
|
||||||
integer
|
integer
|
||||||
],
|
],
|
||||||
"from_port_ranges": [
|
"from_port_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer,
|
"start": integer,
|
||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"from_service": string, # [1]
|
"from_service": string, # [1]
|
||||||
"comment": string # null if no comment
|
"comment": string # null if no comment
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] null if any 'to' ports or port_ranges are set
|
[0] null if any 'to' ports or port_ranges are set
|
||||||
[1] null if any 'from' ports or port_ranges are set
|
[1] null if any 'from' ports or port_ranges are set
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ufw status verbose | jc --ufw -p
|
|
||||||
{
|
$ ufw status verbose | jc --ufw -p
|
||||||
"status": "active",
|
{
|
||||||
"logging": "on",
|
- `"status"` - "active",
|
||||||
"logging_level": "low",
|
- `"logging"` - "on",
|
||||||
"default": "deny (incoming), allow (outgoing), disabled (routed)",
|
- `"logging_level"` - "low",
|
||||||
"new_profiles": "skip",
|
- `"default"` - "deny (incoming), allow (outgoing), disabled (routed)",
|
||||||
"rules": [
|
- `"new_profiles"` - "skip",
|
||||||
{
|
- `"rules"` - [
|
||||||
"action": "ALLOW",
|
{
|
||||||
"action_direction": "IN",
|
- `"action"` - "ALLOW",
|
||||||
"index": null,
|
- `"action_direction"` - "IN",
|
||||||
"network_protocol": "ipv4",
|
- `"index"` - null,
|
||||||
"to_interface": "any",
|
- `"network_protocol"` - "ipv4",
|
||||||
"to_transport": "any",
|
- `"to_interface"` - "any",
|
||||||
"to_service": null,
|
- `"to_transport"` - "any",
|
||||||
"to_ports": [
|
- `"to_service"` - null,
|
||||||
22
|
- `"to_ports"` - [
|
||||||
],
|
22
|
||||||
"to_ip": "0.0.0.0",
|
],
|
||||||
"to_ip_prefix": 0,
|
- `"to_ip"` - "0.0.0.0",
|
||||||
"comment": null,
|
- `"to_ip_prefix"` - 0,
|
||||||
"from_ip": "0.0.0.0",
|
- `"comment"` - null,
|
||||||
"from_ip_prefix": 0,
|
- `"from_ip"` - "0.0.0.0",
|
||||||
"from_interface": "any",
|
- `"from_ip_prefix"` - 0,
|
||||||
"from_transport": "any",
|
- `"from_interface"` - "any",
|
||||||
"from_port_ranges": [
|
- `"from_transport"` - "any",
|
||||||
{
|
- `"from_port_ranges"` - [
|
||||||
"start": 0,
|
{
|
||||||
"end": 65535
|
- `"start"` - 0,
|
||||||
}
|
- `"end"` - 65535
|
||||||
],
|
}
|
||||||
"from_service": null
|
],
|
||||||
},
|
- `"from_service"` - null
|
||||||
{
|
},
|
||||||
"action": "ALLOW",
|
{
|
||||||
"action_direction": "IN",
|
- `"action"` - "ALLOW",
|
||||||
"index": null,
|
- `"action_direction"` - "IN",
|
||||||
"network_protocol": "ipv4",
|
- `"index"` - null,
|
||||||
"to_interface": "any",
|
- `"network_protocol"` - "ipv4",
|
||||||
"to_transport": "tcp",
|
- `"to_interface"` - "any",
|
||||||
"to_service": null,
|
- `"to_transport"` - "tcp",
|
||||||
"to_ports": [
|
- `"to_service"` - null,
|
||||||
80,
|
- `"to_ports"` - [
|
||||||
443
|
80,
|
||||||
],
|
443
|
||||||
"to_ip": "0.0.0.0",
|
],
|
||||||
"to_ip_prefix": 0,
|
- `"to_ip"` - "0.0.0.0",
|
||||||
"comment": null,
|
- `"to_ip_prefix"` - 0,
|
||||||
"from_ip": "0.0.0.0",
|
- `"comment"` - null,
|
||||||
"from_ip_prefix": 0,
|
- `"from_ip"` - "0.0.0.0",
|
||||||
"from_interface": "any",
|
- `"from_ip_prefix"` - 0,
|
||||||
"from_transport": "any",
|
- `"from_interface"` - "any",
|
||||||
"from_port_ranges": [
|
- `"from_transport"` - "any",
|
||||||
{
|
- `"from_port_ranges"` - [
|
||||||
"start": 0,
|
{
|
||||||
"end": 65535
|
- `"start"` - 0,
|
||||||
}
|
- `"end"` - 65535
|
||||||
],
|
}
|
||||||
"from_service": null
|
],
|
||||||
},
|
- `"from_service"` - null
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
}
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ ufw status verbose | jc --ufw -p -r
|
||||||
|
{
|
||||||
|
- `"status"` - "active",
|
||||||
|
- `"logging"` - "on",
|
||||||
|
- `"logging_level"` - "low",
|
||||||
|
- `"default"` - "deny (incoming), allow (outgoing), disabled (routed)",
|
||||||
|
- `"new_profiles"` - "skip",
|
||||||
|
- `"rules"` - [
|
||||||
|
{
|
||||||
|
- `"action"` - "ALLOW",
|
||||||
|
- `"action_direction"` - "IN",
|
||||||
|
- `"index"` - null,
|
||||||
|
- `"network_protocol"` - "ipv4",
|
||||||
|
- `"to_interface"` - "any",
|
||||||
|
- `"to_transport"` - "any",
|
||||||
|
- `"to_service"` - null,
|
||||||
|
- `"to_ports"` - [
|
||||||
|
"22"
|
||||||
|
],
|
||||||
|
- `"to_ip"` - "0.0.0.0",
|
||||||
|
- `"to_ip_prefix"` - "0",
|
||||||
|
- `"comment"` - null,
|
||||||
|
- `"from_ip"` - "0.0.0.0",
|
||||||
|
- `"from_ip_prefix"` - "0",
|
||||||
|
- `"from_interface"` - "any",
|
||||||
|
- `"from_transport"` - "any",
|
||||||
|
- `"from_port_ranges"` - [
|
||||||
|
{
|
||||||
|
- `"start"` - "0",
|
||||||
|
- `"end"` - "65535"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"from_service"` - null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"action"` - "ALLOW",
|
||||||
|
- `"action_direction"` - "IN",
|
||||||
|
- `"index"` - null,
|
||||||
|
- `"network_protocol"` - "ipv4",
|
||||||
|
- `"to_interface"` - "any",
|
||||||
|
- `"to_transport"` - "tcp",
|
||||||
|
- `"to_service"` - null,
|
||||||
|
- `"to_ports"` - [
|
||||||
|
"80",
|
||||||
|
"443"
|
||||||
|
],
|
||||||
|
- `"to_ip"` - "0.0.0.0",
|
||||||
|
- `"to_ip_prefix"` - "0",
|
||||||
|
- `"comment"` - null,
|
||||||
|
- `"from_ip"` - "0.0.0.0",
|
||||||
|
- `"from_ip_prefix"` - "0",
|
||||||
|
- `"from_interface"` - "any",
|
||||||
|
- `"from_transport"` - "any",
|
||||||
|
- `"from_port_ranges"` - [
|
||||||
|
{
|
||||||
|
- `"start"` - "0",
|
||||||
|
- `"end"` - "65535"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"from_service"` - null
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
$ ufw status verbose | jc --ufw -p -r
|
<a id="jc.parsers.ufw.info"></a>
|
||||||
{
|
|
||||||
"status": "active",
|
|
||||||
"logging": "on",
|
|
||||||
"logging_level": "low",
|
|
||||||
"default": "deny (incoming), allow (outgoing), disabled (routed)",
|
|
||||||
"new_profiles": "skip",
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"action": "ALLOW",
|
|
||||||
"action_direction": "IN",
|
|
||||||
"index": null,
|
|
||||||
"network_protocol": "ipv4",
|
|
||||||
"to_interface": "any",
|
|
||||||
"to_transport": "any",
|
|
||||||
"to_service": null,
|
|
||||||
"to_ports": [
|
|
||||||
"22"
|
|
||||||
],
|
|
||||||
"to_ip": "0.0.0.0",
|
|
||||||
"to_ip_prefix": "0",
|
|
||||||
"comment": null,
|
|
||||||
"from_ip": "0.0.0.0",
|
|
||||||
"from_ip_prefix": "0",
|
|
||||||
"from_interface": "any",
|
|
||||||
"from_transport": "any",
|
|
||||||
"from_port_ranges": [
|
|
||||||
{
|
|
||||||
"start": "0",
|
|
||||||
"end": "65535"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"from_service": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "ALLOW",
|
|
||||||
"action_direction": "IN",
|
|
||||||
"index": null,
|
|
||||||
"network_protocol": "ipv4",
|
|
||||||
"to_interface": "any",
|
|
||||||
"to_transport": "tcp",
|
|
||||||
"to_service": null,
|
|
||||||
"to_ports": [
|
|
||||||
"80",
|
|
||||||
"443"
|
|
||||||
],
|
|
||||||
"to_ip": "0.0.0.0",
|
|
||||||
"to_ip_prefix": "0",
|
|
||||||
"comment": null,
|
|
||||||
"from_ip": "0.0.0.0",
|
|
||||||
"from_ip_prefix": "0",
|
|
||||||
"from_interface": "any",
|
|
||||||
"from_transport": "any",
|
|
||||||
"from_port_ranges": [
|
|
||||||
{
|
|
||||||
"start": "0",
|
|
||||||
"end": "65535"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"from_service": null
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ufw.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.ufw_appinfo"></a>
|
||||||
|
|
||||||
|
# jc.parsers.ufw\_appinfo
|
||||||
|
|
||||||
# jc.parsers.ufw_appinfo
|
|
||||||
jc - JSON CLI output utility `ufw app info [application]` command
|
jc - JSON CLI output utility `ufw app info [application]` command
|
||||||
output parser
|
output parser
|
||||||
|
|
||||||
@ -13,157 +15,167 @@ lists and ranges that remove duplicate ports and merge overlapping ranges.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ ufw app info OpenSSH | jc --ufw-appinfo
|
$ ufw app info OpenSSH | jc --ufw-appinfo
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc ufw app info OpenSSH
|
$ jc ufw app info OpenSSH
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('ufw_appinfo', ufw_appinfo_command_output)
|
result = jc.parse('ufw_appinfo', ufw_appinfo_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.ufw_appinfo
|
import jc.parsers.ufw_appinfo
|
||||||
result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output)
|
result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"profile": string,
|
"profile": string,
|
||||||
"title": string,
|
"title": string,
|
||||||
"description": string,
|
"description": string,
|
||||||
"tcp_list": [
|
"tcp_list": [
|
||||||
integer
|
integer
|
||||||
],
|
],
|
||||||
"tcp_ranges": [
|
"tcp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # [0]
|
"start": integer, # [0]
|
||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"udp_list": [
|
"udp_list": [
|
||||||
integer
|
integer
|
||||||
],
|
],
|
||||||
"udp_ranges": [
|
"udp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # [0]
|
"start": integer, # [0]
|
||||||
"end": integer
|
"end": integer
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"normalized_tcp_list": [
|
"normalized_tcp_list": [
|
||||||
integers # [1]
|
integers # [1]
|
||||||
],
|
],
|
||||||
"normalized_tcp_ranges": [
|
"normalized_tcp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # [0]
|
"start": integer, # [0]
|
||||||
"end": integers # [2]
|
"end": integers # [2]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"normalized_udp_list": [
|
"normalized_udp_list": [
|
||||||
integers # [1]
|
integers # [1]
|
||||||
],
|
],
|
||||||
"normalized_udp_ranges": [
|
"normalized_udp_ranges": [
|
||||||
{
|
{
|
||||||
"start": integer, # [0]
|
"start": integer, # [0]
|
||||||
"end": integers # [2]
|
"end": integers # [2]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] 'any' is converted to start/end: 0/65535
|
[0] 'any' is converted to start/end: 0/65535
|
||||||
[1] duplicates and overlapping are removed
|
[1] duplicates and overlapping are removed
|
||||||
[2] overlapping are merged
|
[2] overlapping are merged
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ ufw app info MSN | jc --ufw-appinfo -p
|
|
||||||
[
|
$ ufw app info MSN | jc --ufw-appinfo -p
|
||||||
{
|
[
|
||||||
"profile": "MSN",
|
{
|
||||||
"title": "MSN Chat",
|
- `"profile"` - "MSN",
|
||||||
"description": "MSN chat protocol (with file transfer and voice)",
|
- `"title"` - "MSN Chat",
|
||||||
"tcp_list": [
|
- `"description"` - "MSN chat protocol (with file transfer and voice)",
|
||||||
1863,
|
- `"tcp_list"` - [
|
||||||
6901
|
1863,
|
||||||
],
|
6901
|
||||||
"udp_list": [
|
],
|
||||||
1863,
|
- `"udp_list"` - [
|
||||||
6901
|
1863,
|
||||||
],
|
6901
|
||||||
"tcp_ranges": [
|
],
|
||||||
{
|
- `"tcp_ranges"` - [
|
||||||
"start": 6891,
|
{
|
||||||
"end": 6900
|
- `"start"` - 6891,
|
||||||
}
|
- `"end"` - 6900
|
||||||
],
|
}
|
||||||
"normalized_tcp_list": [
|
],
|
||||||
1863,
|
- `"normalized_tcp_list"` - [
|
||||||
6901
|
1863,
|
||||||
],
|
6901
|
||||||
"normalized_tcp_ranges": [
|
],
|
||||||
{
|
- `"normalized_tcp_ranges"` - [
|
||||||
"start": 6891,
|
{
|
||||||
"end": 6900
|
- `"start"` - 6891,
|
||||||
}
|
- `"end"` - 6900
|
||||||
],
|
}
|
||||||
"normalized_udp_list": [
|
],
|
||||||
1863,
|
- `"normalized_udp_list"` - [
|
||||||
6901
|
1863,
|
||||||
]
|
6901
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ ufw app info MSN | jc --ufw-appinfo -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"profile"` - "MSN",
|
||||||
|
- `"title"` - "MSN Chat",
|
||||||
|
- `"description"` - "MSN chat protocol (with file transfer and voice)",
|
||||||
|
- `"tcp_list"` - [
|
||||||
|
"1863",
|
||||||
|
"6901"
|
||||||
|
],
|
||||||
|
- `"udp_list"` - [
|
||||||
|
"1863",
|
||||||
|
"6901"
|
||||||
|
],
|
||||||
|
- `"tcp_ranges"` - [
|
||||||
|
{
|
||||||
|
- `"start"` - "6891",
|
||||||
|
- `"end"` - "6900"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ ufw app info MSN | jc --ufw-appinfo -p -r
|
<a id="jc.parsers.ufw_appinfo.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"profile": "MSN",
|
|
||||||
"title": "MSN Chat",
|
|
||||||
"description": "MSN chat protocol (with file transfer and voice)",
|
|
||||||
"tcp_list": [
|
|
||||||
"1863",
|
|
||||||
"6901"
|
|
||||||
],
|
|
||||||
"udp_list": [
|
|
||||||
"1863",
|
|
||||||
"6901"
|
|
||||||
],
|
|
||||||
"tcp_ranges": [
|
|
||||||
{
|
|
||||||
"start": "6891",
|
|
||||||
"end": "6900"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.ufw_appinfo.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,78 +1,90 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.uname"></a>
|
||||||
|
|
||||||
# jc.parsers.uname
|
# jc.parsers.uname
|
||||||
|
|
||||||
jc - JSON CLI output utility `uname -a` command output parser
|
jc - JSON CLI output utility `uname -a` command output parser
|
||||||
|
|
||||||
Note: Must use `uname -a`
|
Note: Must use `uname -a`
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ uname -a | jc --uname
|
$ uname -a | jc --uname
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc uname -a
|
$ jc uname -a
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('uname', uname_command_output)
|
result = jc.parse('uname', uname_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.uname
|
import jc.parsers.uname
|
||||||
result = jc.parsers.uname.parse(uname_command_output)
|
result = jc.parsers.uname.parse(uname_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"kernel_name": string,
|
"kernel_name": string,
|
||||||
"node_name": string,
|
"node_name": string,
|
||||||
"kernel_release": string,
|
"kernel_release": string,
|
||||||
"operating_system": string,
|
"operating_system": string,
|
||||||
"hardware_platform": string,
|
"hardware_platform": string,
|
||||||
"processor": string,
|
"processor": string,
|
||||||
"machine": string,
|
"machine": string,
|
||||||
"kernel_version": string
|
"kernel_version": string
|
||||||
}
|
}
|
||||||
|
|
||||||
Example:
|
**Example**:
|
||||||
|
|
||||||
$ uname -a | jc --uname -p
|
|
||||||
{
|
$ uname -a | jc --uname -p
|
||||||
"kernel_name": "Linux",
|
{
|
||||||
"node_name": "user-ubuntu",
|
- `"kernel_name"` - "Linux",
|
||||||
"kernel_release": "4.15.0-65-generic",
|
- `"node_name"` - "user-ubuntu",
|
||||||
"operating_system": "GNU/Linux",
|
- `"kernel_release"` - "4.15.0-65-generic",
|
||||||
"hardware_platform": "x86_64",
|
- `"operating_system"` - "GNU/Linux",
|
||||||
"processor": "x86_64",
|
- `"hardware_platform"` - "x86_64",
|
||||||
"machine": "x86_64",
|
- `"processor"` - "x86_64",
|
||||||
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
- `"machine"` - "x86_64",
|
||||||
}
|
- `"kernel_version"` - "`74`-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
|
||||||
|
}
|
||||||
|
|
||||||
|
<a id="jc.parsers.uname.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.uname.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
@ -1,57 +1,70 @@
|
|||||||
|
<a id="jc.parsers.universal"></a>
|
||||||
|
|
||||||
# jc.parsers.universal
|
# jc.parsers.universal
|
||||||
|
|
||||||
jc - JSON CLI output utility universal Parsers
|
jc - JSON CLI output utility universal Parsers
|
||||||
|
|
||||||
## simple_table_parse
|
<a id="jc.parsers.universal.simple_table_parse"></a>
|
||||||
|
|
||||||
|
#### simple\_table\_parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
simple_table_parse(data)
|
def simple_table_parse(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
Parse simple tables. The last column may contain data with spaces.
|
Parse simple tables. The last column may contain data with spaces.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (list) Text data to parse that has been split into lines
|
|
||||||
via .splitlines(). Item 0 must be the header row.
|
- `data` - (list) Text data to parse that has been split into lines
|
||||||
Any spaces in header names should be changed to
|
via .splitlines(). Item 0 must be the header row.
|
||||||
underscore '_'. You should also ensure headers are
|
Any spaces in header names should be changed to
|
||||||
lowercase by using .lower().
|
underscore '_'. You should also ensure headers are
|
||||||
|
lowercase by using .lower().
|
||||||
|
|
||||||
|
Also, ensure there are no blank lines (list items)
|
||||||
|
in the data.
|
||||||
|
|
||||||
|
|
||||||
Also, ensure there are no blank lines (list items)
|
**Returns**:
|
||||||
in the data.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
List of Dictionaries
|
||||||
|
|
||||||
List of Dictionaries
|
<a id="jc.parsers.universal.sparse_table_parse"></a>
|
||||||
|
|
||||||
|
#### sparse\_table\_parse
|
||||||
|
|
||||||
## sparse_table_parse
|
|
||||||
```python
|
```python
|
||||||
sparse_table_parse(data, delim='\u2063')
|
def sparse_table_parse(data, delim='\u2063')
|
||||||
```
|
```
|
||||||
|
|
||||||
Parse tables with missing column data or with spaces in column data.
|
Parse tables with missing column data or with spaces in column data.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (list) Text data to parse that has been split into lines
|
|
||||||
via .splitlines(). Item 0 must be the header row.
|
- `data` - (list) Text data to parse that has been split into lines
|
||||||
Any spaces in header names should be changed to
|
via .splitlines(). Item 0 must be the header row.
|
||||||
underscore '_'. You should also ensure headers are
|
Any spaces in header names should be changed to
|
||||||
lowercase by using .lower(). Do not change the
|
underscore '_'. You should also ensure headers are
|
||||||
position of header names as the positions are used
|
lowercase by using .lower(). Do not change the
|
||||||
to find the data.
|
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 it 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.
|
||||||
|
|
||||||
|
|
||||||
Also, ensure there are no blank lines (list items)
|
**Returns**:
|
||||||
in the data.
|
|
||||||
|
|
||||||
delim: (string) Delimiter to use. By default `u\2063`
|
|
||||||
(invisible separator) is used since it is unlikely
|
List of Dictionaries
|
||||||
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:
|
|
||||||
|
|
||||||
List of Dictionaries
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.upower"></a>
|
||||||
|
|
||||||
# jc.parsers.upower
|
# jc.parsers.upower
|
||||||
|
|
||||||
jc - JSON CLI output utility `upower` command output parser
|
jc - JSON CLI output utility `upower` command output parser
|
||||||
|
|
||||||
The `updated_epoch` calculated timestamp field is naive. (i.e. based on the
|
The `updated_epoch` calculated timestamp field is naive. (i.e. based on the
|
||||||
@ -11,219 +13,229 @@ only available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ upower -d | jc --upower
|
$ upower -d | jc --upower
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc upower -d
|
$ jc upower -d
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('upower', upower_command_output)
|
result = jc.parse('upower', upower_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.upower
|
import jc.parsers.upower
|
||||||
result = jc.parsers.upower.parse(upower_command_output)
|
result = jc.parsers.upower.parse(upower_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"type": string,
|
"type": string,
|
||||||
"device_name": string,
|
"device_name": string,
|
||||||
"native_path": string,
|
"native_path": string,
|
||||||
"power_supply": boolean,
|
"power_supply": boolean,
|
||||||
"updated": string,
|
"updated": string,
|
||||||
"updated_epoch": integer, # [0]
|
"updated_epoch": integer, # [0]
|
||||||
"updated_epoch_utc": integer, # [0]
|
"updated_epoch_utc": integer, # [0]
|
||||||
"updated_seconds_ago": integer,
|
"updated_seconds_ago": integer,
|
||||||
"has_history": boolean,
|
"has_history": boolean,
|
||||||
"has_statistics": boolean,
|
"has_statistics": boolean,
|
||||||
"detail": {
|
"detail": {
|
||||||
"type": string,
|
"type": string,
|
||||||
"warning_level": string, # null if none
|
"warning_level": string, # null if none
|
||||||
"online": boolean,
|
"online": boolean,
|
||||||
"icon_name": string
|
"icon_name": string
|
||||||
"present": boolean,
|
"present": boolean,
|
||||||
"rechargeable": boolean,
|
"rechargeable": boolean,
|
||||||
"state": string,
|
"state": string,
|
||||||
"energy": float,
|
"energy": float,
|
||||||
"energy_unit": string,
|
"energy_unit": string,
|
||||||
"energy_empty": float,
|
"energy_empty": float,
|
||||||
"energy_empty_unit": string,
|
"energy_empty_unit": string,
|
||||||
"energy_full": float,
|
"energy_full": float,
|
||||||
"energy_full_unit": string,
|
"energy_full_unit": string,
|
||||||
"energy_full_design": float,
|
"energy_full_design": float,
|
||||||
"energy_full_design_unit": string,
|
"energy_full_design_unit": string,
|
||||||
"energy_rate": float,
|
"energy_rate": float,
|
||||||
"energy_rate_unit": string,
|
"energy_rate_unit": string,
|
||||||
"voltage": float,
|
"voltage": float,
|
||||||
"voltage_unit": string,
|
"voltage_unit": string,
|
||||||
"time_to_full": float,
|
"time_to_full": float,
|
||||||
"time_to_full_unit": string,
|
"time_to_full_unit": string,
|
||||||
"percentage": float,
|
"percentage": float,
|
||||||
"capacity": float,
|
"capacity": float,
|
||||||
"technology": string
|
"technology": string
|
||||||
},
|
},
|
||||||
"history_charge": [
|
"history_charge": [
|
||||||
{
|
{
|
||||||
"time": integer,
|
"time": integer,
|
||||||
"percent_charged": float,
|
"percent_charged": float,
|
||||||
"status": string
|
"status": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"history_rate":[
|
"history_rate":[
|
||||||
{
|
{
|
||||||
"time": integer,
|
"time": integer,
|
||||||
"percent_charged": float,
|
"percent_charged": float,
|
||||||
"status": string
|
"status": string
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"daemon_version": string,
|
"daemon_version": string,
|
||||||
"on_battery": boolean,
|
"on_battery": boolean,
|
||||||
"lid_is_closed": boolean,
|
"lid_is_closed": boolean,
|
||||||
"lid_is_present": boolean,
|
"lid_is_present": boolean,
|
||||||
"critical_action": string
|
"critical_action": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] null if date-time conversion fails
|
[0] null if date-time conversion fails
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
|
|
||||||
[
|
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
|
||||||
{
|
[
|
||||||
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
|
{
|
||||||
"vendor": "NOTEBOOK",
|
- `"native_path"` - "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
|
||||||
"model": "BAT",
|
- `"vendor"` - "NOTEBOOK",
|
||||||
"serial": "0001",
|
- `"model"` - "BAT",
|
||||||
"power_supply": true,
|
- `"serial"` - "0001",
|
||||||
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC",
|
- `"power_supply"` - true,
|
||||||
"has_history": true,
|
- `"updated"` - "Thu 11 Mar 2021 06:28:08 PM UTC",
|
||||||
"has_statistics": true,
|
- `"has_history"` - true,
|
||||||
"detail": {
|
- `"has_statistics"` - true,
|
||||||
"type": "battery",
|
- `"detail"` - {
|
||||||
"present": true,
|
- `"type"` - "battery",
|
||||||
"rechargeable": true,
|
- `"present"` - true,
|
||||||
"state": "charging",
|
- `"rechargeable"` - true,
|
||||||
"energy": 22.3998,
|
- `"state"` - "charging",
|
||||||
"energy_empty": 0.0,
|
- `"energy"` - 22.3998,
|
||||||
"energy_full": 52.6473,
|
- `"energy_empty"` - 0.0,
|
||||||
"energy_full_design": 62.16,
|
- `"energy_full"` - 52.6473,
|
||||||
"energy_rate": 31.6905,
|
- `"energy_full_design"` - 62.16,
|
||||||
"voltage": 12.191,
|
- `"energy_rate"` - 31.6905,
|
||||||
"time_to_full": 57.3,
|
- `"voltage"` - 12.191,
|
||||||
"percentage": 42.5469,
|
- `"time_to_full"` - 57.3,
|
||||||
"capacity": 84.6964,
|
- `"percentage"` - 42.5469,
|
||||||
"technology": "lithium-ion",
|
- `"capacity"` - 84.6964,
|
||||||
"energy_unit": "Wh",
|
- `"technology"` - "lithium-ion",
|
||||||
"energy_empty_unit": "Wh",
|
- `"energy_unit"` - "Wh",
|
||||||
"energy_full_unit": "Wh",
|
- `"energy_empty_unit"` - "Wh",
|
||||||
"energy_full_design_unit": "Wh",
|
- `"energy_full_unit"` - "Wh",
|
||||||
"energy_rate_unit": "W",
|
- `"energy_full_design_unit"` - "Wh",
|
||||||
"voltage_unit": "V",
|
- `"energy_rate_unit"` - "W",
|
||||||
"time_to_full_unit": "minutes"
|
- `"voltage_unit"` - "V",
|
||||||
},
|
- `"time_to_full_unit"` - "minutes"
|
||||||
"history_charge": [
|
},
|
||||||
{
|
- `"history_charge"` - [
|
||||||
"time": 1328809335,
|
{
|
||||||
"percent_charged": 42.547,
|
- `"time"` - 1328809335,
|
||||||
"status": "charging"
|
- `"percent_charged"` - 42.547,
|
||||||
},
|
- `"status"` - "charging"
|
||||||
{
|
},
|
||||||
"time": 1328809305,
|
{
|
||||||
"percent_charged": 42.02,
|
- `"time"` - 1328809305,
|
||||||
"status": "charging"
|
- `"percent_charged"` - 42.02,
|
||||||
}
|
- `"status"` - "charging"
|
||||||
],
|
}
|
||||||
"history_rate": [
|
],
|
||||||
{
|
- `"history_rate"` - [
|
||||||
"time": 1328809335,
|
{
|
||||||
"percent_charged": 31.691,
|
- `"time"` - 1328809335,
|
||||||
"status": "charging"
|
- `"percent_charged"` - 31.691,
|
||||||
}
|
- `"status"` - "charging"
|
||||||
],
|
}
|
||||||
"updated_seconds_ago": 441975,
|
],
|
||||||
"updated_epoch": 1615516088,
|
- `"updated_seconds_ago"` - 441975,
|
||||||
"updated_epoch_utc": 1615487288
|
- `"updated_epoch"` - 1615516088,
|
||||||
}
|
- `"updated_epoch_utc"` - 1615487288
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"native_path"` - "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
|
||||||
|
- `"vendor"` - "NOTEBOOK",
|
||||||
|
- `"model"` - "BAT",
|
||||||
|
- `"serial"` - "0001",
|
||||||
|
- `"power_supply"` - "yes",
|
||||||
|
- `"updated"` - "Thu 11 Mar 2021 06:28:08 PM UTC (441975 seconds ago)",
|
||||||
|
- `"has_history"` - "yes",
|
||||||
|
- `"has_statistics"` - "yes",
|
||||||
|
- `"detail"` - {
|
||||||
|
- `"type"` - "battery",
|
||||||
|
- `"present"` - "yes",
|
||||||
|
- `"rechargeable"` - "yes",
|
||||||
|
- `"state"` - "charging",
|
||||||
|
- `"energy"` - "22.3998 Wh",
|
||||||
|
- `"energy_empty"` - "0 Wh",
|
||||||
|
- `"energy_full"` - "52.6473 Wh",
|
||||||
|
- `"energy_full_design"` - "62.16 Wh",
|
||||||
|
- `"energy_rate"` - "31.6905 W",
|
||||||
|
- `"voltage"` - "12.191 V",
|
||||||
|
- `"time_to_full"` - "57.3 minutes",
|
||||||
|
- `"percentage"` - "42.5469%",
|
||||||
|
- `"capacity"` - "84.6964%",
|
||||||
|
- `"technology"` - "lithium-ion"
|
||||||
|
},
|
||||||
|
- `"history_charge"` - [
|
||||||
|
{
|
||||||
|
- `"time"` - "1328809335",
|
||||||
|
- `"percent_charged"` - "42.547",
|
||||||
|
- `"status"` - "charging"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"time"` - "1328809305",
|
||||||
|
- `"percent_charged"` - "42.020",
|
||||||
|
- `"status"` - "charging"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
- `"history_rate"` - [
|
||||||
|
{
|
||||||
|
- `"time"` - "1328809335",
|
||||||
|
- `"percent_charged"` - "31.691",
|
||||||
|
- `"status"` - "charging"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
|
<a id="jc.parsers.upower.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
|
|
||||||
"vendor": "NOTEBOOK",
|
|
||||||
"model": "BAT",
|
|
||||||
"serial": "0001",
|
|
||||||
"power_supply": "yes",
|
|
||||||
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC (441975 seconds ago)",
|
|
||||||
"has_history": "yes",
|
|
||||||
"has_statistics": "yes",
|
|
||||||
"detail": {
|
|
||||||
"type": "battery",
|
|
||||||
"present": "yes",
|
|
||||||
"rechargeable": "yes",
|
|
||||||
"state": "charging",
|
|
||||||
"energy": "22.3998 Wh",
|
|
||||||
"energy_empty": "0 Wh",
|
|
||||||
"energy_full": "52.6473 Wh",
|
|
||||||
"energy_full_design": "62.16 Wh",
|
|
||||||
"energy_rate": "31.6905 W",
|
|
||||||
"voltage": "12.191 V",
|
|
||||||
"time_to_full": "57.3 minutes",
|
|
||||||
"percentage": "42.5469%",
|
|
||||||
"capacity": "84.6964%",
|
|
||||||
"technology": "lithium-ion"
|
|
||||||
},
|
|
||||||
"history_charge": [
|
|
||||||
{
|
|
||||||
"time": "1328809335",
|
|
||||||
"percent_charged": "42.547",
|
|
||||||
"status": "charging"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"time": "1328809305",
|
|
||||||
"percent_charged": "42.020",
|
|
||||||
"status": "charging"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"history_rate": [
|
|
||||||
{
|
|
||||||
"time": "1328809335",
|
|
||||||
"percent_charged": "31.691",
|
|
||||||
"status": "charging"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.upower.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,96 +1,108 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.uptime"></a>
|
||||||
|
|
||||||
# jc.parsers.uptime
|
# jc.parsers.uptime
|
||||||
|
|
||||||
jc - JSON CLI output utility `uptime` command output parser
|
jc - JSON CLI output utility `uptime` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ uptime | jc --uptime
|
$ uptime | jc --uptime
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc uptime
|
$ jc uptime
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('uptime', uptime_command_output)
|
result = jc.parse('uptime', uptime_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.uptime
|
import jc.parsers.uptime
|
||||||
result = jc.parsers.uptime.parse(uptime_command_output)
|
result = jc.parsers.uptime.parse(uptime_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"time": string,
|
"time": string,
|
||||||
"time_hour": integer,
|
"time_hour": integer,
|
||||||
"time_minute": integer,
|
"time_minute": integer,
|
||||||
"time_second": integer, # null if not displayed
|
"time_second": integer, # null if not displayed
|
||||||
"uptime": string,
|
"uptime": string,
|
||||||
"uptime_days": integer,
|
"uptime_days": integer,
|
||||||
"uptime_hours": integer,
|
"uptime_hours": integer,
|
||||||
"uptime_minutes": integer,
|
"uptime_minutes": integer,
|
||||||
"uptime_total_seconds": integer,
|
"uptime_total_seconds": integer,
|
||||||
"users": integer,
|
"users": integer,
|
||||||
"load_1m": float,
|
"load_1m": float,
|
||||||
"load_5m": float,
|
"load_5m": float,
|
||||||
"load_15m": float
|
"load_15m": float
|
||||||
}
|
}
|
||||||
|
|
||||||
Example:
|
**Example**:
|
||||||
|
|
||||||
$ uptime | jc --uptime -p
|
|
||||||
{
|
$ uptime | jc --uptime -p
|
||||||
"time": "11:35",
|
{
|
||||||
"uptime": "3 days, 4:03",
|
- `"time"` - "11:35",
|
||||||
"users": 5,
|
- `"uptime"` - "3 days, 4:03",
|
||||||
"load_1m": 1.88,
|
- `"users"` - 5,
|
||||||
"load_5m": 2.0,
|
- `"load_1m"` - 1.88,
|
||||||
"load_15m": 1.94,
|
- `"load_5m"` - 2.0,
|
||||||
"time_hour": 11,
|
- `"load_15m"` - 1.94,
|
||||||
"time_minute": 35,
|
- `"time_hour"` - 11,
|
||||||
"time_second": null,
|
- `"time_minute"` - 35,
|
||||||
"uptime_days": 3,
|
- `"time_second"` - null,
|
||||||
"uptime_hours": 4,
|
- `"uptime_days"` - 3,
|
||||||
"uptime_minutes": 3,
|
- `"uptime_hours"` - 4,
|
||||||
"uptime_total_seconds": 273780
|
- `"uptime_minutes"` - 3,
|
||||||
}
|
- `"uptime_total_seconds"` - 273780
|
||||||
|
}
|
||||||
|
|
||||||
|
$ uptime | jc --uptime -p -r
|
||||||
|
{
|
||||||
|
- `"time"` - "11:36",
|
||||||
|
- `"uptime"` - "3 days, 4:04",
|
||||||
|
- `"users"` - "5",
|
||||||
|
- `"load_1m"` - "1.88",
|
||||||
|
- `"load_5m"` - "1.99",
|
||||||
|
- `"load_15m"` - "1.94"
|
||||||
|
}
|
||||||
|
|
||||||
$ uptime | jc --uptime -p -r
|
<a id="jc.parsers.uptime.info"></a>
|
||||||
{
|
|
||||||
"time": "11:36",
|
|
||||||
"uptime": "3 days, 4:04",
|
|
||||||
"users": "5",
|
|
||||||
"load_1m": "1.88",
|
|
||||||
"load_5m": "1.99",
|
|
||||||
"load_15m": "1.94"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.uptime.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data
|
|
||||||
|
Dictionary. Raw or processed structured data
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.vmstat"></a>
|
||||||
|
|
||||||
# jc.parsers.vmstat
|
# jc.parsers.vmstat
|
||||||
|
|
||||||
jc - JSON CLI output utility `vmstat` command output parser
|
jc - JSON CLI output utility `vmstat` command output parser
|
||||||
|
|
||||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||||
@ -13,145 +15,155 @@ available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ vmstat | jc --vmstat
|
$ vmstat | jc --vmstat
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc vmstat
|
$ jc vmstat
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('vmstat', vmstat_command_output)
|
result = jc.parse('vmstat', vmstat_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.vmstat
|
import jc.parsers.vmstat
|
||||||
result = jc.parsers.vmstat.parse(vmstat_command_output)
|
result = jc.parsers.vmstat.parse(vmstat_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"runnable_procs": integer,
|
"runnable_procs": integer,
|
||||||
"uninterruptible_sleeping_procs": integer,
|
"uninterruptible_sleeping_procs": integer,
|
||||||
"virtual_mem_used": integer,
|
"virtual_mem_used": integer,
|
||||||
"free_mem": integer,
|
"free_mem": integer,
|
||||||
"buffer_mem": integer,
|
"buffer_mem": integer,
|
||||||
"cache_mem": integer,
|
"cache_mem": integer,
|
||||||
"inactive_mem": integer,
|
"inactive_mem": integer,
|
||||||
"active_mem": integer,
|
"active_mem": integer,
|
||||||
"swap_in": integer,
|
"swap_in": integer,
|
||||||
"swap_out": integer,
|
"swap_out": integer,
|
||||||
"blocks_in": integer,
|
"blocks_in": integer,
|
||||||
"blocks_out": integer,
|
"blocks_out": integer,
|
||||||
"interrupts": integer,
|
"interrupts": integer,
|
||||||
"context_switches": integer,
|
"context_switches": integer,
|
||||||
"user_time": integer,
|
"user_time": integer,
|
||||||
"system_time": integer,
|
"system_time": integer,
|
||||||
"idle_time": integer,
|
"idle_time": integer,
|
||||||
"io_wait_time": integer,
|
"io_wait_time": integer,
|
||||||
"stolen_time": integer,
|
"stolen_time": integer,
|
||||||
"disk": string,
|
"disk": string,
|
||||||
"total_reads": integer,
|
"total_reads": integer,
|
||||||
"merged_reads": integer,
|
"merged_reads": integer,
|
||||||
"sectors_read": integer,
|
"sectors_read": integer,
|
||||||
"reading_ms": integer,
|
"reading_ms": integer,
|
||||||
"total_writes": integer,
|
"total_writes": integer,
|
||||||
"merged_writes": integer,
|
"merged_writes": integer,
|
||||||
"sectors_written": integer,
|
"sectors_written": integer,
|
||||||
"writing_ms": integer,
|
"writing_ms": integer,
|
||||||
"current_io": integer,
|
"current_io": integer,
|
||||||
"io_seconds": integer,
|
"io_seconds": integer,
|
||||||
"timestamp": string,
|
"timestamp": string,
|
||||||
"timezone": string,
|
"timezone": string,
|
||||||
"epoch": integer, # [0]
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer # [1]
|
"epoch_utc": integer # [1]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] naive timestamp if -t flag is used
|
[0] naive timestamp if -t flag is used
|
||||||
[1] aware timestamp if -t flag is used and UTC TZ
|
[1] aware timestamp if -t flag is used and UTC TZ
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ vmstat | jc --vmstat -p
|
|
||||||
[
|
$ vmstat | jc --vmstat -p
|
||||||
{
|
[
|
||||||
"runnable_procs": 2,
|
{
|
||||||
"uninterruptible_sleeping_procs": 0,
|
- `"runnable_procs"` - 2,
|
||||||
"virtual_mem_used": 0,
|
- `"uninterruptible_sleeping_procs"` - 0,
|
||||||
"free_mem": 2794468,
|
- `"virtual_mem_used"` - 0,
|
||||||
"buffer_mem": 2108,
|
- `"free_mem"` - 2794468,
|
||||||
"cache_mem": 741208,
|
- `"buffer_mem"` - 2108,
|
||||||
"inactive_mem": null,
|
- `"cache_mem"` - 741208,
|
||||||
"active_mem": null,
|
- `"inactive_mem"` - null,
|
||||||
"swap_in": 0,
|
- `"active_mem"` - null,
|
||||||
"swap_out": 0,
|
- `"swap_in"` - 0,
|
||||||
"blocks_in": 1,
|
- `"swap_out"` - 0,
|
||||||
"blocks_out": 3,
|
- `"blocks_in"` - 1,
|
||||||
"interrupts": 29,
|
- `"blocks_out"` - 3,
|
||||||
"context_switches": 57,
|
- `"interrupts"` - 29,
|
||||||
"user_time": 0,
|
- `"context_switches"` - 57,
|
||||||
"system_time": 0,
|
- `"user_time"` - 0,
|
||||||
"idle_time": 99,
|
- `"system_time"` - 0,
|
||||||
"io_wait_time": 0,
|
- `"idle_time"` - 99,
|
||||||
"stolen_time": 0,
|
- `"io_wait_time"` - 0,
|
||||||
"timestamp": null,
|
- `"stolen_time"` - 0,
|
||||||
"timezone": null
|
- `"timestamp"` - null,
|
||||||
}
|
- `"timezone"` - null
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ vmstat | jc --vmstat -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"runnable_procs"` - "2",
|
||||||
|
- `"uninterruptible_sleeping_procs"` - "0",
|
||||||
|
- `"virtual_mem_used"` - "0",
|
||||||
|
- `"free_mem"` - "2794468",
|
||||||
|
- `"buffer_mem"` - "2108",
|
||||||
|
- `"cache_mem"` - "741208",
|
||||||
|
- `"inactive_mem"` - null,
|
||||||
|
- `"active_mem"` - null,
|
||||||
|
- `"swap_in"` - "0",
|
||||||
|
- `"swap_out"` - "0",
|
||||||
|
- `"blocks_in"` - "1",
|
||||||
|
- `"blocks_out"` - "3",
|
||||||
|
- `"interrupts"` - "29",
|
||||||
|
- `"context_switches"` - "57",
|
||||||
|
- `"user_time"` - "0",
|
||||||
|
- `"system_time"` - "0",
|
||||||
|
- `"idle_time"` - "99",
|
||||||
|
- `"io_wait_time"` - "0",
|
||||||
|
- `"stolen_time"` - "0",
|
||||||
|
- `"timestamp"` - null,
|
||||||
|
- `"timezone"` - null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ vmstat | jc --vmstat -p -r
|
<a id="jc.parsers.vmstat.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"runnable_procs": "2",
|
|
||||||
"uninterruptible_sleeping_procs": "0",
|
|
||||||
"virtual_mem_used": "0",
|
|
||||||
"free_mem": "2794468",
|
|
||||||
"buffer_mem": "2108",
|
|
||||||
"cache_mem": "741208",
|
|
||||||
"inactive_mem": null,
|
|
||||||
"active_mem": null,
|
|
||||||
"swap_in": "0",
|
|
||||||
"swap_out": "0",
|
|
||||||
"blocks_in": "1",
|
|
||||||
"blocks_out": "3",
|
|
||||||
"interrupts": "29",
|
|
||||||
"context_switches": "57",
|
|
||||||
"user_time": "0",
|
|
||||||
"system_time": "0",
|
|
||||||
"idle_time": "99",
|
|
||||||
"io_wait_time": "0",
|
|
||||||
"stolen_time": "0",
|
|
||||||
"timestamp": null,
|
|
||||||
"timezone": null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.vmstat.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.vmstat_s"></a>
|
||||||
|
|
||||||
|
# jc.parsers.vmstat\_s
|
||||||
|
|
||||||
# jc.parsers.vmstat_s
|
|
||||||
jc - JSON CLI output utility `vmstat` command output streaming parser
|
jc - JSON CLI output utility `vmstat` command output streaming parser
|
||||||
|
|
||||||
> This streaming parser outputs JSON Lines
|
> This streaming parser outputs JSON Lines
|
||||||
@ -15,7 +17,7 @@ available if the timezone field is UTC.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ vmstat | jc --vmstat-s
|
$ vmstat | jc --vmstat-s
|
||||||
|
|
||||||
> Note: When piping `jc` converted `vmstat` output to other processes it may
|
> Note: When piping `jc` converted `vmstat` output to other processes it may
|
||||||
appear the output is hanging due to the OS pipe buffers. This is because
|
appear the output is hanging due to the OS pipe buffers. This is because
|
||||||
@ -26,113 +28,125 @@ for more information.
|
|||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parse('vmstat_s', vmstat_command_output.splitlines())
|
result = jc.parse('vmstat_s', vmstat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.vmstat_s
|
import jc.parsers.vmstat_s
|
||||||
# result is an iterable object (generator)
|
# result is an iterable object (generator)
|
||||||
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines())
|
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines())
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
{
|
{
|
||||||
"runnable_procs": integer,
|
"runnable_procs": integer,
|
||||||
"uninterruptible_sleeping_procs": integer,
|
"uninterruptible_sleeping_procs": integer,
|
||||||
"virtual_mem_used": integer,
|
"virtual_mem_used": integer,
|
||||||
"free_mem": integer,
|
"free_mem": integer,
|
||||||
"buffer_mem": integer,
|
"buffer_mem": integer,
|
||||||
"cache_mem": integer,
|
"cache_mem": integer,
|
||||||
"inactive_mem": integer,
|
"inactive_mem": integer,
|
||||||
"active_mem": integer,
|
"active_mem": integer,
|
||||||
"swap_in": integer,
|
"swap_in": integer,
|
||||||
"swap_out": integer,
|
"swap_out": integer,
|
||||||
"blocks_in": integer,
|
"blocks_in": integer,
|
||||||
"blocks_out": integer,
|
"blocks_out": integer,
|
||||||
"interrupts": integer,
|
"interrupts": integer,
|
||||||
"context_switches": integer,
|
"context_switches": integer,
|
||||||
"user_time": integer,
|
"user_time": integer,
|
||||||
"system_time": integer,
|
"system_time": integer,
|
||||||
"idle_time": integer,
|
"idle_time": integer,
|
||||||
"io_wait_time": integer,
|
"io_wait_time": integer,
|
||||||
"stolen_time": integer,
|
"stolen_time": integer,
|
||||||
"disk": string,
|
"disk": string,
|
||||||
"total_reads": integer,
|
"total_reads": integer,
|
||||||
"merged_reads": integer,
|
"merged_reads": integer,
|
||||||
"sectors_read": integer,
|
"sectors_read": integer,
|
||||||
"reading_ms": integer,
|
"reading_ms": integer,
|
||||||
"total_writes": integer,
|
"total_writes": integer,
|
||||||
"merged_writes": integer,
|
"merged_writes": integer,
|
||||||
"sectors_written": integer,
|
"sectors_written": integer,
|
||||||
"writing_ms": integer,
|
"writing_ms": integer,
|
||||||
"current_io": integer,
|
"current_io": integer,
|
||||||
"io_seconds": integer,
|
"io_seconds": integer,
|
||||||
"timestamp": string,
|
"timestamp": string,
|
||||||
"timezone": string,
|
"timezone": string,
|
||||||
"epoch": integer, # [0]
|
"epoch": integer, # [0]
|
||||||
"epoch_utc": integer # [1]
|
"epoch_utc": integer # [1]
|
||||||
|
|
||||||
# Below object only exists if using -qq or ignore_exceptions=True
|
# Below object only exists if using -qq or ignore_exceptions=True
|
||||||
|
|
||||||
"_jc_meta":
|
"_jc_meta":
|
||||||
{
|
{
|
||||||
"success": boolean, # [2]
|
"success": boolean, # [2]
|
||||||
"error": string, # [3]
|
"error": string, # [3]
|
||||||
"line": string # [3]
|
"line": string # [3]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[0] naive timestamp if -t flag is used
|
[0] naive timestamp if -t flag is used
|
||||||
[1] aware timestamp if -t flag is used and UTC TZ
|
[1] aware timestamp if -t flag is used and UTC TZ
|
||||||
[2] false if error parsing
|
[2] false if error parsing
|
||||||
[3] exists if "success" is false
|
[3] exists if "success" is false
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ vmstat | jc --vmstat-s
|
|
||||||
{"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem...}
|
$ vmstat | jc --vmstat-s
|
||||||
...
|
{"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem...}
|
||||||
|
...
|
||||||
|
|
||||||
|
$ vmstat | jc --vmstat-s -r
|
||||||
|
{"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...}
|
||||||
|
...
|
||||||
|
|
||||||
$ vmstat | jc --vmstat-s -r
|
<a id="jc.parsers.vmstat_s.info"></a>
|
||||||
{"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...}
|
|
||||||
...
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.vmstat_s.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (iterable) line-based text data to parse
|
|
||||||
(e.g. sys.stdin or str.splitlines())
|
- `data` - (iterable) line-based text data to parse
|
||||||
|
(e.g. sys.stdin or str.splitlines())
|
||||||
|
|
||||||
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
|
||||||
|
|
||||||
|
|
||||||
raw: (boolean) unprocessed output if True
|
**Yields**:
|
||||||
quiet: (boolean) suppress warning messages if True
|
|
||||||
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
|
||||||
|
|
||||||
Yields:
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
**Returns**:
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
Iterator object
|
||||||
Iterator object
|
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux
|
Compatibility: linux
|
||||||
|
@ -1,134 +1,146 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.w"></a>
|
||||||
|
|
||||||
# jc.parsers.w
|
# jc.parsers.w
|
||||||
|
|
||||||
jc - JSON CLI output utility `w` command output parser
|
jc - JSON CLI output utility `w` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ w | jc --w
|
$ w | jc --w
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc w
|
$ jc w
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('w', w_command_output)
|
result = jc.parse('w', w_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.w
|
import jc.parsers.w
|
||||||
result = jc.parsers.w.parse(w_command_output)
|
result = jc.parsers.w.parse(w_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": string, # '-' = null
|
"user": string, # '-' = null
|
||||||
"tty": string, # '-' = null
|
"tty": string, # '-' = null
|
||||||
"from": string, # '-' = null
|
"from": string, # '-' = null
|
||||||
"login_at": string, # '-' = null
|
"login_at": string, # '-' = null
|
||||||
"idle": string, # '-' = null
|
"idle": string, # '-' = null
|
||||||
"jcpu": string,
|
"jcpu": string,
|
||||||
"pcpu": string,
|
"pcpu": string,
|
||||||
"what": string # '-' = null
|
"what": string # '-' = null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ w | jc --w -p
|
|
||||||
[
|
$ w | jc --w -p
|
||||||
{
|
[
|
||||||
"user": "root",
|
{
|
||||||
"tty": "tty1",
|
- `"user"` - "root",
|
||||||
"from": null,
|
- `"tty"` - "tty1",
|
||||||
"login_at": "07:49",
|
- `"from"` - null,
|
||||||
"idle": "1:15m",
|
- `"login_at"` - "07:49",
|
||||||
"jcpu": "0.00s",
|
- `"idle"` - "1:15m",
|
||||||
"pcpu": "0.00s",
|
- `"jcpu"` - "0.00s",
|
||||||
"what": "-bash"
|
- `"pcpu"` - "0.00s",
|
||||||
},
|
- `"what"` - "-bash"
|
||||||
{
|
},
|
||||||
"user": "root",
|
{
|
||||||
"tty": "ttyS0",
|
- `"user"` - "root",
|
||||||
"from": null,
|
- `"tty"` - "ttyS0",
|
||||||
"login_at": "06:24",
|
- `"from"` - null,
|
||||||
"idle": "0.00s",
|
- `"login_at"` - "06:24",
|
||||||
"jcpu": "0.43s",
|
- `"idle"` - "0.00s",
|
||||||
"pcpu": "0.00s",
|
- `"jcpu"` - "0.43s",
|
||||||
"what": "w"
|
- `"pcpu"` - "0.00s",
|
||||||
},
|
- `"what"` - "w"
|
||||||
{
|
},
|
||||||
"user": "root",
|
{
|
||||||
"tty": "pts/0",
|
- `"user"` - "root",
|
||||||
"from": "192.168.71.1",
|
- `"tty"` - "pts/0",
|
||||||
"login_at": "06:29",
|
- `"from"` - "192.168.71.1",
|
||||||
"idle": "2:35m",
|
- `"login_at"` - "06:29",
|
||||||
"jcpu": "0.00s",
|
- `"idle"` - "2:35m",
|
||||||
"pcpu": "0.00s",
|
- `"jcpu"` - "0.00s",
|
||||||
"what": "-bash"
|
- `"pcpu"` - "0.00s",
|
||||||
}
|
- `"what"` - "-bash"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ w | jc --w -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"user"` - "kbrazil",
|
||||||
|
- `"tty"` - "tty1",
|
||||||
|
- `"from"` - "-",
|
||||||
|
- `"login_at"` - "07:49",
|
||||||
|
- `"idle"` - "1:16m",
|
||||||
|
- `"jcpu"` - "0.00s",
|
||||||
|
- `"pcpu"` - "0.00s",
|
||||||
|
- `"what"` - "-bash"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "kbrazil",
|
||||||
|
- `"tty"` - "ttyS0",
|
||||||
|
- `"from"` - "-",
|
||||||
|
- `"login_at"` - "06:24",
|
||||||
|
- `"idle"` - "2.00s",
|
||||||
|
- `"jcpu"` - "0.46s",
|
||||||
|
- `"pcpu"` - "0.00s",
|
||||||
|
- `"what"` - "w"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "kbrazil",
|
||||||
|
- `"tty"` - "pts/0",
|
||||||
|
- `"from"` - "192.168.71.1",
|
||||||
|
- `"login_at"` - "06:29",
|
||||||
|
- `"idle"` - "2:36m",
|
||||||
|
- `"jcpu"` - "0.00s",
|
||||||
|
- `"pcpu"` - "0.00s",
|
||||||
|
- `"what"` - "-bash"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ w | jc --w -p -r
|
<a id="jc.parsers.w.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"user": "kbrazil",
|
|
||||||
"tty": "tty1",
|
|
||||||
"from": "-",
|
|
||||||
"login_at": "07:49",
|
|
||||||
"idle": "1:16m",
|
|
||||||
"jcpu": "0.00s",
|
|
||||||
"pcpu": "0.00s",
|
|
||||||
"what": "-bash"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "kbrazil",
|
|
||||||
"tty": "ttyS0",
|
|
||||||
"from": "-",
|
|
||||||
"login_at": "06:24",
|
|
||||||
"idle": "2.00s",
|
|
||||||
"jcpu": "0.46s",
|
|
||||||
"pcpu": "0.00s",
|
|
||||||
"what": "w"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "kbrazil",
|
|
||||||
"tty": "pts/0",
|
|
||||||
"from": "192.168.71.1",
|
|
||||||
"login_at": "06:29",
|
|
||||||
"idle": "2:36m",
|
|
||||||
"jcpu": "0.00s",
|
|
||||||
"pcpu": "0.00s",
|
|
||||||
"what": "-bash"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.w.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,85 +1,97 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.wc"></a>
|
||||||
|
|
||||||
# jc.parsers.wc
|
# jc.parsers.wc
|
||||||
|
|
||||||
jc - JSON CLI output utility `wc` command output parser
|
jc - JSON CLI output utility `wc` command output parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ wc file.txt | jc --wc
|
$ wc file.txt | jc --wc
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc wc file.txt
|
$ jc wc file.txt
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('wc', wc_command_output)
|
result = jc.parse('wc', wc_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.wc
|
import jc.parsers.wc
|
||||||
result = jc.parsers.wc.parse(wc_command_output)
|
result = jc.parsers.wc.parse(wc_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"filename": string,
|
"filename": string,
|
||||||
"lines": integer,
|
"lines": integer,
|
||||||
"words": integer,
|
"words": integer,
|
||||||
"characters": integer
|
"characters": integer
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ wc * | jc --wc -p
|
|
||||||
[
|
$ wc * | jc --wc -p
|
||||||
{
|
[
|
||||||
"filename": "airport-I.json",
|
{
|
||||||
"lines": 1,
|
- `"filename"` - "airport-I.json",
|
||||||
"words": 30,
|
- `"lines"` - 1,
|
||||||
"characters": 307
|
- `"words"` - 30,
|
||||||
},
|
- `"characters"` - 307
|
||||||
{
|
},
|
||||||
"filename": "airport-I.out",
|
{
|
||||||
"lines": 15,
|
- `"filename"` - "airport-I.out",
|
||||||
"words": 33,
|
- `"lines"` - 15,
|
||||||
"characters": 348
|
- `"words"` - 33,
|
||||||
},
|
- `"characters"` - 348
|
||||||
{
|
},
|
||||||
"filename": "airport-s.json",
|
{
|
||||||
"lines": 1,
|
- `"filename"` - "airport-s.json",
|
||||||
"words": 202,
|
- `"lines"` - 1,
|
||||||
"characters": 2152
|
- `"words"` - 202,
|
||||||
},
|
- `"characters"` - 2152
|
||||||
...
|
},
|
||||||
]
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
<a id="jc.parsers.wc.info"></a>
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.wc.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.who"></a>
|
||||||
|
|
||||||
# jc.parsers.who
|
# jc.parsers.who
|
||||||
|
|
||||||
jc - JSON CLI output utility `who` command output parser
|
jc - JSON CLI output utility `who` command output parser
|
||||||
|
|
||||||
Accepts any of the following who options (or no options): `-aTH`
|
Accepts any of the following who options (or no options): `-aTH`
|
||||||
@ -10,157 +12,167 @@ time of the system the parser is run on)
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ who | jc --who
|
$ who | jc --who
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc who
|
$ jc who
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('who', who_command_output)
|
result = jc.parse('who', who_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.who
|
import jc.parsers.who
|
||||||
result = jc.parsers.who.parse(who_command_output)
|
result = jc.parsers.who.parse(who_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"user": string,
|
"user": string,
|
||||||
"event": string,
|
"event": string,
|
||||||
"writeable_tty": string,
|
"writeable_tty": string,
|
||||||
"tty": string,
|
"tty": string,
|
||||||
"time": string,
|
"time": string,
|
||||||
"epoch": integer, # [0]
|
"epoch": integer, # [0]
|
||||||
"idle": string,
|
"idle": string,
|
||||||
"pid": integer,
|
"pid": integer,
|
||||||
"from": string,
|
"from": string,
|
||||||
"comment": string
|
"comment": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
[0] naive timestamp. null if time cannot be converted
|
[0] naive timestamp. null if time cannot be converted
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ who -a | jc --who -p
|
|
||||||
[
|
$ who -a | jc --who -p
|
||||||
{
|
[
|
||||||
"event": "reboot",
|
{
|
||||||
"time": "Feb 7 23:31",
|
- `"event"` - "reboot",
|
||||||
"pid": 1,
|
- `"time"` - "Feb 7 23:31",
|
||||||
"epoch": null
|
- `"pid"` - 1,
|
||||||
},
|
- `"epoch"` - null
|
||||||
{
|
},
|
||||||
"user": "joeuser",
|
{
|
||||||
"writeable_tty": "-",
|
- `"user"` - "joeuser",
|
||||||
"tty": "console",
|
- `"writeable_tty"` - "-",
|
||||||
"time": "Feb 7 23:32",
|
- `"tty"` - "console",
|
||||||
"idle": "old",
|
- `"time"` - "Feb 7 23:32",
|
||||||
"pid": 105,
|
- `"idle"` - "old",
|
||||||
"epoch": null
|
- `"pid"` - 105,
|
||||||
},
|
- `"epoch"` - null
|
||||||
{
|
},
|
||||||
"user": "joeuser",
|
{
|
||||||
"writeable_tty": "+",
|
- `"user"` - "joeuser",
|
||||||
"tty": "ttys000",
|
- `"writeable_tty"` - "+",
|
||||||
"time": "Feb 13 16:44",
|
- `"tty"` - "ttys000",
|
||||||
"idle": ".",
|
- `"time"` - "Feb 13 16:44",
|
||||||
"pid": 51217,
|
- `"idle"` - ".",
|
||||||
"comment": "term=0 exit=0",
|
- `"pid"` - 51217,
|
||||||
"epoch": null
|
- `"comment"` - "term=0 exit=0",
|
||||||
},
|
- `"epoch"` - null
|
||||||
{
|
},
|
||||||
"user": "joeuser",
|
{
|
||||||
"writeable_tty": "?",
|
- `"user"` - "joeuser",
|
||||||
"tty": "ttys003",
|
- `"writeable_tty"` - "?",
|
||||||
"time": "Feb 28 08:59",
|
- `"tty"` - "ttys003",
|
||||||
"idle": "01:36",
|
- `"time"` - "Feb 28 08:59",
|
||||||
"pid": 41402,
|
- `"idle"` - "01:36",
|
||||||
"epoch": null
|
- `"pid"` - 41402,
|
||||||
},
|
- `"epoch"` - null
|
||||||
{
|
},
|
||||||
"user": "joeuser",
|
{
|
||||||
"writeable_tty": "+",
|
- `"user"` - "joeuser",
|
||||||
"tty": "ttys004",
|
- `"writeable_tty"` - "+",
|
||||||
"time": "Mar 1 16:35",
|
- `"tty"` - "ttys004",
|
||||||
"idle": ".",
|
- `"time"` - "Mar 1 16:35",
|
||||||
"pid": 15679,
|
- `"idle"` - ".",
|
||||||
"from": "192.168.1.5",
|
- `"pid"` - 15679,
|
||||||
"epoch": null
|
- `"from"` - "192.168.1.5",
|
||||||
}
|
- `"epoch"` - null
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ who -a | jc --who -p -r
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"event"` - "reboot",
|
||||||
|
- `"time"` - "Feb 7 23:31",
|
||||||
|
- `"pid"` - "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "joeuser",
|
||||||
|
- `"writeable_tty"` - "-",
|
||||||
|
- `"tty"` - "console",
|
||||||
|
- `"time"` - "Feb 7 23:32",
|
||||||
|
- `"idle"` - "old",
|
||||||
|
- `"pid"` - "105"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "joeuser",
|
||||||
|
- `"writeable_tty"` - "+",
|
||||||
|
- `"tty"` - "ttys000",
|
||||||
|
- `"time"` - "Feb 13 16:44",
|
||||||
|
- `"idle"` - ".",
|
||||||
|
- `"pid"` - "51217",
|
||||||
|
- `"comment"` - "term=0 exit=0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "joeuser",
|
||||||
|
- `"writeable_tty"` - "?",
|
||||||
|
- `"tty"` - "ttys003",
|
||||||
|
- `"time"` - "Feb 28 08:59",
|
||||||
|
- `"idle"` - "01:36",
|
||||||
|
- `"pid"` - "41402"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"user"` - "joeuser",
|
||||||
|
- `"writeable_tty"` - "+",
|
||||||
|
- `"tty"` - "ttys004",
|
||||||
|
- `"time"` - "Mar 1 16:35",
|
||||||
|
- `"idle"` - ".",
|
||||||
|
- `"pid"` - "15679",
|
||||||
|
- `"from"` - "192.168.1.5"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ who -a | jc --who -p -r
|
<a id="jc.parsers.who.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"event": "reboot",
|
|
||||||
"time": "Feb 7 23:31",
|
|
||||||
"pid": "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "joeuser",
|
|
||||||
"writeable_tty": "-",
|
|
||||||
"tty": "console",
|
|
||||||
"time": "Feb 7 23:32",
|
|
||||||
"idle": "old",
|
|
||||||
"pid": "105"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "joeuser",
|
|
||||||
"writeable_tty": "+",
|
|
||||||
"tty": "ttys000",
|
|
||||||
"time": "Feb 13 16:44",
|
|
||||||
"idle": ".",
|
|
||||||
"pid": "51217",
|
|
||||||
"comment": "term=0 exit=0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "joeuser",
|
|
||||||
"writeable_tty": "?",
|
|
||||||
"tty": "ttys003",
|
|
||||||
"time": "Feb 28 08:59",
|
|
||||||
"idle": "01:36",
|
|
||||||
"pid": "41402"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"user": "joeuser",
|
|
||||||
"writeable_tty": "+",
|
|
||||||
"tty": "ttys004",
|
|
||||||
"time": "Mar 1 16:35",
|
|
||||||
"idle": ".",
|
|
||||||
"pid": "15679",
|
|
||||||
"from": "192.168.1.5"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.who.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, cygwin, aix, freebsd
|
||||||
|
@ -1,101 +1,113 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.xml"></a>
|
||||||
|
|
||||||
# jc.parsers.xml
|
# jc.parsers.xml
|
||||||
|
|
||||||
jc - JSON CLI output utility `XML` file parser
|
jc - JSON CLI output utility `XML` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat foo.xml | jc --xml
|
$ cat foo.xml | jc --xml
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('xml', xml_file_output)
|
result = jc.parse('xml', xml_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.xml
|
import jc.parsers.xml
|
||||||
result = jc.parsers.xml.parse(xml_file_output)
|
result = jc.parsers.xml.parse(xml_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
XML Document converted to a Dictionary
|
XML Document converted to a Dictionary
|
||||||
See https://github.com/martinblech/xmltodict for details
|
See https://github.com/martinblech/xmltodict for details
|
||||||
|
|
||||||
{
|
{
|
||||||
"key1": string/object,
|
"key1": string/object,
|
||||||
"key2": string/object
|
"key2": string/object
|
||||||
}
|
}
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat cd_catalog.xml
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
$ cat cd_catalog.xml
|
||||||
<CATALOG>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CD>
|
<CATALOG>
|
||||||
<TITLE>Empire Burlesque</TITLE>
|
<CD>
|
||||||
<ARTIST>Bob Dylan</ARTIST>
|
<TITLE>Empire Burlesque</TITLE>
|
||||||
<COUNTRY>USA</COUNTRY>
|
<ARTIST>Bob Dylan</ARTIST>
|
||||||
<COMPANY>Columbia</COMPANY>
|
<COUNTRY>USA</COUNTRY>
|
||||||
<PRICE>10.90</PRICE>
|
<COMPANY>Columbia</COMPANY>
|
||||||
<YEAR>1985</YEAR>
|
<PRICE>10.90</PRICE>
|
||||||
</CD>
|
<YEAR>1985</YEAR>
|
||||||
<CD>
|
</CD>
|
||||||
<TITLE>Hide your heart</TITLE>
|
<CD>
|
||||||
<ARTIST>Bonnie Tyler</ARTIST>
|
<TITLE>Hide your heart</TITLE>
|
||||||
<COUNTRY>UK</COUNTRY>
|
<ARTIST>Bonnie Tyler</ARTIST>
|
||||||
<COMPANY>CBS Records</COMPANY>
|
<COUNTRY>UK</COUNTRY>
|
||||||
<PRICE>9.90</PRICE>
|
<COMPANY>CBS Records</COMPANY>
|
||||||
<YEAR>1988</YEAR>
|
<PRICE>9.90</PRICE>
|
||||||
</CD>
|
<YEAR>1988</YEAR>
|
||||||
...
|
</CD>
|
||||||
|
...
|
||||||
|
|
||||||
|
$ cat cd_catalog.xml | jc --xml -p
|
||||||
|
{
|
||||||
|
- `"CATALOG"` - {
|
||||||
|
- `"CD"` - [
|
||||||
|
{
|
||||||
|
- `"TITLE"` - "Empire Burlesque",
|
||||||
|
- `"ARTIST"` - "Bob Dylan",
|
||||||
|
- `"COUNTRY"` - "USA",
|
||||||
|
- `"COMPANY"` - "Columbia",
|
||||||
|
- `"PRICE"` - "10.90",
|
||||||
|
- `"YEAR"` - "1985"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"TITLE"` - "Hide your heart",
|
||||||
|
- `"ARTIST"` - "Bonnie Tyler",
|
||||||
|
- `"COUNTRY"` - "UK",
|
||||||
|
- `"COMPANY"` - "CBS Records",
|
||||||
|
- `"PRICE"` - "9.90",
|
||||||
|
- `"YEAR"` - "1988"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
$ cat cd_catalog.xml | jc --xml -p
|
<a id="jc.parsers.xml.info"></a>
|
||||||
{
|
|
||||||
"CATALOG": {
|
|
||||||
"CD": [
|
|
||||||
{
|
|
||||||
"TITLE": "Empire Burlesque",
|
|
||||||
"ARTIST": "Bob Dylan",
|
|
||||||
"COUNTRY": "USA",
|
|
||||||
"COMPANY": "Columbia",
|
|
||||||
"PRICE": "10.90",
|
|
||||||
"YEAR": "1985"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"TITLE": "Hide your heart",
|
|
||||||
"ARTIST": "Bonnie Tyler",
|
|
||||||
"COUNTRY": "UK",
|
|
||||||
"COMPANY": "CBS Records",
|
|
||||||
"PRICE": "9.90",
|
|
||||||
"YEAR": "1988"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.xml.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
|
||||||
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,115 +1,127 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.yaml"></a>
|
||||||
|
|
||||||
# jc.parsers.yaml
|
# jc.parsers.yaml
|
||||||
|
|
||||||
jc - JSON CLI output utility `YAML` file parser
|
jc - JSON CLI output utility `YAML` file parser
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ cat foo.yaml | jc --yaml
|
$ cat foo.yaml | jc --yaml
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('yaml', yaml_file_output)
|
result = jc.parse('yaml', yaml_file_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.yaml
|
import jc.parsers.yaml
|
||||||
result = jc.parsers.yaml.parse(yaml_file_output)
|
result = jc.parsers.yaml.parse(yaml_file_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
YAML Document converted to a Dictionary
|
YAML Document converted to a Dictionary
|
||||||
See https://pypi.org/project/ruamel.yaml for details
|
See https://pypi.org/project/ruamel.yaml for details
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"key1": string/int/float/boolean/null/array/object,
|
"key1": string/int/float/boolean/null/array/object,
|
||||||
"key2": string/int/float/boolean/null/array/object
|
"key2": string/int/float/boolean/null/array/object
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ cat istio-mtls-permissive.yaml
|
|
||||||
apiVersion: "authentication.istio.io/v1alpha1"
|
$ cat istio-mtls-permissive.yaml
|
||||||
kind: "Policy"
|
- `apiVersion` - "authentication.istio.io/v1alpha1"
|
||||||
metadata:
|
- `kind` - "Policy"
|
||||||
name: "default"
|
metadata:
|
||||||
namespace: "default"
|
- `name` - "default"
|
||||||
spec:
|
- `namespace` - "default"
|
||||||
peers:
|
spec:
|
||||||
- mtls: {}
|
peers:
|
||||||
---
|
- mtls: {}
|
||||||
apiVersion: "networking.istio.io/v1alpha3"
|
---
|
||||||
kind: "DestinationRule"
|
- `apiVersion` - "networking.istio.io/v1alpha3"
|
||||||
metadata:
|
- `kind` - "DestinationRule"
|
||||||
name: "default"
|
metadata:
|
||||||
namespace: "default"
|
- `name` - "default"
|
||||||
spec:
|
- `namespace` - "default"
|
||||||
host: "*.default.svc.cluster.local"
|
spec:
|
||||||
trafficPolicy:
|
- `host` - "*.default.svc.cluster.local"
|
||||||
tls:
|
trafficPolicy:
|
||||||
mode: ISTIO_MUTUAL
|
tls:
|
||||||
|
- `mode` - ISTIO_MUTUAL
|
||||||
|
|
||||||
|
$ cat istio-mtls-permissive.yaml | jc --yaml -p
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"apiVersion"` - "authentication.istio.io/v1alpha1",
|
||||||
|
- `"kind"` - "Policy",
|
||||||
|
- `"metadata"` - {
|
||||||
|
- `"name"` - "default",
|
||||||
|
- `"namespace"` - "default"
|
||||||
|
},
|
||||||
|
- `"spec"` - {
|
||||||
|
- `"peers"` - [
|
||||||
|
{
|
||||||
|
- `"mtls"` - {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
- `"apiVersion"` - "networking.istio.io/v1alpha3",
|
||||||
|
- `"kind"` - "DestinationRule",
|
||||||
|
- `"metadata"` - {
|
||||||
|
- `"name"` - "default",
|
||||||
|
- `"namespace"` - "default"
|
||||||
|
},
|
||||||
|
- `"spec"` - {
|
||||||
|
- `"host"` - "*.default.svc.cluster.local",
|
||||||
|
- `"trafficPolicy"` - {
|
||||||
|
- `"tls"` - {
|
||||||
|
- `"mode"` - "ISTIO_MUTUAL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
$ cat istio-mtls-permissive.yaml | jc --yaml -p
|
<a id="jc.parsers.yaml.info"></a>
|
||||||
[
|
|
||||||
{
|
|
||||||
"apiVersion": "authentication.istio.io/v1alpha1",
|
|
||||||
"kind": "Policy",
|
|
||||||
"metadata": {
|
|
||||||
"name": "default",
|
|
||||||
"namespace": "default"
|
|
||||||
},
|
|
||||||
"spec": {
|
|
||||||
"peers": [
|
|
||||||
{
|
|
||||||
"mtls": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"apiVersion": "networking.istio.io/v1alpha3",
|
|
||||||
"kind": "DestinationRule",
|
|
||||||
"metadata": {
|
|
||||||
"name": "default",
|
|
||||||
"namespace": "default"
|
|
||||||
},
|
|
||||||
"spec": {
|
|
||||||
"host": "*.default.svc.cluster.local",
|
|
||||||
"trafficPolicy": {
|
|
||||||
"tls": {
|
|
||||||
"mode": "ISTIO_MUTUAL"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.yaml.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries representing the YAML documents.
|
|
||||||
|
List of Dictionaries representing the YAML documents.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.zipinfo"></a>
|
||||||
|
|
||||||
# jc.parsers.zipinfo
|
# jc.parsers.zipinfo
|
||||||
|
|
||||||
jc - JSON CLI output utility `zipinfo` command output parser
|
jc - JSON CLI output utility `zipinfo` command output parser
|
||||||
|
|
||||||
Options supported:
|
Options supported:
|
||||||
@ -10,101 +12,111 @@ Note: The default listing format.
|
|||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ zipinfo <archive> | jc --zipinfo
|
$ zipinfo <archive> | jc --zipinfo
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ jc zipinfo
|
$ jc zipinfo
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('zipinfo', zipinfo_command_output)
|
result = jc.parse('zipinfo', zipinfo_command_output)
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
import jc.parsers.zipinfo
|
import jc.parsers.zipinfo
|
||||||
result = jc.parsers.zipinfo.parse(zipinfo_command_output)
|
result = jc.parsers.zipinfo.parse(zipinfo_command_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"archive": string,
|
"archive": string,
|
||||||
"size": integer,
|
"size": integer,
|
||||||
"size_unit": string,
|
"size_unit": string,
|
||||||
"number_entries": integer,
|
"number_entries": integer,
|
||||||
"number_files": integer,
|
"number_files": integer,
|
||||||
"bytes_uncompressed": integer,
|
"bytes_uncompressed": integer,
|
||||||
"bytes_compressed": integer,
|
"bytes_compressed": integer,
|
||||||
"percent_compressed": float,
|
"percent_compressed": float,
|
||||||
"files": [
|
"files": [
|
||||||
{
|
{
|
||||||
"flags": string,
|
"flags": string,
|
||||||
"zipversion": string,
|
"zipversion": string,
|
||||||
"zipunder": string
|
"zipunder": string
|
||||||
"filesize": integer,
|
"filesize": integer,
|
||||||
"type": string,
|
"type": string,
|
||||||
"method": string,
|
"method": string,
|
||||||
"date": string,
|
"date": string,
|
||||||
"time": string,
|
"time": string,
|
||||||
"filename": string
|
"filename": string
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Examples:
|
**Examples**:
|
||||||
|
|
||||||
$ zipinfo log4j-core-2.16.0.jar | jc --zipinfo -p
|
|
||||||
|
$ zipinfo log4j-core-2.16.0.jar | jc --zipinfo -p
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
- `"archive"` - "log4j-core-2.16.0.jar",
|
||||||
|
- `"size"` - 1789565,
|
||||||
|
- `"size_unit"` - "bytes",
|
||||||
|
- `"number_entries"` - 1218,
|
||||||
|
- `"number_files"` - 1218,
|
||||||
|
- `"bytes_uncompressed"` - 3974141,
|
||||||
|
- `"bytes_compressed"` - 1515455,
|
||||||
|
- `"percent_compressed"` - 61.9,
|
||||||
|
- `"files"` - [
|
||||||
|
{
|
||||||
|
- `"flags"` - "-rw-r--r--",
|
||||||
|
- `"zipversion"` - "2.0",
|
||||||
|
- `"zipunder"` - "unx",
|
||||||
|
- `"filesize"` - 19810,
|
||||||
|
- `"type"` - "bl",
|
||||||
|
- `"method"` - "defN",
|
||||||
|
- `"date"` - "21-Dec-12",
|
||||||
|
- `"time"` - "23:35",
|
||||||
|
- `"filename"` - "META-INF/MANIFEST.MF"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
|
||||||
[
|
<a id="jc.parsers.zipinfo.info"></a>
|
||||||
{
|
|
||||||
"archive": "log4j-core-2.16.0.jar",
|
|
||||||
"size": 1789565,
|
|
||||||
"size_unit": "bytes",
|
|
||||||
"number_entries": 1218,
|
|
||||||
"number_files": 1218,
|
|
||||||
"bytes_uncompressed": 3974141,
|
|
||||||
"bytes_compressed": 1515455,
|
|
||||||
"percent_compressed": 61.9,
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"flags": "-rw-r--r--",
|
|
||||||
"zipversion": "2.0",
|
|
||||||
"zipunder": "unx",
|
|
||||||
"filesize": 19810,
|
|
||||||
"type": "bl",
|
|
||||||
"method": "defN",
|
|
||||||
"date": "21-Dec-12",
|
|
||||||
"time": "23:35",
|
|
||||||
"filename": "META-INF/MANIFEST.MF"
|
|
||||||
},
|
|
||||||
...
|
|
||||||
|
|
||||||
|
## info Objects
|
||||||
|
|
||||||
## info
|
|
||||||
```python
|
```python
|
||||||
info()
|
class info()
|
||||||
```
|
```
|
||||||
|
|
||||||
Provides parser metadata (version, author, etc.)
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## parse
|
<a id="jc.parsers.zipinfo.parse"></a>
|
||||||
|
|
||||||
|
#### parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
parse(data, raw=False, quiet=False)
|
def parse(data, raw=False, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing function
|
Main text parsing function
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) text data to parse
|
|
||||||
raw: (boolean) unprocessed output if True
|
- `data` - (string) text data to parse
|
||||||
quiet: (boolean) suppress warning messages if True
|
- `raw` - (boolean) unprocessed output if True
|
||||||
|
- `quiet` - (boolean) suppress warning messages if True
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
|
||||||
|
List of Dictionaries. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin
|
Compatibility: linux, darwin
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
<a id="jc"></a>
|
||||||
|
|
||||||
# jc
|
# jc
|
||||||
|
|
||||||
JC - JSON CLI output utility
|
JC - JSON CLI output utility
|
||||||
|
|
||||||
* kellyjonbrazil@gmail.com
|
* kellyjonbrazil@gmail.com
|
||||||
|
217
docs/utils.md
217
docs/utils.md
@ -1,194 +1,255 @@
|
|||||||
|
<a id="jc.utils"></a>
|
||||||
|
|
||||||
|
# jc.utils
|
||||||
|
|
||||||
# utils
|
|
||||||
jc - JSON CLI output utility utils
|
jc - JSON CLI output utility utils
|
||||||
|
|
||||||
## warning_message
|
<a id="jc.utils.warning_message"></a>
|
||||||
|
|
||||||
|
#### warning\_message
|
||||||
|
|
||||||
```python
|
```python
|
||||||
warning_message(message_lines)
|
def warning_message(message_lines)
|
||||||
```
|
```
|
||||||
|
|
||||||
Prints warning message for non-fatal issues. The first line is
|
Prints warning message for non-fatal issues. The first line is
|
||||||
prepended with 'jc: Warning - ' and subsequent lines are indented.
|
prepended with 'jc: Warning - ' and subsequent lines are indented.
|
||||||
Wraps text as needed based on the terminal width.
|
Wraps text as needed based on the terminal width.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
message: (list) list of string lines
|
|
||||||
|
- `message` - (list) list of string lines
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
None - just prints output to STDERR
|
|
||||||
|
None - just prints output to STDERR
|
||||||
|
|
||||||
|
<a id="jc.utils.error_message"></a>
|
||||||
|
|
||||||
|
#### error\_message
|
||||||
|
|
||||||
## error_message
|
|
||||||
```python
|
```python
|
||||||
error_message(message_lines)
|
def error_message(message_lines)
|
||||||
```
|
```
|
||||||
|
|
||||||
Prints an error message for fatal issues. The first line is
|
Prints an error message for fatal issues. The first line is
|
||||||
prepended with 'jc: Error - ' and subsequent lines are indented.
|
prepended with 'jc: Error - ' and subsequent lines are indented.
|
||||||
Wraps text as needed based on the terminal width.
|
Wraps text as needed based on the terminal width.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
message: (list) list of string lines
|
|
||||||
|
- `message` - (list) list of string lines
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
None - just prints output to STDERR
|
|
||||||
|
None - just prints output to STDERR
|
||||||
|
|
||||||
|
<a id="jc.utils.compatibility"></a>
|
||||||
|
|
||||||
|
#### compatibility
|
||||||
|
|
||||||
## compatibility
|
|
||||||
```python
|
```python
|
||||||
compatibility(mod_name, compatible, quiet=False)
|
def compatibility(mod_name, compatible, quiet=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
Checks for the parser's compatibility with the running OS
|
Checks for the parser's compatibility with the running OS
|
||||||
platform.
|
platform.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
mod_name: (string) __name__ of the calling module
|
|
||||||
|
- `mod_name` - (string) __name__ of the calling module
|
||||||
|
|
||||||
|
- `compatible` - (list) sys.platform name(s) compatible with
|
||||||
|
the parser. compatible options:
|
||||||
|
linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
|
- `quiet` - (bool) supress compatibility message if True
|
||||||
|
|
||||||
|
|
||||||
compatible: (list) sys.platform name(s) compatible with
|
**Returns**:
|
||||||
the parser. compatible options:
|
|
||||||
linux, darwin, cygwin, win32, aix, freebsd
|
|
||||||
|
|
||||||
quiet: (bool) supress compatibility message if True
|
|
||||||
|
None - just prints output to STDERR
|
||||||
|
|
||||||
Returns:
|
<a id="jc.utils.has_data"></a>
|
||||||
|
|
||||||
None - just prints output to STDERR
|
#### has\_data
|
||||||
|
|
||||||
|
|
||||||
## has_data
|
|
||||||
```python
|
```python
|
||||||
has_data(data)
|
def has_data(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
Checks if the input contains data. If there are any non-whitespace
|
Checks if the input contains data. If there are any non-whitespace
|
||||||
characters then return True, else return False.
|
characters then return True, else return False.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
data: (string) input to check whether it contains data
|
|
||||||
|
- `data` - (string) input to check whether it contains data
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
Boolean True if input string (data) contains non-whitespace
|
|
||||||
characters, otherwise False
|
Boolean True if input string (data) contains non-whitespace
|
||||||
|
characters, otherwise False
|
||||||
|
|
||||||
|
<a id="jc.utils.convert_to_int"></a>
|
||||||
|
|
||||||
|
#### convert\_to\_int
|
||||||
|
|
||||||
## convert_to_int
|
|
||||||
```python
|
```python
|
||||||
convert_to_int(value)
|
def convert_to_int(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
Converts string and float input to int. Strips all non-numeric
|
Converts string and float input to int. Strips all non-numeric
|
||||||
characters from strings.
|
characters from strings.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
value: (string/integer/float) Input value
|
|
||||||
|
- `value` - (string/integer/float) Input value
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
integer/None Integer if successful conversion, otherwise None
|
|
||||||
|
integer/None Integer if successful conversion, otherwise None
|
||||||
|
|
||||||
|
<a id="jc.utils.convert_to_float"></a>
|
||||||
|
|
||||||
|
#### convert\_to\_float
|
||||||
|
|
||||||
## convert_to_float
|
|
||||||
```python
|
```python
|
||||||
convert_to_float(value)
|
def convert_to_float(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
Converts string and int input to float. Strips all non-numeric
|
Converts string and int input to float. Strips all non-numeric
|
||||||
characters from strings.
|
characters from strings.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
value: (string) Input value
|
|
||||||
|
- `value` - (string) Input value
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
float/None Float if successful conversion, otherwise None
|
|
||||||
|
float/None Float if successful conversion, otherwise None
|
||||||
|
|
||||||
|
<a id="jc.utils.convert_to_bool"></a>
|
||||||
|
|
||||||
|
#### convert\_to\_bool
|
||||||
|
|
||||||
## convert_to_bool
|
|
||||||
```python
|
```python
|
||||||
convert_to_bool(value)
|
def convert_to_bool(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
Converts string, integer, or float input to boolean by checking
|
Converts string, integer, or float input to boolean by checking
|
||||||
for 'truthy' values.
|
for 'truthy' values.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
value: (string/integer/float) Input value
|
|
||||||
|
- `value` - (string/integer/float) Input value
|
||||||
|
|
||||||
|
|
||||||
Returns:
|
**Returns**:
|
||||||
|
|
||||||
True/False False unless a 'truthy' number or string is found
|
|
||||||
('y', 'yes', 'true', '1', 1, -1, etc.)
|
True/False False unless a 'truthy' number or string is found
|
||||||
|
('y', 'yes', 'true', '1', 1, -1, etc.)
|
||||||
|
|
||||||
|
<a id="jc.utils.stream_success"></a>
|
||||||
|
|
||||||
|
#### stream\_success
|
||||||
|
|
||||||
## stream_success
|
|
||||||
```python
|
```python
|
||||||
stream_success(output_line, ignore_exceptions)
|
def stream_success(output_line, ignore_exceptions)
|
||||||
```
|
```
|
||||||
|
|
||||||
Add `_jc_meta` object to output line if `ignore_exceptions=True`
|
Add `_jc_meta` object to output line if `ignore_exceptions=True`
|
||||||
|
|
||||||
## stream_error
|
<a id="jc.utils.stream_error"></a>
|
||||||
|
|
||||||
|
#### stream\_error
|
||||||
|
|
||||||
```python
|
```python
|
||||||
stream_error(e, ignore_exceptions, line)
|
def stream_error(e, ignore_exceptions, line)
|
||||||
```
|
```
|
||||||
|
|
||||||
Reraise the stream exception with annotation or print an error
|
Reraise the stream exception with annotation or print an error
|
||||||
`_jc_meta` field if `ignore_exceptions=True`.
|
`_jc_meta` field if `ignore_exceptions=True`.
|
||||||
|
|
||||||
|
<a id="jc.utils.input_type_check"></a>
|
||||||
|
|
||||||
|
#### input\_type\_check
|
||||||
|
|
||||||
## input_type_check
|
|
||||||
```python
|
```python
|
||||||
input_type_check(data)
|
def input_type_check(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
Ensure input data is a string
|
Ensure input data is a string
|
||||||
|
|
||||||
## streaming_input_type_check
|
<a id="jc.utils.streaming_input_type_check"></a>
|
||||||
|
|
||||||
|
#### streaming\_input\_type\_check
|
||||||
|
|
||||||
```python
|
```python
|
||||||
streaming_input_type_check(data)
|
def streaming_input_type_check(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
Ensure input data is an iterable, but not a string or bytes
|
Ensure input data is an iterable, but not a string or bytes
|
||||||
|
|
||||||
## streaming_line_input_type_check
|
<a id="jc.utils.streaming_line_input_type_check"></a>
|
||||||
|
|
||||||
|
#### streaming\_line\_input\_type\_check
|
||||||
|
|
||||||
```python
|
```python
|
||||||
streaming_line_input_type_check(line)
|
def streaming_line_input_type_check(line)
|
||||||
```
|
```
|
||||||
|
|
||||||
Ensure each line is a string
|
Ensure each line is a string
|
||||||
|
|
||||||
## timestamp
|
<a id="jc.utils.timestamp"></a>
|
||||||
|
|
||||||
|
## timestamp Objects
|
||||||
|
|
||||||
```python
|
```python
|
||||||
timestamp(datetime_string)
|
class timestamp()
|
||||||
```
|
```
|
||||||
|
|
||||||
Input a date-time text string of several formats and convert to a
|
Input a date-time text string of several formats and convert to a
|
||||||
naive or timezone-aware epoch timestamp in UTC.
|
naive or timezone-aware epoch timestamp in UTC.
|
||||||
|
|
||||||
Parameters:
|
**Arguments**:
|
||||||
|
|
||||||
datetime_string: (str) a string representation of a
|
|
||||||
date-time in several supported formats
|
- `datetime_string` - (str) a string representation of a
|
||||||
|
date-time in several supported formats
|
||||||
|
|
||||||
|
|
||||||
Attributes:
|
**Attributes**:
|
||||||
|
|
||||||
string (str) the input datetime string
|
|
||||||
|
string (str) the input datetime string
|
||||||
format (int) the format rule that was used to
|
|
||||||
decode the datetime string. None if
|
format (int) the format rule that was used to
|
||||||
conversion fails
|
decode the datetime string. None if
|
||||||
|
conversion fails
|
||||||
naive (int) timestamp based on locally configured
|
|
||||||
timezone. None if conversion fails
|
naive (int) timestamp based on locally configured
|
||||||
|
timezone. None if conversion fails
|
||||||
utc (int) aware timestamp only if UTC timezone
|
|
||||||
detected in datetime string. None if
|
utc (int) aware timestamp only if UTC timezone
|
||||||
conversion fails
|
detected in datetime string. None if
|
||||||
|
conversion fails
|
||||||
|
|
||||||
|
@ -521,6 +521,7 @@ def main():
|
|||||||
|
|
||||||
utils.error_message([f'Parser issue with {parser_name}:',
|
utils.error_message([f'Parser issue with {parser_name}:',
|
||||||
f'{e.__class__.__name__}: {e}',
|
f'{e.__class__.__name__}: {e}',
|
||||||
|
'Please ensure the locale is set to C (LANG=C) and you used the correct parser.',
|
||||||
'For details use the -d or -dd option. Use "jc -h" for help.'])
|
'For details use the -d or -dd option. Use "jc -h" for help.'])
|
||||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||||
|
|
||||||
@ -541,8 +542,9 @@ def main():
|
|||||||
streaming_msg = 'Use the -qq option to ignore streaming parser errors.'
|
streaming_msg = 'Use the -qq option to ignore streaming parser errors.'
|
||||||
|
|
||||||
utils.error_message([
|
utils.error_message([
|
||||||
f'{parser_name} parser could not parse the input data. Did you use the correct parser?',
|
f'{parser_name} parser could not parse the input data.',
|
||||||
f'{streaming_msg}',
|
f'{streaming_msg}',
|
||||||
|
'Please ensure the locale is set to C (LANG=C) and you used the correct parser.',
|
||||||
'For details use the -d or -dd option. Use "jc -h" for help.'
|
'For details use the -d or -dd option. Use "jc -h" for help.'
|
||||||
])
|
])
|
||||||
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
|
||||||
|
12
man/jc.1
12
man/jc.1
@ -1,4 +1,4 @@
|
|||||||
.TH jc 1 2022-01-23 1.18.1 "JSON CLI output utility"
|
.TH jc 1 2022-01-25 1.18.2 "JSON CLI output utility"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
jc \- JSONifies the output of many CLI tools and file-types
|
jc \- JSONifies the output of many CLI tools and file-types
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -442,6 +442,16 @@ YAML file parser
|
|||||||
\fB--zipinfo\fP
|
\fB--zipinfo\fP
|
||||||
`zipinfo` command parser
|
`zipinfo` command parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--testing-two\fP
|
||||||
|
test parser 2
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--testing\fP
|
||||||
|
test parser
|
||||||
|
|
||||||
|
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
|
Reference in New Issue
Block a user