1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/pidstat.md

155 lines
3.5 KiB
Markdown
Raw Normal View History

2022-03-09 14:06:34 -08:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.pidstat"></a>
# jc.parsers.pidstat
2022-09-22 14:35:53 -07:00
jc - JSON Convert `pidstat -H` command output parser
2022-03-09 14:06:34 -08:00
2022-09-22 14:35:53 -07:00
Must use the `-H` (or `-h`, if `-H` is not available) option in `pidstat`.
All other `pidstat` options are supported in combination with this option.
2022-03-09 14:06:34 -08:00
Usage (cli):
2022-09-22 14:41:40 -07:00
$ pidstat -H | jc --pidstat
2022-03-09 14:06:34 -08:00
2022-08-15 13:51:48 -07:00
or
2022-03-09 14:06:34 -08:00
2022-09-22 14:41:40 -07:00
$ jc pidstat -H
2022-03-09 14:06:34 -08:00
Usage (module):
import jc
result = jc.parse('pidstat', pidstat_command_output)
Schema:
[
{
"time": integer,
"uid": integer,
"pid": integer,
"percent_usr": float,
"percent_system": float,
"percent_guest": float,
"percent_cpu": float,
"cpu": integer,
"minflt_s": float,
"majflt_s": float,
"vsz": integer,
"rss": integer,
"percent_mem": float,
"stksize": integer,
"stkref": integer,
"kb_rd_s": float,
"kb_wr_s": float,
"kb_ccwr_s": float,
"cswch_s": float,
"nvcswch_s": float,
2023-10-01 11:25:56 -07:00
"usr_ms": integer,
"system_ms": integer,
"guest_ms": integer,
2022-03-09 14:06:34 -08:00
"command": string
}
]
Examples:
2022-09-22 14:35:53 -07:00
$ pidstat -Hl | jc --pidstat -p
2022-03-09 14:06:34 -08:00
[
{
"time": 1646859134,
"uid": 0,
"pid": 1,
"percent_usr": 0.0,
"percent_system": 0.03,
"percent_guest": 0.0,
"percent_cpu": 0.03,
"cpu": 0,
2022-03-09 15:09:22 -08:00
"command": "/usr/lib/systemd/systemd --switched-root --system..."
2022-03-09 14:06:34 -08:00
},
{
"time": 1646859134,
"uid": 0,
"pid": 6,
"percent_usr": 0.0,
"percent_system": 0.0,
"percent_guest": 0.0,
"percent_cpu": 0.0,
"cpu": 0,
"command": "ksoftirqd/0"
},
{
"time": 1646859134,
"uid": 0,
"pid": 2263,
"percent_usr": 0.0,
"percent_system": 0.0,
"percent_guest": 0.0,
"percent_cpu": 0.0,
"cpu": 0,
"command": "kworker/0:0"
}
]
2022-09-22 14:35:53 -07:00
$ pidstat -Hl | jc --pidstat -p -r
2022-03-09 14:06:34 -08:00
[
{
"time": "1646859134",
"uid": "0",
"pid": "1",
"percent_usr": "0.00",
"percent_system": "0.03",
"percent_guest": "0.00",
"percent_cpu": "0.03",
"cpu": "0",
2022-03-09 15:09:22 -08:00
"command": "/usr/lib/systemd/systemd --switched-root --system..."
2022-03-09 14:06:34 -08:00
},
{
"time": "1646859134",
"uid": "0",
"pid": "6",
"percent_usr": "0.00",
"percent_system": "0.00",
"percent_guest": "0.00",
"percent_cpu": "0.00",
"cpu": "0",
"command": "ksoftirqd/0"
},
{
"time": "1646859134",
"uid": "0",
"pid": "2263",
"percent_usr": "0.00",
"percent_system": "0.00",
"percent_guest": "0.00",
"percent_cpu": "0.00",
"cpu": "0",
"command": "kworker/0:0"
}
]
<a id="jc.parsers.pidstat.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-10-01 11:25:56 -07:00
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)