#!/usr/bin/env bash # # Plugin to monitor a ZFS Filesystem # # Wildcard-plugin to monitor a zfs filesystems. # # To monitor a filesystem, link zfs_fs__ to this file. E.g. # # ln -s /usr/share/munin/node/plugins-auto/zfs_fs_ /etc/munin/node.d/zfs_fs_tank_foo # # ...will monitor tank/foo fs. # # You can monitor zpool as well by a link on zfs_fs_ # # Parameters understood: # # config (required) # autoconf (optional - used by munin-config) # # ** WARNING ** # For now this plugin does not allow "_" in the name of a zpool or filesystems # # #%# capabilities=autoconf # myname=$(basename "$0" | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g') if [ "$1" = "autoconf" ]; then if which zfs >/dev/null; then echo yes else echo "no (missing executable 'zfs')" fi exit 0 fi read -r -a values <<<"$(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota "$myname" \ | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}')" if [ "$1" = "config" ]; then echo <