From 4612c1bc90bcfea79bc86a44ce27cdfa173999a3 Mon Sep 17 00:00:00 2001 From: Michael Grote <38253905+quotengrote@users.noreply.github.com> Date: Sun, 12 Dec 2021 20:59:52 +0100 Subject: [PATCH] plugin zfs_list: add "ignore_datasets_pattern" configuration Allow to ignore certain volumes. --- plugins/zfs/zfs_list | 64 +++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/plugins/zfs/zfs_list b/plugins/zfs/zfs_list index 1128b1ba..400840cc 100755 --- a/plugins/zfs/zfs_list +++ b/plugins/zfs/zfs_list @@ -1,21 +1,37 @@ #!/bin/bash -# -# Plugin to monitor ZFS Filesystems -# Author: Adam Michel (elfurbe@furbism.com) -# Description: -# This is an extension of the zfs_fs plugin -# modified as a multigraph to graph all zfs -# filesystems it can find -# -# Tested on Ubuntu-14.04 -# -# Parameters understood: -# -# config (required) -# autoconf (optional - used by munin-config) -# #%# family=auto +: << EOF +=head1 NAME +zfs_list - Plugin to monitor ZFS Filesystems + +This is an extension of the zfs_fs plugin +modified as a multigraph to graph all zfs +filesystems it can find + +=head1 CONFIGURATION +plugin config: +[zfs_list] +env.ignore_datasets_pattern + + +=head1 AUTHOR +=over 4 +=item * Adam Michel (elfurbe@furbism.com) +=back + + +=head1 MAGIC MARKERS +=begin comment +These magic markers are used by munin-node-configure when installing +munin-node. +=end comment + #%# family=auto +=cut + +EOF + + . "$MUNIN_LIBDIR/plugins/plugin.sh" need_multigraph() @@ -30,8 +46,20 @@ if [ "$1" = "suggest" ]; then exit 0 fi +# set standard value +ignore_datasets_pattern=${ignore_datasets_pattern:-} + +# set search term, based on if the searh pattern is set +if [ -n "$ignore_datasets_pattern" ]; then + search_term=$(zfs list -Hp -t filesystem,volume | grep -v "$ignore_datasets_pattern" | awk '{print $1}') +else + search_term=$(zfs list -Hp -t filesystem,volume | awk '{print $1}') +fi + + + if [ "$1" = "config" ]; then - for i in `zfs list -Hp -t filesystem,volume | awk '{print $1}'`; do + for i in $search_term; do values=( $(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota $i | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}') ) fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g')) @@ -39,7 +67,7 @@ if [ "$1" = "config" ]; then graph_title $fsname usage graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota graph_args --base 1024 -r -l 0 --vertical-label Bytes --upper-limit ${values[6]} -graph_info This graph shows how is used a zfs filesystems. +graph_info This graph shows how a zfs filesystem is used. graph_category fs graph_period second usedbydataset.label UsedByDataset @@ -75,7 +103,7 @@ EOF exit 0 fi -for i in `zfs list -Hp -t filesystem,volume | awk '{print $1}'`; do +for i in $search_term; do values=( $(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota $i | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}') ) fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g'))