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?
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
:and in snmpd.conf:
With zfs/zpool, you're blessed since most of the subcommands have options for machine output, which will make it easier to grok.
I don't know the answer for the zpool status, scrub, etc. but for space I figured something out.
in /etc/snmpd.config, I found this, and uncommented it, and now I have storage values:
And here is some output:
Unfortunately, the Size output (1024 GiB) is wrong. Storage size according to df is 20 TiB and used is 491 GiB, but for some reason, Size here is coincidentally exactly 2^31-1 * 512 bytes. (where 2^31-1 is the maximum value of a signed 32 bit integer). Used is correct though: 1030063349*512/1024/1024/1024 = 491.
Fortunately though, it works fine for my 80 GB root disk. I guess it is limited to 1 TiB on FreeBSD. This same mount seen using SNMP on a Linux NFS client shows the correct value and hrStorageAllocationUnits is "INTEGER: 32768 Bytes"