Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
zpool status -x still returns 0 if pools are unhealthy. –  bahamat Oct 2 '12 at 18:05

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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:

#
# Host resources module
#  This requires the mibII module.
#
begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so"

And here is some output:

# snmpwalk -v1 -c public $freebsdzfsmachine | grep -E "Storage.*\.22 " | less
HOST-RESOURCES-MIB::hrStorageIndex.22 = INTEGER: 22
HOST-RESOURCES-MIB::hrStorageType.22 = OID: HOST-RESOURCES-TYPES::hrFSOther
HOST-RESOURCES-MIB::hrStorageDescr.22 = STRING: /tank, type: zfs, dev: tank
HOST-RESOURCES-MIB::hrStorageAllocationUnits.22 = INTEGER: 512 Bytes
HOST-RESOURCES-MIB::hrStorageSize.22 = INTEGER: 2147483647
HOST-RESOURCES-MIB::hrStorageUsed.22 = INTEGER: 1030063349
HOST-RESOURCES-MIB::hrStorageAllocationFailures.22 = Counter32: 0
HOST-RESOURCES-MIB::hrFSStorageIndex.22 = INTEGER: 24

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"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.