Freebsd – How to monitor ZFS with SNMP in FreeBSD

freebsdsnmpzfs

I'd like to monitor these with SNMP:

zpool iostat -v 1

Per drive and sum.

zpool status

Scrubbing as 1 and not scrubbing as 0.

zpool status -x

Monitor $? (return value). Send trap when value is not 0.

zfs list

Used & free space.

What kind of scripts are needed?

Best Answer

Assuming you're using net-snmpd, you'd probably need to write a script per value. Then, using the techniques described in the snmpd.conf man page, section 'extending agent functionality', add references of those scripts to your snmpd.conf.

For example, /root/bin/myzstatus:

#!/bin/sh
/sbin/zpool status -x $1

and in snmpd.conf:

extend status /root/bin/myzstatus tank

With zfs/zpool, you're blessed since most of the subcommands have options for machine output, which will make it easier to grok.