2021-09-22 14:38:13 -07:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.vmstat"></a>
|
2021-09-22 14:38:13 -07:00
|
|
|
|
|
|
|
# jc.parsers.vmstat
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2022-03-04 13:27:39 -08:00
|
|
|
jc - JSON Convert `vmstat` command output parser
|
2021-09-22 14:38:13 -07:00
|
|
|
|
|
|
|
Options supported: `-a`, `-w`, `-d`, `-t`
|
|
|
|
|
2022-01-19 17:30:14 -08:00
|
|
|
The `epoch` calculated timestamp field is naive. (i.e. based on the local
|
|
|
|
time of the system the parser is run on)
|
2021-09-24 10:11:15 -07:00
|
|
|
|
2022-01-19 17:30:14 -08:00
|
|
|
The `epoch_utc` calculated timestamp field is timezone-aware and is only
|
|
|
|
available if the timezone field is UTC.
|
2021-09-24 10:11:15 -07:00
|
|
|
|
2021-09-22 14:38:13 -07:00
|
|
|
Usage (cli):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ vmstat | jc --vmstat
|
2021-09-22 14:38:13 -07:00
|
|
|
|
2022-08-15 13:51:48 -07:00
|
|
|
or
|
2021-09-22 14:38:13 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
$ jc vmstat
|
2021-09-22 14:38:13 -07:00
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
import jc
|
|
|
|
result = jc.parse('vmstat', vmstat_command_output)
|
2022-01-18 15:38:03 -08:00
|
|
|
|
2021-09-22 14:38:13 -07:00
|
|
|
Schema:
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"runnable_procs": integer,
|
|
|
|
"uninterruptible_sleeping_procs": integer,
|
|
|
|
"virtual_mem_used": integer,
|
|
|
|
"free_mem": integer,
|
|
|
|
"buffer_mem": integer,
|
|
|
|
"cache_mem": integer,
|
|
|
|
"inactive_mem": integer,
|
|
|
|
"active_mem": integer,
|
|
|
|
"swap_in": integer,
|
|
|
|
"swap_out": integer,
|
|
|
|
"blocks_in": integer,
|
|
|
|
"blocks_out": integer,
|
|
|
|
"interrupts": integer,
|
|
|
|
"context_switches": integer,
|
|
|
|
"user_time": integer,
|
|
|
|
"system_time": integer,
|
|
|
|
"idle_time": integer,
|
|
|
|
"io_wait_time": integer,
|
|
|
|
"stolen_time": integer,
|
|
|
|
"disk": string,
|
|
|
|
"total_reads": integer,
|
|
|
|
"merged_reads": integer,
|
|
|
|
"sectors_read": integer,
|
|
|
|
"reading_ms": integer,
|
|
|
|
"total_writes": integer,
|
|
|
|
"merged_writes": integer,
|
|
|
|
"sectors_written": integer,
|
|
|
|
"writing_ms": integer,
|
|
|
|
"current_io": integer,
|
|
|
|
"io_seconds": integer,
|
|
|
|
"timestamp": string,
|
|
|
|
"timezone": string,
|
|
|
|
"epoch": integer, # [0]
|
|
|
|
"epoch_utc": integer # [1]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
[0] naive timestamp if -t flag is used
|
|
|
|
[1] aware timestamp if -t flag is used and UTC TZ
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ vmstat | jc --vmstat -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
}
|
|
|
|
]
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
<a id="jc.parsers.vmstat.parse"></a>
|
|
|
|
|
2022-03-05 12:15:14 -08:00
|
|
|
### parse
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2021-09-22 14:38:13 -07:00
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def parse(data, raw=False, quiet=False)
|
2021-09-22 14:38:13 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Parameters:
|
2021-09-22 14:38:13 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) unprocessed output if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
2021-09-22 14:38:13 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
Returns:
|
2021-09-22 14:38:13 -07:00
|
|
|
|
2022-01-25 18:03:34 -08:00
|
|
|
List of Dictionaries. Raw or processed structured data.
|
2021-09-22 14:38:13 -07:00
|
|
|
|
2022-01-25 19:18:54 -08:00
|
|
|
### Parser Information
|
2021-09-22 14:38:13 -07:00
|
|
|
Compatibility: linux
|
|
|
|
|
2022-07-16 20:52:19 -07:00
|
|
|
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|