Ad Widget

Collapse

Solaris and FreeBSD: using zfs program to obtain advanced statistics on ZFS volumes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mounty
    Junior Member
    • Aug 2022
    • 5

    #1

    Solaris and FreeBSD: using zfs program to obtain advanced statistics on ZFS volumes

    man zfs-program describes the capabilities of the Lua interpreter built in to the ZFS subsystem.

    You can use this with the Zabbix agent to measure just about anything about zpools and zfs volumes but you have to jump through a couple of hoops. Here's a starter example: obtain the percentage free space in a zpool.

    Code:
    ~# cat /opt/ooce/zabbix/scripts/zfree.l
    args = ...
    pool = args["argv"][1]
    used = zfs.get_prop(pool,"used")
    available = zfs.get_prop(pool,"available")
    return available * 1000 / (used + available)​
    In /etc/opt/ooce/zabbix/zabbix_agentd.conf.d/zfs.conf:
    UserParameter=zfs.zpool.free[*],sudo -u root /usr/sbin/zfs program -jn $1 /opt/ooce/zabbix/scripts/zfree.l $1 | sed 's/{"return":\(.*\)}'
    The main hoop is that zfs program must be run as root, for some reason. So run visudo and add
    zabbixa ALL=(root:bin) NOPASSWD: /usr/sbin/zfs
    Then in your Zabbix server create an item with a key such as zfs.zpool.free[rpool] to get the free space on that pool. Now that the means of running zfs program is determined, you can obtain just about any metric about a pool.
  • Mounty
    Junior Member
    • Aug 2022
    • 5

    #2
    Erratum: in /etc/opt/ooce/zabbix/zabbix_agentd.conf.d/zfs.conf:
    UserParameter=zfs.zpool.free[*],sudo -u root /usr/sbin/zfs program -jn $1 /opt/ooce/zabbix/scripts/zfree.l $1 | sed 's/{"return":\(.*\)}/\1/'

    Comment

    Working...