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

82 lines
1.8 KiB
Markdown
Raw Normal View History

2020-07-30 16:20:24 -07:00
2020-07-09 16:18:33 -07:00
# jc.parsers.sysctl
2020-08-05 16:51:58 -07:00
jc - JSON CLI output utility `sysctl -a` command output parser
Note: Since `sysctl` output is not easily parsable only a very simple key/value object will be output. An attempt is made to convert obvious integers and floats. If no conversion is desired, use the `-r` command-line argument or the `raw=True` argument in `parse()`.
2020-07-09 16:18:33 -07:00
2020-08-05 13:32:59 -07:00
Usage (cli):
2020-07-09 16:18:33 -07:00
2020-08-05 16:51:58 -07:00
$ sysctl -a | jc --sysctl
or
2020-07-09 16:18:33 -07:00
2020-08-05 16:51:58 -07:00
$ jc sysctl -a
2020-07-09 16:18:33 -07:00
2020-08-05 13:32:59 -07:00
Usage (module):
import jc.parsers.sysctl
result = jc.parsers.sysctl.parse(sysctl_command_output)
2021-04-08 15:52:49 -07:00
Schema:
{
"key1": string/integer/float, # best guess based on value
"key2": string/integer/float,
"key3": string/integer/float
}
2020-07-09 16:18:33 -07:00
Compatibility:
'linux', 'darwin', 'freebsd'
Examples:
2020-08-05 16:51:58 -07:00
$ sysctl -a | jc --sysctl -p
2020-07-09 16:18:33 -07:00
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
"user.bc_dim_max": 2048,
"user.bc_scale_max": 99,
"user.bc_string_max": 1000,
"user.coll_weights_max": 2,
"user.expr_nest_max": 32
...
}
2020-08-05 16:51:58 -07:00
$ sysctl -a | jc --sysctl -p -r
2020-07-09 16:18:33 -07:00
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",
"user.bc_dim_max": "2048",
"user.bc_scale_max": "99",
"user.bc_string_max": "1000",
"user.coll_weights_max": "2",
"user.expr_nest_max": "32",
...
}
2020-07-30 16:20:24 -07:00
2020-07-09 16:18:33 -07:00
## info
```python
2020-07-30 16:20:24 -07:00
info()
2020-07-09 16:18:33 -07:00
```
2021-04-08 15:52:49 -07:00
Provides parser metadata (version, author, etc.)
2020-07-30 16:20:24 -07:00
2020-07-09 16:18:33 -07:00
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.