1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

doc update

This commit is contained in:
Kelly Brazil
2021-12-02 11:42:56 -08:00
parent dbd134d0da
commit a26a298f1a
4 changed files with 148 additions and 1 deletions

View File

@ -139,6 +139,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--ifconfig` enables the `ifconfig` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ifconfig))
- `--ini` enables the INI file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ini))
- `--iostat` enables the `iostat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat))
- `--iostat-s` enables the `iostat` command streaming parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s))
- `--iptables` enables the `iptables` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables))
- `--iw-scan` enables the `iw dev [device] scan` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan))
- `--jobs` enables the `jobs` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs))

View File

@ -3,6 +3,8 @@
# jc.parsers.iostat
jc - JSON CLI output utility `iostat` command output parser
Note: `iostat` version 11 and higher include a JSON output option
Usage (cli):
$ iostat | jc --iostat
@ -37,6 +39,8 @@ Schema:
"mb_read": integer,
"kb_wrtn": integer,
"mb_wrtn": integer,
'kb_dscd': integer,
'mb_dscd': integer,
"rrqm_s": float,
"wrqm_s": float,
"r_s": float,
@ -54,6 +58,17 @@ Schema:
"aqu_sz": float,
"rareq_sz": float,
"wareq_sz": float,
"d_s": float,
"dkb_s": float,
"dmb_s": float,
"drqm_s": float,
"percent_drqm": float,
"d_await": float,
"dareq_sz": float,
"f_s": float,
"f_await": float,
"kb_dscd_s": float,
"mb_dscd_s": float,
"percent_util": float,
"percent_rrqm": float,
"percent_wrqm": float

126
docs/parsers/iostat_s.md Normal file
View File

@ -0,0 +1,126 @@
[Home](https://kellyjonbrazil.github.io/jc/)
# jc.parsers.iostat_s
jc - JSON CLI output utility `iostat` command output streaming parser
> This streaming parser outputs JSON Lines
Note: `iostat` version 11 and higher include a JSON output option
Usage (cli):
$ iostat | jc --iostat-s
Usage (module):
import jc.parsers.iostat_s
result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines()) # result is an iterable object
for item in result:
# do something
Schema:
{
"type": string,
"percent_user": float,
"percent_nice": float,
"percent_system": float,
"percent_iowait": float,
"percent_steal": float,
"percent_idle": float,
"device": string,
"tps": float,
"kb_read_s": float,
"mb_read_s": float,
"kb_wrtn_s": float,
"mb_wrtn_s": float,
"kb_read": integer,
"mb_read": integer,
"kb_wrtn": integer,
"mb_wrtn": integer,
'kb_dscd': integer,
'mb_dscd': integer,
"rrqm_s": float,
"wrqm_s": float,
"r_s": float,
"w_s": float,
"rmb_s": float,
"rkb_s": float,
"wmb_s": float,
"wkb_s": float,
"avgrq_sz": float,
"avgqu_sz": float,
"await": float,
"r_await": float,
"w_await": float,
"svctm": float,
"aqu_sz": float,
"rareq_sz": float,
"wareq_sz": float,
"d_s": float,
"dkb_s": float,
"dmb_s": float,
"drqm_s": float,
"percent_drqm": float,
"d_await": float,
"dareq_sz": float,
"f_s": float,
"f_await": float,
"kb_dscd_s": float,
"mb_dscd_s": float,
"percent_util": float,
"percent_rrqm": float,
"percent_wrqm": float,
"_jc_meta": # This object only exists if using -qq or ignore_exceptions=True
{
"success": booean, # true if successfully parsed, false if error
"error": string, # exists if "success" is false
"line": string # exists if "success" is false
}
}
Examples:
$ iostat | jc --iostat-s
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,"percent_iowait":0.0,"percent_steal":0.0,"percent_idle":99.7,"type":"cpu"}
{"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1,"kb_read":203305,"kb_wrtn":42368,"type":"device"}
...
$ iostat | jc --iostat-s -r
{"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16","percent_iowait":"0.00","percent_steal":"0.00","percent_idle":"99.70","type":"cpu"}
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10","kb_read":"203305","kb_wrtn":"42368","type":"device"}
...
## info
```python
info()
```
Provides parser metadata (version, author, etc.)
## parse
```python
parse(data, raw=False, quiet=False, ignore_exceptions=False)
```
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) output preprocessed JSON 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
## Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@ -1,4 +1,4 @@
.TH jc 1 2021-12-01 1.17.3 "JSON CLI output utility"
.TH jc 1 2021-12-02 1.17.3 "JSON CLI output utility"
.SH NAME
jc \- JSONifies the output of many CLI tools and file-types
.SH SYNOPSIS
@ -182,6 +182,11 @@ INI file parser
\fB--iostat\fP
`iostat` command parser
.TP
.B
\fB--iostat-s\fP
`iostat` command streaming parser
.TP
.B
\fB--iptables\fP