-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Machine parsable "zpool status" #2626
Comments
I'm not sure - but why not use zdb -C output? Looks a bit more parseable and even contains full path:
|
Doesn't contain any status information. But otherwise very good - we could use some of that... |
Illumos uses a lot of json formatted settings. |
What about |
@behlendorf Why did this get closed without comment? Unless I'm missing something, this still isn't a solved problem. |
Indeed, this hasn't been resolved. I'm not sure why it was closed, although I seem to be the responsible party. Let me reopen it. There was some progress made in the area with the addition of the new |
Given the complexity of the data being displayed, JSON, YAML, TOML, or some other format may be most useful and also allow easy import into any environment with a parser for those. For example, piping the output into jq on the command line. |
Agreed - I'd argue json is probably best so you're not messing with newlines. |
I have never contributed to ZFS before but I would be willing to try an implementation and submit a pull request, unless somebody else is already working on it... |
It isn't prefect yet, but a bunch of the data can be gotten via the new vdev properties interface: so you could do: To get the status of all of the VDEVs I have wondered about exposing the rest of the status state, like status, action, scan, etc, as zpool properties as well. |
I'm not sure if this is something still being discussed, but I would really appreciate if all the data in zpool status could be exposed as properties, such as scrubs and status. Currently it's very difficult trying to parse zpool status for monitoring purpose, often ending up needing to do odd things like this: zpool status ${poolname} | grep "scrub in progress" &> /dev/null
if [[ "$?" == "0" ]] ; then
scrub=1
else
scrub=0
fi |
I decided to take a look to see how complicated this would be. Following Just updating the output functions to check for a JSON output option at every print would make the code hard to read and create a burden for any future status messages that might be added to ensure that the JSON output wouldn't break. If I was familiar with ZFS development (I haven't done any) and understood these structures and output status combinations better I'd probably have a go at creating a new "status_output" structure, update the existing I'm not sure if that's helpful for anyone who wants to give this a go. |
If anyone wanted to explore this, #2905 has some skeletons of what you might want, though obviously it's pretty stale. |
This would be pretty helpful, especially in cases where a pool is not
In the meantime you could parse output from https://github.com/openzfs/zfs/blob/816d2b2bfc2591b951f32aeb7c00e14e27ee624c/cmd/zpool_influxdb/README.md |
Good news: JSON support was recently added to many
This should be available in the upcoming 2.3 series. |
Closing since this was done for 2.3. |
I could really have used this in one of my GetDiskInfo scripts (and grub could need this as well).
It should not be to difficult to do (I'm offering :), but it should really be synchronized with OpenZFS/Illumos (THAT I do not volunteer to do though :) so they're on board with this.
For example (out of the top of my head without much thought :):
Original output:
New, parsable output:
Ok, so that's not very pretty. Needs more work. But it's a start...
The text was updated successfully, but these errors were encountered: