2015-10-27 19:28:42 +01:00
|
|
|
#!/usr/bin/env bash
|
2010-12-01 15:23:50 +01:00
|
|
|
#
|
|
|
|
# Plugin to monitor a ZFS Filesystem
|
|
|
|
#
|
2018-08-02 02:03:42 +02:00
|
|
|
# Wildcard-plugin to monitor a zfs filesystems.
|
2010-12-30 09:33:43 +01:00
|
|
|
#
|
2010-12-01 15:23:50 +01:00
|
|
|
# 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
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2010-12-01 15:23:50 +01:00
|
|
|
# ...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)
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2010-12-30 09:33:43 +01:00
|
|
|
# ** WARNING **
|
|
|
|
# For now this plugin does not allow "_" in the name of a zpool or filesystems
|
2010-12-01 15:23:50 +01:00
|
|
|
#
|
|
|
|
|
2010-12-03 22:54:42 +01:00
|
|
|
myname=`basename $0 | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g'`
|
2010-12-01 15:23:50 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2010-12-04 19:05:12 +01:00
|
|
|
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;}') )
|
2010-12-01 15:23:50 +01:00
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
2010-12-30 09:33:43 +01:00
|
|
|
echo <<EOF "graph_title zfs $myname
|
|
|
|
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
|
2015-04-15 23:53:38 +02:00
|
|
|
graph_args --base 1024 -r -l 0 --vertical-label Bytes
|
2010-12-30 09:33:43 +01:00
|
|
|
graph_info This graph shows how is used a zfs filesystems.
|
2017-02-21 22:15:07 +01:00
|
|
|
graph_category fs
|
2010-12-30 09:33:43 +01:00
|
|
|
graph_period second
|
|
|
|
usedbydataset.label UsedByDataset
|
|
|
|
usedbydataset.draw AREA
|
|
|
|
usedbydataset.info Used space by Dataset
|
|
|
|
usedbydataset.colour FF0000
|
|
|
|
usedbychildren.label UsedByChildren
|
|
|
|
usedbychildren.draw STACK
|
|
|
|
usedbychildren.info Used space by children
|
|
|
|
usedbychildren.colour FFCC33
|
|
|
|
usedbysnapshots.label UsedBySnapshots
|
|
|
|
usedbysnapshots.draw STACK
|
|
|
|
usedbysnapshots.info Used space by snapshot
|
|
|
|
usedbysnapshots.colour 0000FF
|
|
|
|
usedbyrefreservation.label Usedbyrefreservation
|
|
|
|
usedbyrefreservation.draw STACK
|
|
|
|
usedbyrefreservation.info Used space by Ref Reservation
|
|
|
|
usedbyrefreservation.colour 33CCFF
|
|
|
|
available.label Available
|
|
|
|
available.draw STACK
|
|
|
|
available.info Free space
|
|
|
|
available.colour 00FF00
|
|
|
|
total.label Total
|
|
|
|
total.draw LINE1
|
|
|
|
total.info Total
|
|
|
|
total.colour 000000
|
|
|
|
quota.label Quota
|
|
|
|
quota.draw LINE1
|
|
|
|
quota.info Quota
|
|
|
|
quota.colour 555555"
|
|
|
|
EOF
|
2010-12-01 15:23:50 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2010-12-30 09:33:43 +01:00
|
|
|
echo <<EOF "usedbydataset.value ${values[0]}
|
|
|
|
usedbysnapshots.value ${values[2]}
|
|
|
|
usedbychildren.value ${values[1]}
|
|
|
|
usedbyrefreservation.value ${values[3]}
|
|
|
|
available.value ${values[4]}
|
|
|
|
total.value ${values[6]}
|
|
|
|
quota.value ${values[5]}"
|
|
|
|
EOF
|
2010-12-01 15:23:50 +01:00
|
|
|
|
|
|
|
exit 0
|