I would like to know if there is a way to access the ZFS api (preferably from python but C is fine too). My goal is to write some tools that will monitor my pools but would definitely like to not to have to parse output of zpool command.
3 Answers
There are java bindings to the libzfs on Solaris. AFAIK they haven't been ported (yet) to BSD or Linux. However, it might not be too big of an endeavour to start that, since it is Java after all, it could be relatively portable already.
IIRC the Java API was used for Solaris 10's ZFS Management Web Interface.
Also, I've heard rumors about a Python API (perhaps it was used in the new-style Autosnapshot service by Tim Foster?).
Here is a link to the latest bits I knew how to find
-
1This is quite an old answer now. Have a look at http://zfsonlinux.org/ to check whether they have better support now – sehe Jan 22 '14 at 11:28
Additionally if you are using OpenZFS (ie. ZFS on Illumos, FreeBSD, Linux, Mac OS X, etc.) there is now libzfs_core as alternative to libzfs (which was iirc never a stable API). See: http://blog.delphix.com/matt/2012/01/17/the-future-of-libzfs/

- 69,818
- 15
- 125
- 179

- 1,412
- 16
- 25
Well, it may not be a full answer but there is the libzfs library in /usr/lib
. The strange thing is that headers for libzfs (zfs.h and etc.) aren't installed and only present in kernel sources.
So, if you need to develop something using libzfs, you may try to install kernel sources and include needed headers from there.
-
yes i have noticed it already. what is even more weird is that if you try to load the shared object you get some errors just at the loading time – Dave Jan 03 '12 at 13:16