2023-02-05 09:49:32 -08:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
|
|
|
<a id="jc.parsers.zpool_status"></a>
|
|
|
|
|
2024-03-14 22:46:52 -07:00
|
|
|
# jc.parsers.zpool_status
|
2023-02-05 09:49:32 -08:00
|
|
|
|
|
|
|
jc - JSON Convert `zpool status` command output parser
|
|
|
|
|
|
|
|
Works with or without the `-v` option.
|
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
2023-02-05 09:52:59 -08:00
|
|
|
$ zpool status | jc --zpool-status
|
2023-02-05 09:49:32 -08:00
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
$ jc zpool status
|
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
|
|
|
import jc
|
|
|
|
result = jc.parse('zpool_status', zpool_status_command_output)
|
|
|
|
|
|
|
|
Schema:
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"pool": string,
|
|
|
|
"state": string,
|
|
|
|
"status": string,
|
|
|
|
"action": string,
|
|
|
|
"see": string,
|
|
|
|
"scan": string,
|
|
|
|
"scrub": string,
|
|
|
|
"config": [
|
|
|
|
{
|
|
|
|
"name": string,
|
2024-05-10 11:11:31 -07:00
|
|
|
"state": string/null,
|
|
|
|
"read": integer/null,
|
|
|
|
"write": integer/null,
|
|
|
|
"checksum": integer/null,
|
|
|
|
"errors": string/null,
|
2023-02-05 09:49:32 -08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"errors": string
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2023-02-05 09:52:59 -08:00
|
|
|
$ zpool status -v | jc --zpool-status -p
|
2023-02-05 09:49:32 -08:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"pool": "tank",
|
|
|
|
"state": "DEGRADED",
|
2023-02-05 13:04:32 -08:00
|
|
|
"status": "One or more devices could not be opened. Suffic...",
|
|
|
|
"action": "Attach the missing device and online it using 'zpool...",
|
2023-02-05 09:49:32 -08:00
|
|
|
"see": "http://www.sun.com/msg/ZFS-8000-2Q",
|
|
|
|
"scrub": "none requested",
|
|
|
|
"config": [
|
|
|
|
{
|
|
|
|
"name": "tank",
|
|
|
|
"state": "DEGRADED",
|
|
|
|
"read": 0,
|
|
|
|
"write": 0,
|
|
|
|
"checksum": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "mirror-0",
|
|
|
|
"state": "DEGRADED",
|
|
|
|
"read": 0,
|
|
|
|
"write": 0,
|
|
|
|
"checksum": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "c1t0d0",
|
|
|
|
"state": "ONLINE",
|
|
|
|
"read": 0,
|
|
|
|
"write": 0,
|
|
|
|
"checksum": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "c1t1d0",
|
|
|
|
"state": "UNAVAIL",
|
|
|
|
"read": 0,
|
|
|
|
"write": 0,
|
|
|
|
"checksum": 0,
|
|
|
|
"errors": "cannot open"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"errors": "No known data errors"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-02-05 09:52:59 -08:00
|
|
|
$ zpool status -v | jc --zpool-status -p -r
|
2023-02-05 09:49:32 -08:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"pool": "tank",
|
|
|
|
"state": "DEGRADED",
|
2023-02-05 13:04:32 -08:00
|
|
|
"status": "One or more devices could not be opened. Sufficient...",
|
|
|
|
"action": "Attach the missing device and online it using 'zpool...",
|
2023-02-05 09:49:32 -08:00
|
|
|
"see": "http://www.sun.com/msg/ZFS-8000-2Q",
|
|
|
|
"scrub": "none requested",
|
|
|
|
"config": [
|
|
|
|
{
|
|
|
|
"name": "tank",
|
|
|
|
"state": "DEGRADED",
|
|
|
|
"read": "0",
|
|
|
|
"write": "0",
|
|
|
|
"checksum": "0"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "mirror-0",
|
|
|
|
"state": "DEGRADED",
|
|
|
|
"read": "0",
|
|
|
|
"write": "0",
|
|
|
|
"checksum": "0"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "c1t0d0",
|
|
|
|
"state": "ONLINE",
|
|
|
|
"read": "0",
|
|
|
|
"write": "0",
|
|
|
|
"checksum": "0"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "c1t1d0",
|
|
|
|
"state": "UNAVAIL",
|
|
|
|
"read": "0",
|
|
|
|
"write": "0",
|
|
|
|
"checksum": "0",
|
|
|
|
"errors": "cannot open"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"errors": "No known data errors"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
<a id="jc.parsers.zpool_status.parse"></a>
|
|
|
|
|
|
|
|
### parse
|
|
|
|
|
|
|
|
```python
|
|
|
|
def parse(data: str,
|
|
|
|
raw: bool = False,
|
2024-03-14 22:46:52 -07:00
|
|
|
quiet: bool = False) -> List[Dict[str, Any]]
|
2023-02-05 09:49:32 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
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, darwin, freebsd
|
|
|
|
|
2023-12-21 14:55:21 -08:00
|
|
|
Source: [`jc/parsers/zpool_status.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/zpool_status.py)
|
|
|
|
|
2024-05-10 11:06:05 -07:00
|
|
|
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|