icinga2-checks/checker/zfs.py

10 lines
410 B
Python

import subprocess
def zfs_get_free(zpool: str):
size = int(subprocess.check_output(f"zpool get -p -H size | grep {zpool} | awk '{{ print $3}}'", shell=True).decode().strip('\n'))
size_gb = int(size / 1e+9)
free = int(subprocess.check_output(f"zpool get -p -H free | grep {zpool} | awk '{{ print $3}}'", shell=True).decode().strip('\n'))
free_gb = int(free / 1e+9)
return size_gb, free_gb