2022-09-06 10:07:19 -07:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
|
|
|
<a id="jc.parsers.proc"></a>
|
|
|
|
|
|
|
|
# jc.parsers.proc
|
|
|
|
|
|
|
|
jc - JSON Convert Proc file output parser
|
|
|
|
|
2022-09-06 11:42:24 -07:00
|
|
|
This parser automatically identifies the Proc file and calls the
|
2022-11-16 10:01:58 +08:00
|
|
|
corresponding parser to perform the parsing.
|
2022-09-07 12:31:17 -07:00
|
|
|
|
|
|
|
Magic syntax for converting `/proc` files is also supported by running
|
|
|
|
`jc /proc/<path to file>`. Any `jc` options must be specified before the
|
|
|
|
`/proc` path.
|
|
|
|
|
|
|
|
specific Proc file parsers can also be called directly, if desired and have
|
|
|
|
a naming convention of `proc-<name>` (cli) or `proc_<name>` (module).
|
2022-09-06 10:07:19 -07:00
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
2022-09-06 11:42:24 -07:00
|
|
|
$ cat /proc/meminfo | jc --proc
|
|
|
|
|
2022-09-07 12:31:17 -07:00
|
|
|
or
|
|
|
|
|
|
|
|
$ jc /proc/meminfo
|
|
|
|
|
2022-09-06 11:42:24 -07:00
|
|
|
or
|
|
|
|
|
|
|
|
$ cat /proc/meminfo | jc --proc-memifno
|
2022-09-06 10:07:19 -07:00
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
|
|
|
import jc
|
2022-09-06 11:42:24 -07:00
|
|
|
result = jc.parse('proc', proc_file)
|
2022-09-06 10:07:19 -07:00
|
|
|
|
|
|
|
Schema:
|
|
|
|
|
2022-09-06 11:42:24 -07:00
|
|
|
See the specific Proc parser for the schema:
|
|
|
|
|
|
|
|
$ jc --help --proc-<name>
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
$ jc --help --proc-meminfo
|
|
|
|
|
|
|
|
Specific Proc file parser names can be found with `jc -hh` or `jc -a`.
|
|
|
|
|
|
|
|
Schemas can also be found online at:
|
|
|
|
|
|
|
|
https://kellyjonbrazil.github.io/jc/docs/parsers/proc_<name>
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
https://kellyjonbrazil.github.io/jc/docs/parsers/proc_meminfo
|
2022-09-06 10:07:19 -07:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2022-09-06 11:46:35 -07:00
|
|
|
$ cat /proc/modules | jc --proc -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"module": "binfmt_misc",
|
|
|
|
"size": 24576,
|
|
|
|
"used": 1,
|
|
|
|
"used_by": [],
|
|
|
|
"status": "Live",
|
|
|
|
"location": "0xffffffffc0ab4000"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"module": "vsock_loopback",
|
|
|
|
"size": 16384,
|
|
|
|
"used": 0,
|
|
|
|
"used_by": [],
|
|
|
|
"status": "Live",
|
|
|
|
"location": "0xffffffffc0a14000"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"module": "vmw_vsock_virtio_transport_common",
|
|
|
|
"size": 36864,
|
|
|
|
"used": 1,
|
|
|
|
"used_by": [
|
|
|
|
"vsock_loopback"
|
|
|
|
],
|
|
|
|
"status": "Live",
|
|
|
|
"location": "0xffffffffc0a03000"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
|
2022-11-04 09:19:42 -07:00
|
|
|
$ cat /proc/modules | jc --proc-modules -p -r
|
2022-09-06 11:46:35 -07:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"module": "binfmt_misc",
|
|
|
|
"size": "24576",
|
|
|
|
"used": "1",
|
|
|
|
"used_by": [],
|
|
|
|
"status": "Live",
|
|
|
|
"location": "0xffffffffc0ab4000"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"module": "vsock_loopback",
|
|
|
|
"size": "16384",
|
|
|
|
"used": "0",
|
|
|
|
"used_by": [],
|
|
|
|
"status": "Live",
|
|
|
|
"location": "0xffffffffc0a14000"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"module": "vmw_vsock_virtio_transport_common",
|
|
|
|
"size": "36864",
|
|
|
|
"used": "1",
|
|
|
|
"used_by": [
|
|
|
|
"vsock_loopback"
|
|
|
|
],
|
|
|
|
"status": "Live",
|
|
|
|
"location": "0xffffffffc0a03000"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
2022-09-06 10:07:19 -07:00
|
|
|
|
|
|
|
<a id="jc.parsers.proc.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
|
|
|
|
|
2023-12-16 12:55:29 -08:00
|
|
|
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|