From 498e871d22d191bfbbcba4d20451a29d6cbc5ca8 Mon Sep 17 00:00:00 2001 From: yoannmoulin Date: Sat, 4 Dec 2010 19:05:12 +0100 Subject: [PATCH] decrease numbers of fork --- plugins/other/zfs-filesystem-graph | 33 +++++++++--------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/plugins/other/zfs-filesystem-graph b/plugins/other/zfs-filesystem-graph index 145c03ff..f8bc96a1 100755 --- a/plugins/other/zfs-filesystem-graph +++ b/plugins/other/zfs-filesystem-graph @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/local/bin/bash # # Plugin to monitor a ZFS Filesystem # @@ -24,9 +24,6 @@ myname=`basename $0 | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g'` -name="${name-\<$myname\>}" -REGEX="${regex-\<$name\>}" - if [ "$1" = "autoconf" ]; then # Makes little sense to autoconf if you can't suggest echo no @@ -37,20 +34,13 @@ if [ "$1" = "suggest" ]; then exit 0 fi -usedbydataset=`zfs get -p usedbydataset $myname | grep $myname | awk '{print $3}'` -usedbychildren=`zfs get -p usedbychildren $myname | grep $myname | awk '{print $3}'` -usedbysnapshots=`zfs get -p usedbysnapshots $myname | grep $myname | awk '{print $3}'` -usedbyrefreservation=`zfs get -p usedbyrefreservation $myname | grep $myname | awk '{print $3}'` -available=`zfs get -p available $myname | grep $myname | awk '{print $3}'` -quota=`zfs get -p quota $myname | grep $myname | awk '{print $3}'` -total=$((usedbydataset+usedbysnapshots+available+usedbychildren+usedbyrefreservation)) - +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 $total" + 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' @@ -85,15 +75,12 @@ if [ "$1" = "config" ]; then exit 0 fi - - -echo "usedbydataset.value $usedbydataset" -echo "usedbysnapshots.value $usedbysnapshots" -echo "usedbychildren.value $usedbychildren" -echo "usedbyrefreservation.value $usedbyrefreservation" -echo "available.value $available" -echo "total.value $total" -echo "quota.value $quota" - +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