Does OpenZFS have an API?

Developer discussions about the GUI.

Does OpenZFS have an API?

Postby randolph.kahle » Wed Jan 03, 2018 10:42 am

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.

Posts: 10
Joined: Fri Feb 24, 2017 8:13 am

Re: Does OpenZFS have an API?

Postby lundman » Fri Jan 05, 2018 12:24 am

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.

User avatar
Posts: 1327
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Does OpenZFS have an API?

Postby cbreak » Sat Jul 06, 2019 4:02 am

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
Posts: 13
Joined: Mon Sep 19, 2016 9:12 am

Re: Does OpenZFS have an API?

Postby Jacobjsdhfg » Mon Dec 11, 2023 1:50 am

It's great to hear that you're considering writing automation and monitoring tools for OpenZFSonOSX! To answer your question, OpenZFSonOSX does not have a dedicated API. If you prefer to call an API, you may need to explore alternative options or consider writing shell commands to parse the returned textual values. Good luck with your project! Drive Mad 2
Posts: 1
Joined: Mon Dec 11, 2023 1:49 am

Re: Does OpenZFS have an API?

Postby gea » Tue Feb 13, 2024 9:52 am

There are ongoing improvements in ZFS. They are in zfs and zpool and well documented.
Any 3rd party API would need constant work to follow development - does simply make no sense.

In my napp-it web-gui I call zfs and zpool directly and process return values, no problem with that.
With the -H option you get not only headerless outputs but also tab seperated lists.
Without the -H you often have the problem that a space in a list is a seperator what can give problems ex when a date is involved with spaces in it.
Posts: 7
Joined: Tue Jan 23, 2024 9:56 am

Return to GUI Development

Who is online

Users browsing this forum: No registered users and 2 guests