From d7efd25d88a8f489564ce48223845a16e4ab1cc7 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 11 Mar 2022 14:54:06 -0800 Subject: [PATCH] add mpstat to docs --- EXAMPLES.md | 64 +++++++++++++++++++ README.md | 1 + docs/parsers/mpstat.md | 136 +++++++++++++++++++++++++++++++++++++++++ man/jc.1 | 7 ++- 4 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 docs/parsers/mpstat.md diff --git a/EXAMPLES.md b/EXAMPLES.md index 943933db..21debe32 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -2149,6 +2149,29 @@ mount | jc --mount -p # or: jc -p mount } ] ``` +### mpstat +```bash +mpstat | jc --mpstat -p # or jc -p mpstat +``` +```json +[ + { + "cpu": "all", + "percent_usr": 12.94, + "percent_nice": 0.0, + "percent_sys": 26.42, + "percent_iowait": 0.43, + "percent_irq": 0.0, + "percent_soft": 0.16, + "percent_steal": 0.0, + "percent_guest": 0.0, + "percent_gnice": 0.0, + "percent_idle": 60.05, + "type": "cpu", + "time": "01:58:14 PM" + } +] +``` ### netstat ```bash netstat -apee | jc --netstat -p # or: jc -p netstat -apee @@ -2497,6 +2520,47 @@ cat /etc/passwd | jc --passwd -p } ] ``` +### pidstat +```bash +pidstat -hl | jc --pidstat -p # or jc -p pidstat -hl +``` +```json +[ + { + "time": 1646859134, + "uid": 0, + "pid": 1, + "percent_usr": 0.0, + "percent_system": 0.03, + "percent_guest": 0.0, + "percent_cpu": 0.03, + "cpu": 0, + "command": "/usr/lib/systemd/systemd --switched-root --system..." + }, + { + "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" + } +] +``` ### ping ```bash ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3 diff --git a/README.md b/README.md index 354e373d..21bf10c6 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,7 @@ option. - `--lsof` enables the `lsof` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof)) - `--lsusb` enables the `lsusb` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb)) - `--mount` enables the `mount` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mount)) +- `--mpstat` enables the `mpstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat)) - `--netstat` enables the `netstat` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/netstat)) - `--nmcli` enables the `nmcli` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/nmcli)) - `--ntpq` enables the `ntpq -p` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/ntpq)) diff --git a/docs/parsers/mpstat.md b/docs/parsers/mpstat.md new file mode 100644 index 00000000..588b7612 --- /dev/null +++ b/docs/parsers/mpstat.md @@ -0,0 +1,136 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.mpstat + +jc - JSON Convert `mpstat` command output parser + +Usage (cli): + + $ mpstat | jc --mpstat + + or + + $ jc mpstat + +Usage (module): + + import jc + result = jc.parse('mpstat', mpstat_command_output) + +Schema: + + [ + { + "type": string, + "time": string, + "cpu": string, + "average": boolean, + "percent_usr": float, + "percent_nice": float, + "percent_sys": float, + "percent_iowait": float, + "percent_irq": float, + "percent_soft": float, + "percent_steal": float, + "percent_guest": float, + "percent_gnice": float, + "percent_idle": float, + "intr_s": float, + "_s": float, # is an integer + "nmi_s": float, + "loc_s": float, + "spu_s": float, + "pmi_s": float, + "iwi_s": float, + "rtr_s": float, + "res_s": float, + "cal_s": float, + "tlb_s": float, + "trm_s": float, + "thr_s": float, + "dfr_s": float, + "mce_s": float, + "mcp_s": float, + "err_s": float, + "mis_s": float, + "pin_s": float, + "npi_s": float, + "piw_s": float, + "hi_s": float, + "timer_s": float, + "net_tx_s": float, + "net_rx_s": float, + "block_s": float, + "block_iopoll_s": float, + "tasklet_s": float, + "sched_s": float, + "hrtimer_s": float, + "rcu_s": float + } + ] + +Examples: + + $ mpstat | jc --mpstat -p + [ + { + "cpu": "all", + "percent_usr": 12.94, + "percent_nice": 0.0, + "percent_sys": 26.42, + "percent_iowait": 0.43, + "percent_irq": 0.0, + "percent_soft": 0.16, + "percent_steal": 0.0, + "percent_guest": 0.0, + "percent_gnice": 0.0, + "percent_idle": 60.05, + "type": "cpu", + "time": "01:58:14 PM" + } + ] + + $ mpstat | jc --mpstat -p -r + [ + { + "cpu": "all", + "percent_usr": "12.94", + "percent_nice": "0.00", + "percent_sys": "26.42", + "percent_iowait": "0.43", + "percent_irq": "0.00", + "percent_soft": "0.16", + "percent_steal": "0.00", + "percent_guest": "0.00", + "percent_gnice": "0.00", + "percent_idle": "60.05", + "type": "cpu", + "time": "01:58:14 PM" + } + ] + + + +### 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 + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/man/jc.1 b/man/jc.1 index 45711507..40ce7249 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2022-03-10 1.18.6 "JSON Convert" +.TH jc 1 2022-03-11 1.18.6 "JSON Convert" .SH NAME jc \- JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -252,6 +252,11 @@ Key/Value file parser \fB--mount\fP `mount` command parser +.TP +.B +\fB--mpstat\fP +`mpstat` command parser + .TP .B \fB--netstat\fP