1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

add proc-vmstat parser

This commit is contained in:
Kelly Brazil
2022-09-17 13:34:40 -07:00
parent e5913cd10d
commit 906eeefa52
3 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,84 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.proc_vmstat"></a>
# jc.parsers.proc\_vmstat
jc - JSON Convert `/proc/vmstat` file parser
Usage (cli):
$ cat /proc/vmstat | jc --proc
or
$ jc /proc/vmstat
or
$ cat /proc/vmstat | jc --proc-vmstat
Usage (module):
import jc
result = jc.parse('proc', proc_vmstat_file)
or
import jc
result = jc.parse('proc_vmstat', proc_vmstat_file)
Schema:
All values are integers.
{
<keyName> integer
}
Examples:
$ cat /proc/vmstat | jc --proc -p
{
"nr_free_pages": 615337,
"nr_zone_inactive_anon": 39,
"nr_zone_active_anon": 34838,
"nr_zone_inactive_file": 104036,
"nr_zone_active_file": 130601,
"nr_zone_unevictable": 4897,
"nr_zone_write_pending": 45,
"nr_mlock": 4897,
"nr_page_table_pages": 548,
"nr_kernel_stack": 5984,
"nr_bounce": 0,
"nr_zspages": 0,
"nr_free_cma": 0,
"numa_hit": 1910597,
"numa_miss": 0,
"numa_foreign": 0,
...
}
<a id="jc.parsers.proc_vmstat.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> 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:
Dictionary. Raw or processed structured data.
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)

View File

@ -110,6 +110,7 @@ parsers = [
'proc-uptime', 'proc-uptime',
'proc-version', 'proc-version',
'proc-vmallocinfo', 'proc-vmallocinfo',
'proc-vmstat',
'proc-pid-numa-maps', 'proc-pid-numa-maps',
'ps', 'ps',
'route', 'route',

View File

@ -535,6 +535,11 @@ PLIST file parser
\fB--proc-vmallocinfo\fP \fB--proc-vmallocinfo\fP
`/proc/vmallocinfo` file parser `/proc/vmallocinfo` file parser
.TP
.B
\fB--proc-vmstat\fP
`/proc/vmstat` file parser
.TP .TP
.B .B
\fB--proc-pid-numa-maps\fP \fB--proc-pid-numa-maps\fP