2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/other/zfs-filesystem-graph
2011-12-18 15:10:31 +01:00

87 lines
2.7 KiB
Bash
Executable File

#!/usr/local/bin/bash
#
# Plugin to monitor a ZFS Filesystem
#
# Wildcard-plugin to monitor a zfs filesystems.
# To monitor a filesystem, link zfs_fs_<zpool>_<filesystem> 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_<zpool>
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=auto
#%# capabilities=autoconf
myname=`basename $0 | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g'`
if [ "$1" = "autoconf" ]; then
# Makes little sense to autoconf if you can't suggest
echo no
exit 0
fi
if [ "$1" = "suggest" ]; then
exit 0
fi
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 "graph_title zfs $myname"
echo 'graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota'
echo "graph_args --base 1024 -r -l 0 --vertical-label Bytes --upper-limit ${values[6]}"
echo 'graph_info This graph shows how is used a zfs filesystems.'
echo 'graph_category Zfs'
echo 'graph_period second'
echo 'usedbydataset.label UsedByDataset'
echo 'usedbydataset.draw AREA'
echo 'usedbydataset.info Used space by Dataset'
echo 'usedbydataset.colour FF0000'
echo 'usedbychildren.label UsedByChildren'
echo 'usedbychildren.draw STACK'
echo 'usedbychildren.info Used space by children'
echo 'usedbychildren.colour FFCC33'
echo 'usedbysnapshots.label UsedBySnapshots'
echo 'usedbysnapshots.draw STACK'
echo 'usedbysnapshots.info Used space by snapshot'
echo 'usedbysnapshots.colour 0000FF'
echo 'usedbyrefreservation.label Usedbyrefreservation'
echo 'usedbyrefreservation.draw STACK'
echo 'usedbyrefreservation.info Used space by Ref Reservation'
echo 'usedbyrefreservation.colour 33CCFF'
echo 'available.label Available'
echo 'available.draw STACK'
echo 'available.info Free space'
echo 'available.colour 00FF00'
echo 'total.label Total'
echo 'total.draw LINE1'
echo 'total.info Total'
echo 'total.colour 000000'
echo 'quota.label Quota'
echo 'quota.draw LINE1'
echo 'quota.info Quota'
echo 'quota.colour 555555'
exit 0
fi
echo "usedbydataset.value ${values[0]}"
echo "usedbysnapshots.value ${values[2]}"
echo "usedbychildren.value ${values[1]}"
echo "usedbyrefreservation.value ${values[3]}"
echo "available.value ${values[4]}"
echo "total.value ${values[6]}"
echo "quota.value ${values[5]}"
exit 0