mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
@ -1,5 +1,14 @@
|
||||
jc changelog
|
||||
|
||||
20220325 v1.18.6
|
||||
- Add pidstat command parser tested on linux
|
||||
- Add pidstat command streaming parser tested on linux
|
||||
- Add mpstat command parser tested on linux
|
||||
- Add mpstat command streaming parser tested on linux
|
||||
- Add single-line ASCII and Unicode table parser
|
||||
- Add multi-line ASCII and Unicode table parser
|
||||
- Add documentation option to parser_info() and all_parser_info()
|
||||
|
||||
20220305 v1.18.5
|
||||
- Fix date parser to ensure AM/PM period string is always uppercase
|
||||
|
||||
|
64
EXAMPLES.md
64
EXAMPLES.md
@ -2149,6 +2149,29 @@ mount | jc --mount -p # or: jc -p mount
|
||||
}
|
||||
]
|
||||
```
|
||||
### mpstat
|
||||
```bash
|
||||
mpstat | jc --mpstat -p # or jc -p mpstat
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"cpu": "all",
|
||||
"percent_usr": 12.94,
|
||||
"percent_nice": 0.0,
|
||||
"percent_sys": 26.42,
|
||||
"percent_iowait": 0.43,
|
||||
"percent_irq": 0.0,
|
||||
"percent_soft": 0.16,
|
||||
"percent_steal": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_gnice": 0.0,
|
||||
"percent_idle": 60.05,
|
||||
"type": "cpu",
|
||||
"time": "01:58:14 PM"
|
||||
}
|
||||
]
|
||||
```
|
||||
### netstat
|
||||
```bash
|
||||
netstat -apee | jc --netstat -p # or: jc -p netstat -apee
|
||||
@ -2497,6 +2520,47 @@ cat /etc/passwd | jc --passwd -p
|
||||
}
|
||||
]
|
||||
```
|
||||
### pidstat
|
||||
```bash
|
||||
pidstat -hl | jc --pidstat -p # or jc -p pidstat -hl
|
||||
```
|
||||
```json
|
||||
[
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 1,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.03,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.03,
|
||||
"cpu": 0,
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system..."
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 6,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "ksoftirqd/0"
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 2263,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "kworker/0:0"
|
||||
}
|
||||
]
|
||||
```
|
||||
### ping
|
||||
```bash
|
||||
ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3
|
||||
|
@ -147,6 +147,8 @@ option.
|
||||
- `--airport` enables the `airport -I` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport))
|
||||
- `--airport-s` enables the `airport -s` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s))
|
||||
- `--arp` enables the `arp` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/arp))
|
||||
- `--asciitable` enables the ASCII and Unicode table parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable))
|
||||
- `--asciitable-m` enables the multi-line ASCII and Unicode table parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m))
|
||||
- `--blkid` enables the `blkid` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/blkid))
|
||||
- `--cksum` enables the `cksum` and `sum` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/cksum))
|
||||
- `--crontab` enables the `crontab` command and file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/crontab))
|
||||
@ -190,10 +192,14 @@ option.
|
||||
- `--lsof` enables the `lsof` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof))
|
||||
- `--lsusb` enables the `lsusb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb))
|
||||
- `--mount` enables the `mount` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mount))
|
||||
- `--mpstat` enables the `mpstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat))
|
||||
- `--mpstat-s` enables the `mpstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s))
|
||||
- `--netstat` enables the `netstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat))
|
||||
- `--nmcli` enables the `nmcli` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli))
|
||||
- `--ntpq` enables the `ntpq -p` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq))
|
||||
- `--passwd` enables the `/etc/passwd` file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/passwd))
|
||||
- `--pidstat` enables the `pidstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat))
|
||||
- `--pidstat-s` enables the `pidstat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pidstat_s))
|
||||
- `--ping` enables the `ping` and `ping6` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping))
|
||||
- `--ping-s` enables the `ping` and `ping6` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ping_s))
|
||||
- `--pip-list` enables the `pip list` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list))
|
||||
|
26
docs/lib.md
26
docs/lib.md
@ -14,8 +14,7 @@
|
||||
|
||||
# jc.lib
|
||||
|
||||
jc - JSON Convert
|
||||
JC lib module
|
||||
jc - JSON Convert lib module
|
||||
|
||||
<a id="jc.lib.parse"></a>
|
||||
|
||||
@ -133,23 +132,34 @@ subset of `parser_mod_list()`.
|
||||
### parser\_info
|
||||
|
||||
```python
|
||||
def parser_info(parser_mod_name: str) -> Dict
|
||||
def parser_info(parser_mod_name: str, documentation: bool = False) -> Dict
|
||||
```
|
||||
|
||||
Returns a dictionary that includes the module metadata.
|
||||
Returns a dictionary that includes the parser module metadata.
|
||||
|
||||
This function will accept **module_name**, **cli-name**, and
|
||||
**--argument-name** variants of the module name string.
|
||||
Parameters:
|
||||
|
||||
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.
|
||||
|
||||
documentation: (boolean) include parser docstring if True
|
||||
|
||||
<a id="jc.lib.all_parser_info"></a>
|
||||
|
||||
### all\_parser\_info
|
||||
|
||||
```python
|
||||
def all_parser_info() -> List[Dict]
|
||||
def all_parser_info(documentation: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Returns a list of dictionaries that includes metadata for all modules.
|
||||
Returns a list of dictionaries that includes metadata for all parser
|
||||
modules.
|
||||
|
||||
Parameters:
|
||||
|
||||
documentation: (boolean) include parser docstrings if True
|
||||
|
||||
<a id="jc.lib.get_help"></a>
|
||||
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('acpi', acpi_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.acpi
|
||||
result = jc.parsers.acpi.parse(acpi_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('airport', airport_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.airport
|
||||
result = jc.parsers.airport.parse(airport_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('airport_s', airport_s_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.airport_s
|
||||
result = jc.parsers.airport_s.parse(airport_s_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('arp', arp_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.arp
|
||||
result = jc.parsers.arp.parse(arp_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
@ -127,7 +122,7 @@ Examples:
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data, raw=False, quiet=False)
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
@ -145,4 +140,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux, aix, freebsd, darwin
|
||||
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
139
docs/parsers/asciitable.md
Normal file
139
docs/parsers/asciitable.md
Normal file
@ -0,0 +1,139 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.asciitable"></a>
|
||||
|
||||
# jc.parsers.asciitable
|
||||
|
||||
jc - JSON Convert `asciitable` parser
|
||||
|
||||
This parser converts ASCII and Unicode text tables with single-line rows.
|
||||
|
||||
Column headers must be at least two spaces apart from each other and must
|
||||
be unique.
|
||||
|
||||
For example:
|
||||
|
||||
╒══════════╤═════════╤════════╕
|
||||
│ foo │ bar │ baz │
|
||||
╞══════════╪═════════╪════════╡
|
||||
│ good day │ │ 12345 │
|
||||
├──────────┼─────────┼────────┤
|
||||
│ hi there │ abc def │ 3.14 │
|
||||
╘══════════╧═════════╧════════╛
|
||||
|
||||
or
|
||||
|
||||
+-----------------------------+
|
||||
| foo bar baz |
|
||||
+-----------------------------+
|
||||
| good day 12345 |
|
||||
| hi there abc def 3.14 |
|
||||
+-----------------------------+
|
||||
|
||||
or
|
||||
|
||||
| foo | bar | baz |
|
||||
|----------|---------|--------|
|
||||
| good day | | 12345 |
|
||||
| hi there | abc def | 3.14 |
|
||||
|
||||
or
|
||||
|
||||
foo bar baz
|
||||
--------- -------- ------
|
||||
good day 12345
|
||||
hi there abc def 3.14
|
||||
|
||||
or
|
||||
|
||||
foo bar baz
|
||||
good day 12345
|
||||
hi there abc def 3.14
|
||||
|
||||
etc...
|
||||
|
||||
Headers (keys) are converted to snake-case. All values are returned as
|
||||
strings, except empty strings, which are converted to None/null.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('asciitable', asciitable_string)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string, # empty string is null
|
||||
"column_name2": string # empty string is null
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '
|
||||
> ╒══════════╤═════════╤════════╕
|
||||
> │ foo │ bar │ baz │
|
||||
> ╞══════════╪═════════╪════════╡
|
||||
> │ good day │ │ 12345 │
|
||||
> ├──────────┼─────────┼────────┤
|
||||
> │ hi there │ abc def │ 3.14 │
|
||||
> ╘══════════╧═════════╧════════╛' | jc --asciitable -p
|
||||
[
|
||||
{
|
||||
"foo": "good day",
|
||||
"bar": null,
|
||||
"baz": "12345"
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
$ echo '
|
||||
> foo bar baz
|
||||
> --------- -------- ------
|
||||
> good day 12345
|
||||
> hi there abc def 3.14' | jc --asciitable -p
|
||||
[
|
||||
{
|
||||
"foo": "good day",
|
||||
"bar": null,
|
||||
"baz": "12345"
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.asciitable.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
123
docs/parsers/asciitable_m.md
Normal file
123
docs/parsers/asciitable_m.md
Normal file
@ -0,0 +1,123 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.asciitable_m"></a>
|
||||
|
||||
# jc.parsers.asciitable\_m
|
||||
|
||||
jc - JSON Convert `asciitable-m` parser
|
||||
|
||||
This parser converts various styles of ASCII and Unicode text tables with
|
||||
multi-line rows. Tables must have a header row and separator line between
|
||||
rows.
|
||||
|
||||
For example:
|
||||
|
||||
╒══════════╤═════════╤════════╕
|
||||
│ foo │ bar baz │ fiz │
|
||||
│ │ │ buz │
|
||||
╞══════════╪═════════╪════════╡
|
||||
│ good day │ 12345 │ │
|
||||
│ mate │ │ │
|
||||
├──────────┼─────────┼────────┤
|
||||
│ hi there │ abc def │ 3.14 │
|
||||
│ │ │ │
|
||||
╘══════════╧═════════╧════════╛
|
||||
|
||||
Cells with multiple lines within rows will be joined with a newline
|
||||
character ('\n').
|
||||
|
||||
Headers (keys) are converted to snake-case and newlines between multi-line
|
||||
headers are joined with an underscore. All values are returned as strings,
|
||||
except empty strings, which are converted to None/null.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable-m
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('asciitable_m', asciitable-string)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string, # empty string is null
|
||||
"column_name2": string # empty string is null
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '
|
||||
> +----------+---------+--------+
|
||||
> | foo | bar | baz |
|
||||
> | | | buz |
|
||||
> +==========+=========+========+
|
||||
> | good day | 12345 | |
|
||||
> | mate | | |
|
||||
> +----------+---------+--------+
|
||||
> | hi there | abc def | 3.14 |
|
||||
> | | | |
|
||||
> +==========+=========+========+' | jc --asciitable-m -p
|
||||
[
|
||||
{
|
||||
"foo": "good day\nmate",
|
||||
"bar": "12345",
|
||||
"baz_buz": null
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz_buz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
$ echo '
|
||||
> ╒══════════╤═════════╤════════╕
|
||||
> │ foo │ bar │ baz │
|
||||
> │ │ │ buz │
|
||||
> ╞══════════╪═════════╪════════╡
|
||||
> │ good day │ 12345 │ │
|
||||
> │ mate │ │ │
|
||||
> ├──────────┼─────────┼────────┤
|
||||
> │ hi there │ abc def │ 3.14 │
|
||||
> │ │ │ │
|
||||
> ╘══════════╧═════════╧════════╛' | jc --asciitable-m -p
|
||||
[
|
||||
{
|
||||
"foo": "good day\nmate",
|
||||
"bar": "12345",
|
||||
"baz_buz": null
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz_buz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.asciitable_m.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('blkid', blkid_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.blkid
|
||||
result = jc.parsers.blkid.parse(blkid_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -22,11 +22,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('cksum', cksum_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.cksum
|
||||
result = jc.parsers.cksum.parse(cksum_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -21,11 +21,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('crontab', crontab_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.crontab
|
||||
result = jc.parsers.crontab.parse(crontab_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('crontab_u', crontab_u_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.crontab_u
|
||||
result = jc.parsers.crontab_u.parse(crontab_u_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('csv', csv_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.csv
|
||||
result = jc.parsers.csv.parse(csv_output)
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary:
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
jc - JSON Convert `csv` file streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
The `csv` streaming parser will attempt to automatically detect the
|
||||
delimiter character. If the delimiter cannot be detected it will default
|
||||
@ -21,19 +22,11 @@ Usage (cli):
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('csv_s', csv_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.csv_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.csv_s.parse(csv_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
csv file converted to a Dictionary:
|
||||
@ -44,9 +37,7 @@ Schema:
|
||||
"column_name2": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
|
@ -24,11 +24,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('date', date_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.date
|
||||
result = jc.parsers.date.parse(date_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('df', df_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.df
|
||||
result = jc.parsers.df.parse(df_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -29,11 +29,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('dig', dig_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.dig
|
||||
result = jc.parsers.dig.parse(dig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -26,11 +26,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('dir', dir_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.dir
|
||||
result = jc.parsers.dir.parse(dir_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('dmidecode', dmidecode_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.dmidecode
|
||||
result = jc.parsers.dmidecode.parse(dmidecode_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('dpkg_l', dpkg_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.dpkg_l
|
||||
result = jc.parsers.dpkg_l.parse(dpkg_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('du', du_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.du
|
||||
result = jc.parsers.du.parse(du_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('env', env_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.env
|
||||
result = jc.parsers.env.parse(env_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('file', file_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.file
|
||||
result = jc.parsers.file.parse(file_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('finger', finger_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.finger
|
||||
result = jc.parsers.finger.parse(finger_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('free', free_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.free
|
||||
result = jc.parsers.free.parse(free_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('fstab', fstab_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.fstab
|
||||
result = jc.parsers.fstab.parse(fstab_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('group', group_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.group
|
||||
result = jc.parsers.group.parse(group_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('gshadow', gshadow_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.gshadow
|
||||
result = jc.parsers.gshadow.parse(gshadow_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('hash', hash_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.hash
|
||||
result = jc.parsers.hash.parse(hash_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -28,11 +28,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('hashsum', md5sum_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.hashsum
|
||||
result = jc.parsers.hashsum.parse(md5sum_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('hciconfig', hciconfig_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.hciconfig
|
||||
result = jc.parsers.hciconfig.parse(hciconfig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -22,11 +22,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('history', history_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.history
|
||||
result = jc.parsers.history.parse(history_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('hosts', hosts_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.hosts
|
||||
result = jc.parsers.hosts.parse(hosts_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('id', id_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.id
|
||||
result = jc.parsers.id.parse(id_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ifconfig', ifconfig_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ifconfig
|
||||
result = jc.parsers.ifconfig.parse(ifconfig_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -22,11 +22,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ini', ini_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ini
|
||||
result = jc.parsers.ini.parse(ini_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
ini or key/value document converted to a dictionary - see the
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('iostat', iostat_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.iostat
|
||||
result = jc.parsers.iostat.parse(iostat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
jc - JSON Convert `iostat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Note: `iostat` version 11 and higher include a JSON output option
|
||||
|
||||
@ -13,22 +14,21 @@ Usage (cli):
|
||||
|
||||
$ iostat | jc --iostat-s
|
||||
|
||||
> Note: When piping `jc` converted `iostat` output to other processes it may
|
||||
appear the output is hanging due to the OS pipe buffers. This is because
|
||||
`iostat` 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. See
|
||||
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('iostat_s', iostat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.iostat_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
@ -83,10 +83,8 @@ Schema:
|
||||
"percent_rrqm": float,
|
||||
"percent_wrqm": float,
|
||||
|
||||
# Below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('iptables', iptables_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.iptables
|
||||
result = jc.parsers.iptables.parse(iptables_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -21,11 +21,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('iw_scan', iw_scan_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.iw_scan
|
||||
result = jc.parsers.iw_scan.parse(iw_scan_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('jar_manifest', jar_manifest_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.jar_manifest
|
||||
result = jc.parsers.jar_manifest.parse(jar_manifest_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -19,11 +19,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('jobs', jobs_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.jobs
|
||||
result = jc.parsers.jobs.parse(jobs_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -22,11 +22,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('kv', kv_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.kv
|
||||
result = jc.parsers.kv.parse(kv_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
key/value document converted to a dictionary - see the
|
||||
|
@ -24,11 +24,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('last', last_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.last
|
||||
result = jc.parsers.last.parse(last_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -34,11 +34,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ls', ls_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ls
|
||||
result = jc.parsers.ls.parse(ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
# jc.parsers.ls\_s
|
||||
|
||||
jc - JSON Convert `ls` and `vdir` command output streaming
|
||||
parser
|
||||
jc - JSON Convert `ls` and `vdir` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Requires the `-l` option to be used on `ls`. If there are newline characters
|
||||
in the filename, then make sure to use the `-b` option on `ls`.
|
||||
@ -27,19 +27,11 @@ Usage (cli):
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('ls_s', ls_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ls_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
@ -54,10 +46,8 @@ Schema:
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer, # [1]
|
||||
|
||||
# Below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('lsblk', lsblk_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.lsblk
|
||||
result = jc.parsers.lsblk.parse(lsblk_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('lsmod', lsmod_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.lsmod
|
||||
result = jc.parsers.lsmod.parse(lsmod_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('lsof', lsof_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.lsof
|
||||
result = jc.parsers.lsof.parse(lsof_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('lsusb', lsusb_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.lsusb
|
||||
result = jc.parsers.lsusb.parse(lsusb_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Note: <item> object keynames are assigned directly from the lsusb
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('mount', mount_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.mount
|
||||
result = jc.parsers.mount.parse(mount_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
140
docs/parsers/mpstat.md
Normal file
140
docs/parsers/mpstat.md
Normal file
@ -0,0 +1,140 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.mpstat"></a>
|
||||
|
||||
# jc.parsers.mpstat
|
||||
|
||||
jc - JSON Convert `mpstat` command output parser
|
||||
|
||||
Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ mpstat | jc --mpstat
|
||||
|
||||
or
|
||||
|
||||
$ jc mpstat
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('mpstat', mpstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"time": string,
|
||||
"cpu": string,
|
||||
"node": string,
|
||||
"average": boolean,
|
||||
"percent_usr": float,
|
||||
"percent_nice": float,
|
||||
"percent_sys": float,
|
||||
"percent_iowait": float,
|
||||
"percent_irq": float,
|
||||
"percent_soft": float,
|
||||
"percent_steal": float,
|
||||
"percent_guest": float,
|
||||
"percent_gnice": float,
|
||||
"percent_idle": float,
|
||||
"intr_s": float,
|
||||
"<x>_s": float, # <x> is an integer
|
||||
"nmi_s": float,
|
||||
"loc_s": float,
|
||||
"spu_s": float,
|
||||
"pmi_s": float,
|
||||
"iwi_s": float,
|
||||
"rtr_s": float,
|
||||
"res_s": float,
|
||||
"cal_s": float,
|
||||
"tlb_s": float,
|
||||
"trm_s": float,
|
||||
"thr_s": float,
|
||||
"dfr_s": float,
|
||||
"mce_s": float,
|
||||
"mcp_s": float,
|
||||
"err_s": float,
|
||||
"mis_s": float,
|
||||
"pin_s": float,
|
||||
"npi_s": float,
|
||||
"piw_s": float,
|
||||
"hi_s": float,
|
||||
"timer_s": float,
|
||||
"net_tx_s": float,
|
||||
"net_rx_s": float,
|
||||
"block_s": float,
|
||||
"irq_poll_s": float,
|
||||
"block_iopoll_s": float,
|
||||
"tasklet_s": float,
|
||||
"sched_s": float,
|
||||
"hrtimer_s": float,
|
||||
"rcu_s": float
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ mpstat | jc --mpstat -p
|
||||
[
|
||||
{
|
||||
"cpu": "all",
|
||||
"percent_usr": 12.94,
|
||||
"percent_nice": 0.0,
|
||||
"percent_sys": 26.42,
|
||||
"percent_iowait": 0.43,
|
||||
"percent_irq": 0.0,
|
||||
"percent_soft": 0.16,
|
||||
"percent_steal": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_gnice": 0.0,
|
||||
"percent_idle": 60.05,
|
||||
"type": "cpu",
|
||||
"time": "01:58:14 PM"
|
||||
}
|
||||
]
|
||||
|
||||
$ mpstat | jc --mpstat -p -r
|
||||
[
|
||||
{
|
||||
"cpu": "all",
|
||||
"percent_usr": "12.94",
|
||||
"percent_nice": "0.00",
|
||||
"percent_sys": "26.42",
|
||||
"percent_iowait": "0.43",
|
||||
"percent_irq": "0.00",
|
||||
"percent_soft": "0.16",
|
||||
"percent_steal": "0.00",
|
||||
"percent_guest": "0.00",
|
||||
"percent_gnice": "0.00",
|
||||
"percent_idle": "60.05",
|
||||
"type": "cpu",
|
||||
"time": "01:58:14 PM"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.mpstat.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
134
docs/parsers/mpstat_s.md
Normal file
134
docs/parsers/mpstat_s.md
Normal file
@ -0,0 +1,134 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.mpstat_s"></a>
|
||||
|
||||
# jc.parsers.mpstat\_s
|
||||
|
||||
jc - JSON Convert `mpstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Note: Latest versions of `mpstat` support JSON output (v11.5.1+)
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ mpstat | jc --mpstat-s
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('mpstat_s', mpstat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"type": string,
|
||||
"time": string,
|
||||
"cpu": string,
|
||||
"node": string,
|
||||
"average": boolean,
|
||||
"percent_usr": float,
|
||||
"percent_nice": float,
|
||||
"percent_sys": float,
|
||||
"percent_iowait": float,
|
||||
"percent_irq": float,
|
||||
"percent_soft": float,
|
||||
"percent_steal": float,
|
||||
"percent_guest": float,
|
||||
"percent_gnice": float,
|
||||
"percent_idle": float,
|
||||
"intr_s": float,
|
||||
"<x>_s": float, # <x> is an integer
|
||||
"nmi_s": float,
|
||||
"loc_s": float,
|
||||
"spu_s": float,
|
||||
"pmi_s": float,
|
||||
"iwi_s": float,
|
||||
"rtr_s": float,
|
||||
"res_s": float,
|
||||
"cal_s": float,
|
||||
"tlb_s": float,
|
||||
"trm_s": float,
|
||||
"thr_s": float,
|
||||
"dfr_s": float,
|
||||
"mce_s": float,
|
||||
"mcp_s": float,
|
||||
"err_s": float,
|
||||
"mis_s": float,
|
||||
"pin_s": float,
|
||||
"npi_s": float,
|
||||
"piw_s": float,
|
||||
"hi_s": float,
|
||||
"timer_s": float,
|
||||
"net_tx_s": float,
|
||||
"net_rx_s": float,
|
||||
"block_s": float,
|
||||
"irq_poll_s": float,
|
||||
"block_iopoll_s": float,
|
||||
"tasklet_s": float,
|
||||
"sched_s": float,
|
||||
"hrtimer_s": float,
|
||||
"rcu_s": float,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ mpstat -A | jc --mpstat-s
|
||||
{"cpu":"all","percent_usr":0.22,"percent_nice":0.0,"percent_sys":...}
|
||||
{"cpu":"0","percent_usr":0.22,"percent_nice":0.0,"percent_sys":0....}
|
||||
{"cpu":"all","intr_s":37.61,"type":"interrupts","time":"03:15:06 PM"}
|
||||
...
|
||||
|
||||
$ mpstat -A | jc --mpstat-s -r
|
||||
{"cpu":"all","percent_usr":"0.22","percent_nice":"0.00","percent_...}
|
||||
{"cpu":"0","percent_usr":"0.22","percent_nice":"0.00","percent_sy...}
|
||||
{"cpu":"all","intr_s":"37.61","type":"interrupts","time":"03:15:06 PM"}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.mpstat_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False
|
||||
) -> Union[Generator[Dict, None, None], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
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
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('netstat', netstat_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.netstat
|
||||
result = jc.parsers.netstat.parse(netstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -27,11 +27,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('nmcli', nmcli_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.nmcli
|
||||
result = jc.parsers.nmcli.parse(nmcli_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Because there are so many options, the schema is not strictly defined.
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ntpq', ntpq_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ntpq
|
||||
result = jc.parsers.ntpq.parse(ntpq_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('passwd', passwd_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.passwd
|
||||
result = jc.parsers.passwd.parse(passwd_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
151
docs/parsers/pidstat.md
Normal file
151
docs/parsers/pidstat.md
Normal file
@ -0,0 +1,151 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.pidstat"></a>
|
||||
|
||||
# jc.parsers.pidstat
|
||||
|
||||
jc - JSON Convert `pidstat` command output parser
|
||||
|
||||
Must use the `-h` option in `pidstat`. All other `pidstat` options are
|
||||
supported in combination with `-h`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ pidstat -h | jc --pidstat
|
||||
|
||||
or
|
||||
|
||||
$ jc pidstat -h
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('pidstat', pidstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"time": integer,
|
||||
"uid": integer,
|
||||
"pid": integer,
|
||||
"percent_usr": float,
|
||||
"percent_system": float,
|
||||
"percent_guest": float,
|
||||
"percent_cpu": float,
|
||||
"cpu": integer,
|
||||
"minflt_s": float,
|
||||
"majflt_s": float,
|
||||
"vsz": integer,
|
||||
"rss": integer,
|
||||
"percent_mem": float,
|
||||
"stksize": integer,
|
||||
"stkref": integer,
|
||||
"kb_rd_s": float,
|
||||
"kb_wr_s": float,
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"command": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ pidstat -hl | jc --pidstat -p
|
||||
[
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 1,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.03,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.03,
|
||||
"cpu": 0,
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system..."
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 6,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "ksoftirqd/0"
|
||||
},
|
||||
{
|
||||
"time": 1646859134,
|
||||
"uid": 0,
|
||||
"pid": 2263,
|
||||
"percent_usr": 0.0,
|
||||
"percent_system": 0.0,
|
||||
"percent_guest": 0.0,
|
||||
"percent_cpu": 0.0,
|
||||
"cpu": 0,
|
||||
"command": "kworker/0:0"
|
||||
}
|
||||
]
|
||||
|
||||
$ pidstat -hl | jc --pidstat -p -r
|
||||
[
|
||||
{
|
||||
"time": "1646859134",
|
||||
"uid": "0",
|
||||
"pid": "1",
|
||||
"percent_usr": "0.00",
|
||||
"percent_system": "0.03",
|
||||
"percent_guest": "0.00",
|
||||
"percent_cpu": "0.03",
|
||||
"cpu": "0",
|
||||
"command": "/usr/lib/systemd/systemd --switched-root --system..."
|
||||
},
|
||||
{
|
||||
"time": "1646859134",
|
||||
"uid": "0",
|
||||
"pid": "6",
|
||||
"percent_usr": "0.00",
|
||||
"percent_system": "0.00",
|
||||
"percent_guest": "0.00",
|
||||
"percent_cpu": "0.00",
|
||||
"cpu": "0",
|
||||
"command": "ksoftirqd/0"
|
||||
},
|
||||
{
|
||||
"time": "1646859134",
|
||||
"uid": "0",
|
||||
"pid": "2263",
|
||||
"percent_usr": "0.00",
|
||||
"percent_system": "0.00",
|
||||
"percent_guest": "0.00",
|
||||
"percent_cpu": "0.00",
|
||||
"cpu": "0",
|
||||
"command": "kworker/0:0"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.pidstat.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
116
docs/parsers/pidstat_s.md
Normal file
116
docs/parsers/pidstat_s.md
Normal file
@ -0,0 +1,116 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.pidstat_s"></a>
|
||||
|
||||
# jc.parsers.pidstat\_s
|
||||
|
||||
jc - JSON Convert `pidstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Must use the `-h` option in `pidstat`. All other `pidstat` options are
|
||||
supported in combination with `-h`.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ pidstat | jc --pidstat-s
|
||||
|
||||
> Note: When piping `jc` converted `pidstat` output to other processes it
|
||||
may appear the output is hanging due to the OS pipe buffers. This is
|
||||
because `pidstat` 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. See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
|
||||
result = jc.parse('pidstat_s', pidstat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
"time": integer,
|
||||
"uid": integer,
|
||||
"pid": integer,
|
||||
"percent_usr": float,
|
||||
"percent_system": float,
|
||||
"percent_guest": float,
|
||||
"percent_cpu": float,
|
||||
"cpu": integer,
|
||||
"minflt_s": float,
|
||||
"majflt_s": float,
|
||||
"vsz": integer,
|
||||
"rss": integer,
|
||||
"percent_mem": float,
|
||||
"stksize": integer,
|
||||
"stkref": integer,
|
||||
"kb_rd_s": float,
|
||||
"kb_wr_s": float,
|
||||
"kb_ccwr_s": float,
|
||||
"cswch_s": float,
|
||||
"nvcswch_s": float,
|
||||
"command": string,
|
||||
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
}
|
||||
}
|
||||
|
||||
Examples:
|
||||
|
||||
$ pidstat -hl | jc --pidstat-s
|
||||
{"time":1646859134,"uid":0,"pid":1,"percent_usr":0.0,"percent_syste...}
|
||||
{"time":1646859134,"uid":0,"pid":6,"percent_usr":0.0,"percent_syste...}
|
||||
{"time":1646859134,"uid":0,"pid":9,"percent_usr":0.0,"percent_syste...}
|
||||
...
|
||||
|
||||
$ pidstat -hl | jc --pidstat-s -r
|
||||
{"time":"1646859134","uid":"0","pid":"1","percent_usr":"0.00","perc...}
|
||||
{"time":"1646859134","uid":"0","pid":"6","percent_usr":"0.00","perc...}
|
||||
{"time":"1646859134","uid":"0","pid":"9","percent_usr":"0.00","perc...}
|
||||
...
|
||||
|
||||
<a id="jc.parsers.pidstat_s.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False
|
||||
) -> Union[Generator[Dict, None, None], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
||||
Parameters:
|
||||
|
||||
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
|
||||
|
||||
Yields:
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
|
||||
Returns:
|
||||
|
||||
Iterator object (generator)
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ping', ping_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ping
|
||||
result = jc.parsers.ping.parse(ping_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
jc - JSON Convert `ping` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Supports `ping` and `ping6` output.
|
||||
|
||||
@ -23,19 +24,11 @@ Usage (cli):
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('ping_s', ping_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ping_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.ping_s.parse(ping_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
@ -61,10 +54,8 @@ Schema:
|
||||
"round_trip_ms_max": float,
|
||||
"round_trip_ms_stddev": float,
|
||||
|
||||
# Below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('pip_list', pip_list_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.pip_list
|
||||
result = jc.parsers.pip_list.parse(pip_list_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('pip_show', pip_show_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.pip_show
|
||||
result = jc.parsers.pip_show.parse(pip_show_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -22,11 +22,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ps', ps_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ps
|
||||
result = jc.parsers.ps.parse(ps_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('route', route_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.route
|
||||
result = jc.parsers.route.parse(route_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -26,11 +26,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('rpm_qi', rpm_qi_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.rpm_qi
|
||||
result = jc.parsers.rpm_qi.parse(rpm_qi_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -26,11 +26,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('rsync', rsync_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.rsync
|
||||
result = jc.parsers.rsync.parse(rsync_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
jc - JSON Convert `rsync` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Supports the `-i` or `--itemize-changes` options with all levels of
|
||||
verbosity. This parser will process the STDOUT output or a log file
|
||||
@ -22,19 +23,11 @@ Usage (cli):
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('rsync_s', rsync_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.rsync_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.rsync_s.parse(rsync_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
@ -68,10 +61,8 @@ Schema:
|
||||
"extended_attribute_different": bool/null,
|
||||
"epoch": integer, [2]
|
||||
|
||||
# Below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
@ -99,10 +90,12 @@ Examples:
|
||||
|
||||
```python
|
||||
@add_jc_meta
|
||||
def parse(data: Iterable[str],
|
||||
def parse(
|
||||
data: Iterable[str],
|
||||
raw: bool = False,
|
||||
quiet: bool = False,
|
||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
||||
ignore_exceptions: bool = False
|
||||
) -> Union[Generator[Dict, None, None], tuple]
|
||||
```
|
||||
|
||||
Main text parsing generator function. Returns an iterator object.
|
||||
|
@ -27,11 +27,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('sfdisk', sfdisk_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.sfdisk
|
||||
result = jc.parsers.sfdisk.parse(sfdisk_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('shadow', shadow_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.shadow
|
||||
result = jc.parsers.shadow.parse(shadow_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -21,11 +21,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ss', ss_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ss
|
||||
result = jc.parsers.ss.parse(ss_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Information from https://www.cyberciti.biz/files/ss.html used to define
|
||||
|
@ -24,11 +24,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('stat', stat_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.stat
|
||||
result = jc.parsers.stat.parse(stat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
jc - JSON Convert `stat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the
|
||||
local time of the system the parser is run on).
|
||||
@ -20,19 +21,11 @@ Usage (cli):
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('stat_s', stat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.stat_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.stat_s.parse(stat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
@ -68,10 +61,8 @@ Schema:
|
||||
"block_size": integer,
|
||||
"unix_flags": string,
|
||||
|
||||
# Below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # false if error parsing
|
||||
"error": string, # exists if "success" is false
|
||||
"line": string # exists if "success" is false
|
||||
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('sysctl', sysctl_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.sysctl
|
||||
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('systemctl', systemctl_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.systemctl
|
||||
result = jc.parsers.systemctl.parse(systemctl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('systemctl_lj', systemctl_lj_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.systemctl_lj
|
||||
result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -19,11 +19,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('systemctl_ls', systemctl_ls_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.systemctl_ls
|
||||
result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -19,11 +19,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('systemctl_luf', systemctl_luf_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.systemctl_luf
|
||||
result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -24,11 +24,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('systeminfo', systeminfo_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.systeminfo
|
||||
result = jc.parsers.systeminfo.parse(systeminfo_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -24,11 +24,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('time', time_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.time
|
||||
result = jc.parsers.time.parse(time_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage
|
||||
|
@ -21,11 +21,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('timedatectl', timedatectl_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.timedatectl
|
||||
result = jc.parsers.timedatectl.parse(timedatectl_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('tracepath', tracepath_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.tracepath
|
||||
result = jc.parsers.tracepath.parse(tracepath_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -27,11 +27,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('traceroute', traceroute_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.traceroute
|
||||
result = jc.parsers.traceroute.parse(traceroute_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ufw', ufw_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ufw
|
||||
result = jc.parsers.ufw.parse(ufw_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -26,11 +26,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('ufw_appinfo', ufw_appinfo_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.ufw_appinfo
|
||||
result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -20,11 +20,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('uname', uname_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.uname
|
||||
result = jc.parsers.uname.parse(uname_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -15,14 +15,28 @@ jc - JSON Convert universal parsers
|
||||
### simple\_table\_parse
|
||||
|
||||
```python
|
||||
def simple_table_parse(data: List[str]) -> List[Dict]
|
||||
def simple_table_parse(data: Iterable[str]) -> List[Dict]
|
||||
```
|
||||
|
||||
Parse simple tables. The last column may contain data with spaces.
|
||||
Parse simple tables. There should be no blank cells. The last column
|
||||
may contain data with spaces.
|
||||
|
||||
Example Table:
|
||||
|
||||
col_1 col_2 col_3 col_4 col_5
|
||||
apple orange pear banana my favorite fruits
|
||||
carrot squash celery spinach my favorite veggies
|
||||
chicken beef pork eggs my favorite proteins
|
||||
|
||||
[{'col_1': 'apple', 'col_2': 'orange', 'col_3': 'pear', 'col_4':
|
||||
'banana', 'col_5': 'my favorite fruits'}, {'col_1': 'carrot',
|
||||
'col_2': 'squash', 'col_3': 'celery', 'col_4': 'spinach', 'col_5':
|
||||
'my favorite veggies'}, {'col_1': 'chicken', 'col_2': 'beef',
|
||||
'col_3': 'pork', 'col_4': 'eggs', 'col_5': 'my favorite proteins'}]
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (list) Text data to parse that has been split into lines
|
||||
data: (iter) Text data to parse that has been split into lines
|
||||
via .splitlines(). Item 0 must be the header row.
|
||||
Any spaces in header names should be changed to
|
||||
underscore '_'. You should also ensure headers are
|
||||
@ -40,23 +54,38 @@ Returns:
|
||||
### sparse\_table\_parse
|
||||
|
||||
```python
|
||||
def sparse_table_parse(data: List[str], delim: str = '\u2063') -> List[Dict]
|
||||
def sparse_table_parse(data: Iterable[str],
|
||||
delim: str = '\u2063') -> List[Dict]
|
||||
```
|
||||
|
||||
Parse tables with missing column data or with spaces in column data.
|
||||
Blank cells are converted to None in the resulting dictionary. Data
|
||||
elements must line up within column boundaries.
|
||||
|
||||
Example Table:
|
||||
|
||||
col_1 col_2 col_3 col_4 col_5
|
||||
apple orange fuzzy peach my favorite fruits
|
||||
green beans celery spinach my favorite veggies
|
||||
chicken beef brown eggs my favorite proteins
|
||||
|
||||
[{'col_1': 'apple', 'col_2': 'orange', 'col_3': None, 'col_4':
|
||||
'fuzzy peach', 'col_5': 'my favorite fruits'}, {'col_1':
|
||||
'green beans', 'col_2': None, 'col_3': 'celery', 'col_4': 'spinach',
|
||||
'col_5': 'my favorite veggies'}, {'col_1': 'chicken', 'col_2':
|
||||
'beef', 'col_3': None, 'col_4': 'brown eggs', 'col_5':
|
||||
'my favorite proteins'}]
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (list) Text data to parse that has been split into lines
|
||||
via .splitlines(). Item 0 must be the header row.
|
||||
Any spaces in header names should be changed to
|
||||
underscore '_'. You should also ensure headers are
|
||||
lowercase by using .lower(). Do not change the
|
||||
position of header names as the positions are used
|
||||
to find the data.
|
||||
data: (iter) An iterable of string lines (e.g. str.splitlines())
|
||||
Item 0 must be the header row. Any spaces in header
|
||||
names should be changed to underscore '_'. You
|
||||
should also ensure headers are lowercase by using
|
||||
.lower(). Do not change the position of header
|
||||
names as the positions are used to find the data.
|
||||
|
||||
Also, ensure there are no blank lines (list items)
|
||||
in the data.
|
||||
Also, ensure there are no blank line items.
|
||||
|
||||
delim: (string) Delimiter to use. By default `u\\2063`
|
||||
(invisible separator) is used since it is unlikely
|
||||
|
@ -24,11 +24,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('upower', upower_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.upower
|
||||
result = jc.parsers.upower.parse(upower_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('uptime', uptime_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.uptime
|
||||
result = jc.parsers.uptime.parse(uptime_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -26,11 +26,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('vmstat', vmstat_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.vmstat
|
||||
result = jc.parsers.vmstat.parse(vmstat_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
jc - JSON Convert `vmstat` command output streaming parser
|
||||
|
||||
> This streaming parser outputs JSON Lines
|
||||
> This streaming parser outputs JSON Lines (cli) or returns a Generator
|
||||
iterator of Dictionaries (module)
|
||||
|
||||
Options supported: `-a`, `-w`, `-d`, `-t`
|
||||
|
||||
@ -20,28 +21,20 @@ Usage (cli):
|
||||
$ vmstat | jc --vmstat-s
|
||||
|
||||
> 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
|
||||
`vmstat` 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. See
|
||||
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
appear the output is hanging due to the OS pipe buffers. This is because
|
||||
`vmstat` 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. See
|
||||
the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output)
|
||||
for more information.
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
# result is an iterable object (generator)
|
||||
|
||||
result = jc.parse('vmstat_s', vmstat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.vmstat_s
|
||||
# result is an iterable object (generator)
|
||||
result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines())
|
||||
for item in result:
|
||||
# do something
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
@ -80,10 +73,8 @@ Schema:
|
||||
"epoch": integer, # [0]
|
||||
"epoch_utc": integer # [1]
|
||||
|
||||
# Below object only exists if using -qq or ignore_exceptions=True
|
||||
|
||||
"_jc_meta":
|
||||
{
|
||||
# below object only exists if using -qq or ignore_exceptions=True
|
||||
"_jc_meta": {
|
||||
"success": boolean, # [2]
|
||||
"error": string, # [3]
|
||||
"line": string # [3]
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('w', w_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.w
|
||||
result = jc.parsers.w.parse(w_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('wc', wc_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.wc
|
||||
result = jc.parsers.wc.parse(wc_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('who', who_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.who
|
||||
result = jc.parsers.who.parse(who_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('xml', xml_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.xml
|
||||
result = jc.parsers.xml.parse(xml_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
XML Document converted to a Dictionary
|
||||
|
@ -18,11 +18,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('xrandr', xrandr_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.xrandr
|
||||
result = jc.parsers.xrandr.parse(xrandr_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
{
|
||||
|
@ -14,11 +14,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('yaml', yaml_file_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.yaml
|
||||
result = jc.parsers.yaml.parse(yaml_file_output)
|
||||
|
||||
Schema:
|
||||
|
||||
YAML Document converted to a Dictionary
|
||||
|
@ -23,11 +23,6 @@ Usage (module):
|
||||
import jc
|
||||
result = jc.parse('zipinfo', zipinfo_command_output)
|
||||
|
||||
or
|
||||
|
||||
import jc.parsers.zipinfo
|
||||
result = jc.parsers.zipinfo.parse(zipinfo_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user