From a194f4c430216655a0603482dd4c7746e8505c23 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Wed, 15 Sep 2021 21:03:00 +0200 Subject: [PATCH] zpool_fragmentation --- zpool_fragmentation | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 zpool_fragmentation diff --git a/zpool_fragmentation b/zpool_fragmentation new file mode 100644 index 0000000..79c238a --- /dev/null +++ b/zpool_fragmentation @@ -0,0 +1,43 @@ +#!/bin/bash +#%# family=auto +#%# capabilities=autoconf + +# selbst geschrieben + +# lese alle pool, lösche die erste zeile +# entferne das %-zeichen +list=$(zpool list | sed 1d | tr -d %) + +# wenn parameter = ... +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + # https://superuser.com/questions/284187/bash-iterating-over-lines-in-a-variable + while read -r line; do + # setze label + echo $line | awk '{print $1".label " $1}' + # setze warn-limits + echo $line | awk '{print $1".warning " 50}' + echo $line | awk '{print $1".critical " 75}' + done <<< "$list" + # setze optionen + echo 'graph_title zpool fragmentation' + echo 'graph_vlabel fragmentation in %' + echo 'graph_category fs' + echo 'graph_info This graph shows the ZFS Pool fragmentation.' + echo 'graph_args -l 0 --upper-limit 100' + exit 0 +fi + +# lese jede Zeile der Variable $list +# tue für jede Zeile +# "echo" die Zeile, wende awk drauf, Spalte $1/$7 +while read -r line; do + # gebe wert aus + # .value + echo $line | awk '{print $1".value " $7}' +done <<< "$list" +exit 0