2021-12-02 11:42:56 -08:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.iostat_s"></a>
|
|
|
|
|
2024-03-14 22:46:52 -07:00
|
|
|
# jc.parsers.iostat_s
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-03-04 13:27:39 -08:00
|
|
|
jc - JSON Convert `iostat` command output streaming parser
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-04-28 13:38:24 -07:00
|
|
|
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of
|
2022-05-26 15:07:54 -07:00
|
|
|
> Dictionaries (module)
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-05-26 15:07:54 -07:00
|
|
|
> Note: `iostat` version 11 and higher include a JSON output option
|
2021-12-02 11:42:56 -08:00
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ iostat | jc --iostat-s
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-03-10 13:32:26 -08:00
|
|
|
> Note: When piping `jc` converted `iostat` output to other processes it may
|
2022-05-26 15:07:54 -07:00
|
|
|
> 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.
|
2022-03-10 13:32:26 -08:00
|
|
|
|
2021-12-02 11:42:56 -08:00
|
|
|
Usage (module):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
import jc
|
2022-01-18 15:38:03 -08:00
|
|
|
|
2022-03-10 13:32:26 -08:00
|
|
|
result = jc.parse('iostat_s', iostat_command_output.splitlines())
|
2022-01-25 18:03:34 -08:00
|
|
|
for item in result:
|
|
|
|
# do something
|
2021-12-02 11:42:56 -08:00
|
|
|
|
|
|
|
Schema:
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
{
|
|
|
|
"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,
|
|
|
|
|
2022-03-10 10:10:57 -08:00
|
|
|
# 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
|
|
|
|
}
|
2022-01-25 18:03:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ iostat | jc --iostat-s
|
|
|
|
{"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"...}
|
|
|
|
...
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
<a id="jc.parsers.iostat_s.parse"></a>
|
|
|
|
|
2022-03-05 12:15:14 -08:00
|
|
|
### parse
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2021-12-02 11:42:56 -08:00
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def parse(data, raw=False, quiet=False, ignore_exceptions=False)
|
2021-12-02 11:42:56 -08:00
|
|
|
```
|
|
|
|
|
2022-04-28 13:30:11 -07:00
|
|
|
Main text parsing generator function. Returns an iterable object.
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Parameters:
|
2022-01-19 17:30:14 -08:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
data: (iterable) line-based text data to parse
|
|
|
|
(e.g. sys.stdin or str.splitlines())
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
raw: (boolean) unprocessed output if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
2022-02-04 12:14:16 -08:00
|
|
|
ignore_exceptions: (boolean) ignore parsing exceptions if True
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Returns:
|
|
|
|
|
2022-04-28 13:30:11 -07:00
|
|
|
Iterable of Dictionaries
|
2021-12-02 11:42:56 -08:00
|
|
|
|
2022-01-25 19:18:54 -08:00
|
|
|
### Parser Information
|
2021-12-02 11:42:56 -08:00
|
|
|
Compatibility: linux
|
|
|
|
|
2023-12-21 14:55:21 -08:00
|
|
|
Source: [`jc/parsers/iostat_s.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/iostat_s.py)
|
|
|
|
|
2022-11-22 13:11:41 -08:00
|
|
|
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|