Tracking free space on the ZFS Drive

Now that I’ve set up 2 drives on a RAID like configuration using ZFS, I want to see how much space I have left on the drive.

Because I’m using ZFS, it is not recognised as a standard drive in Ubuntu and as such it’s not possible to use standard Ubuntu utilities to keep track of disk usage.

You can use the following command to check the status of your ZFS pool:

sudo zpool list

However this is somewhat a manual action which requires opening a terminal. Since I use DomotiGa extensively, I wanted to display the free space on the ZFS device (already displayed thanks to the HDDTemp plugin).

I ended up with this python script:

# -*- coding: utf-8 -*-

import requests, subprocess
import json, json as simplejson

def Domotiga_API(Method, Device_Id, Valuenum, Value):
url = "http://localhost:9090" 
data={'jsonrpc': '2.0', 'method': '' + Method + '', 'params': {'device_id': Device_Id, 'valuenum': '' + str(Valuenum) + '', 'value': '' + str(Value) + ''}, 'id': 1}
headers = {'Content-type': 'application/json', 'Accept-Encoding': 'text/plain', 'Accept': 'text/plain'}
r =, data=json.dumps(data), headers=headers)
c = r.content
result = simplejson.loads(c)
#print result

p = subprocess.check_output(['sudo', '-S', 'zpool', 'list', '-o', 'alloc'], shell=False)
q = subprocess.check_output(['sudo', '-S', 'zpool', 'list', '-o', 'size'], shell=False)
c = subprocess.check_output(['sudo', '-S', 'zpool', 'list', '-o', 'cap'], shell=False)
mystring= p[6:11] + "/" + q[6:11]
Domotiga_API("device.set", 65, 2, mystring.strip())
Domotiga_API("device.set", 66, 2, mystring.strip())
Domotiga_API("device.set", 65, 3, c[6:10].strip())
Domotiga_API("device.set", 66, 3, c[6:10].strip())

I then set up an even in DomotiGa which launches bash script every 5 min:

echo "password" | sudo -S ~/domotiga/shell/

Replace password with your own sudo password of course.


ZFS Disk Space

ZFS Disk Space