Discussion:
Getting state information out of ZFS in a program?
Chris Siebenmann
2013-08-26 20:37:28 UTC
Permalink
Is there currently any official or recommended way of getting state
information about pools out of ZFS in a program (ie, not by running
'zpool status' and so on and parsing the output)?

If there isn't any currently recommended way, do people have
opinions on what approach would be the best idea and the most
likely one to turn into a recommended way (or a supported API)
in the future?

(I know how to do it unofficially by extracting the current pool
configuration and state information from libzfs and then parsing it.
I'm wondering if there's a better, more future proof way.)

Thanks in advance.

- cks
Saso Kiselkov
2013-08-26 21:02:57 UTC
Permalink
Post by Chris Siebenmann
Is there currently any official or recommended way of getting state
information about pools out of ZFS in a program (ie, not by running
'zpool status' and so on and parsing the output)?
If there isn't any currently recommended way, do people have
opinions on what approach would be the best idea and the most
likely one to turn into a recommended way (or a supported API)
in the future?
(I know how to do it unofficially by extracting the current pool
configuration and state information from libzfs and then parsing it.
I'm wondering if there's a better, more future proof way.)
Thanks in advance.
Hi Chris,

Try having a look at libzfs_core - I remember this was tossed around a
while ago as being the future-proof method of accessing ZFS state in a
programmatic fashion. Maybe it will suit you.

Cheers,
--
Saso
Chris Siebenmann
2013-08-26 21:13:25 UTC
Permalink
Saso Kiselkov:
| On 8/26/13 9:37 PM, Chris Siebenmann wrote:
| > Is there currently any official or recommended way of getting state
| > information about pools out of ZFS in a program (ie, not by running
| > 'zpool status' and so on and parsing the output)?
| [...]
|
| Try having a look at libzfs_core - I remember this was tossed around a
| while ago as being the future-proof method of accessing ZFS state in a
| programmatic fashion. Maybe it will suit you.

I just took a look at libzfs_core in current Illumos git and right now
it appears to only be implementing ZFS operations, not anything to get
ZFS information.

(Hopefully it will acquire get-information functions in the future,
although one problem there is future-proofing the data that they
return.)

- cks
Matthew Ahrens
2013-09-08 13:14:57 UTC
Permalink
Post by Chris Siebenmann
| > Is there currently any official or recommended way of getting state
| > information about pools out of ZFS in a program (ie, not by running
| > 'zpool status' and so on and parsing the output)?
| [...]
|
| Try having a look at libzfs_core - I remember this was tossed around a
| while ago as being the future-proof method of accessing ZFS state in a
| programmatic fashion. Maybe it will suit you.
I just took a look at libzfs_core in current Illumos git and right now
it appears to only be implementing ZFS operations, not anything to get
ZFS information.
(Hopefully it will acquire get-information functions in the future,
although one problem there is future-proofing the data that they
return.)
Yes, that's a goal for libzfs_core.

What specific information are you looking for? E.g. which devices are part
of a pool, how full they are, scrub/resilver status, ...?

--matt



-------------------------------------------
illumos-zfs
Archives: https://www.listbox.com/member/archive/182191/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182191/23047029-187a0c8d
Modify Your Subscription: https://www.listbox.com/member/?member_id=23047029&id_secret=23047029-2e85923f
Powered by Listbox: http://www.listbox.com
Chris Siebenmann
2013-09-09 15:46:53 UTC
Permalink
| > Saso Kiselkov:
| > | On 8/26/13 9:37 PM, Chris Siebenmann wrote:
| > | > Is there currently any official or recommended way of getting state
| > | > information about pools out of ZFS in a program (ie, not by running
| > | > 'zpool status' and so on and parsing the output)?
| > | [...]
| > |
| > | Try having a look at libzfs_core - I remember this was tossed around a
| > | while ago as being the future-proof method of accessing ZFS state in a
| > | programmatic fashion. Maybe it will suit you.
| >
| > I just took a look at libzfs_core in current Illumos git and right now
| > it appears to only be implementing ZFS operations, not anything to get
| > ZFS information.
| >
| > (Hopefully it will acquire get-information functions in the future,
| > although one problem there is future-proofing the data that they
| > return.)
| >
| >
| Yes, that's a goal for libzfs_core.
|
| What specific information are you looking for? E.g. which devices are
| part of a pool, how full they are, scrub/resilver status, ...?

All of the above.

Our specific use is a system that handles status monitoring and
customized disk sparing and replacement in response to faults (and other
events). For this we need to know the pool device layout, the device
status, the space used on each vdev, and the status of any ongoing
scrubs and resilvers. For status monitoring we also look at things like
error counts and the amount of data repaired.

I have code today that extracts this information from the nvlist
hierarchy you get back from zpool_get_config() and dumps it in
a pseudo-JSON format (which we then postprocess with a separate
program). Obviously this is an internal and unstable interface so
periodically we get to reverse engineer what zpool does to report this
general information.

(I can make the code available if people want. I suspect that it's
not particularly interesting and some of it may be wrong, in that
I'm not correctly interpreting various fields.)

- cks

Loading...