2020-07-30 16:20:24 -07:00
|
|
|
|
2020-07-09 16:18:33 -07:00
|
|
|
# jc.parsers.sysctl
|
|
|
|
jc - JSON CLI output utility sysctl -a Parser
|
|
|
|
|
2020-08-05 13:32:59 -07:00
|
|
|
Usage (cli):
|
2020-07-09 16:18:33 -07:00
|
|
|
|
|
|
|
specify --sysctl as the first argument if the piped input is coming from sysctl -a
|
|
|
|
|
|
|
|
Note: since sysctl output is not easily parsable only a very simple key/value object
|
2020-07-10 09:28:20 -07:00
|
|
|
will be output. An attempt is made to convert obvious integers and floats. If no
|
2020-07-09 16:18:33 -07:00
|
|
|
conversion is desired, use the -r (raw) option.
|
|
|
|
|
2020-08-05 13:32:59 -07:00
|
|
|
Usage (module):
|
|
|
|
|
|
|
|
import jc.parsers.sysctl
|
|
|
|
result = jc.parsers.sysctl.parse(sysctl_command_output)
|
|
|
|
|
2020-07-09 16:18:33 -07:00
|
|
|
Compatibility:
|
|
|
|
|
|
|
|
'linux', 'darwin', 'freebsd'
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ sysctl | jc --sysctl -p
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
...
|
|
|
|
}
|
|
|
|
|
|
|
|
$ sysctl | jc --sysctl -p -r
|
|
|
|
{
|
|
|
|
"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
|
|
|
```
|
|
|
|
|
2020-07-30 16:20:24 -07:00
|
|
|
|
2020-07-09 16:18:33 -07:00
|
|
|
## process
|
|
|
|
```python
|
|
|
|
process(proc_data)
|
|
|
|
```
|
|
|
|
|
|
|
|
Final processing to conform to the schema.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
proc_data: (dictionary) raw structured data to process
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
Dictionary. Structured data with the following schema:
|
|
|
|
|
2020-07-09 16:35:36 -07:00
|
|
|
{
|
|
|
|
"foo": string/integer/float, # best guess based on value
|
|
|
|
"bar": string/integer/float,
|
|
|
|
"baz": string/integer/float
|
|
|
|
}
|
2020-07-09 16:18:33 -07:00
|
|
|
|
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.
|
|
|
|
|