Page 1 of 1

Does OpenZFS have an API?

PostPosted: Wed Jan 03, 2018 10:42 am
by randolph.kahle
I am considering writing automation and monitoring tools for OpenZFSonOSX and I am wondering if there is an API.

If not, I'll have to write shell commands and parse the returned textual values - all possible, but I'd rather call an API.


Re: Does OpenZFS have an API?

PostPosted: Fri Jan 05, 2018 12:24 am
by lundman
Yes and no.

First, on the spawning of the commands, many options have "-H" for header less and some other option for machine parsable, so that is at least nice. There was ZOL work for JSON output as well.

Internally, libzfs is a pain to work with, so they started libzfs_core, which is what will be the API for calling processes. It is not done, but has a start. I think that Ryao over in ZOL land did some additional work on it, but I never saw a PR, so who knows what happened there.

Personally, I would do new code by just calling libzfs_core and libzfs, and just deal with that the library functions may just not work each time you update ZFS, and tweak the calling code. But if you want something that requires much less maintenance, spawning is probably the most stable.


Re: Does OpenZFS have an API?

PostPosted: Sat Jul 06, 2019 4:02 am
by cbreak
Depending on what you want to do, the C api in libzfs, libzfs_core and so on is ok in most places. I chose that route for ZetaWatch, after giving up on using the command line tools.

If you want a more higher level convenient interface, there's the part of ZetaWatch that interacts with ZFS is encapsulated in a ZFS Wrapper Library with a clean and easy C++ Interface: ... ZFSWrapper