From 0429e63be5670f57b053411c37e4c8d92258c92b Mon Sep 17 00:00:00 2001 From: Sephtex Date: Sun, 3 Feb 2019 15:10:13 +0100 Subject: [PATCH 1/4] Add support for dash in zfs_list #969 zfs/zfs_list: Add support for dash in zfs_list --- plugins/zfs/zfs_list | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/zfs/zfs_list b/plugins/zfs/zfs_list index 72134b74..3550fb05 100755 --- a/plugins/zfs/zfs_list +++ b/plugins/zfs/zfs_list @@ -31,7 +31,7 @@ fi if [ "$1" = "config" ]; then for i in `zfs list -Hp | awk '{print $1}'`; 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=`echo $i | sed 's/\//__/g'` + fsname=`echo $i | sed 's/\//__/g' | sed 's/-/_/g'` echo < Date: Sun, 3 Feb 2019 19:10:56 +0100 Subject: [PATCH 2/4] add usage of clean_fieldname Used the correct munin way by soursing "$MUNIN_LIBDIR/plugins/plugin.sh" and use clean_fieldname. For the title I removed the replacement of / by __ and on the multigraph value I added the usage of clean_fieldname to make it backwards compatible. --- plugins/zfs/zfs_list | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/zfs/zfs_list b/plugins/zfs/zfs_list index 3550fb05..1e9d48a3 100755 --- a/plugins/zfs/zfs_list +++ b/plugins/zfs/zfs_list @@ -16,6 +16,8 @@ # #%# family=auto +. "$MUNIN_LIBDIR/plugins/plugin.sh" + need_multigraph() if [ "$1" = "autoconf" ]; then @@ -31,7 +33,7 @@ fi if [ "$1" = "config" ]; then for i in `zfs list -Hp | awk '{print $1}'`; 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=`echo $i | sed 's/\//__/g' | sed 's/-/_/g'` + fsname=$(clean_fieldname "$i") echo < Date: Sun, 3 Feb 2019 19:12:54 +0100 Subject: [PATCH 3/4] indentation fix added same indentation of the echo as all the rest in the for loop --- plugins/zfs/zfs_list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/zfs/zfs_list b/plugins/zfs/zfs_list index 1e9d48a3..5add8979 100755 --- a/plugins/zfs/zfs_list +++ b/plugins/zfs/zfs_list @@ -79,7 +79,7 @@ for i in `zfs list -Hp | awk '{print $1}'`; 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')) -echo < Date: Sun, 3 Feb 2019 19:55:16 +0100 Subject: [PATCH 4/4] replace the / by __ anyway To make it more clear that we had a subdevice it's better to use the __ for it's replacement anyway --- plugins/zfs/zfs_list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/zfs/zfs_list b/plugins/zfs/zfs_list index 5add8979..c7abf7da 100755 --- a/plugins/zfs/zfs_list +++ b/plugins/zfs/zfs_list @@ -33,7 +33,7 @@ fi if [ "$1" = "config" ]; then for i in `zfs list -Hp | awk '{print $1}'`; 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 "$i") + fsname=$(clean_fieldname $(echo "$i" | sed 's/\//__/g')) echo <