2021-09-15 21:03:00 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
2021-09-15 23:47:27 +02:00
|
|
|
# Michael Grote
|
|
|
|
# michael.grote ät posteo.de
|
|
|
|
# Outputs the zpool fragmentation per zfs pool.
|
2021-09-15 21:03:00 +02:00
|
|
|
|
2021-09-16 00:08:32 +02:00
|
|
|
# lese alle pools, sed löscht die erste zeile
|
2021-09-15 21:03:00 +02:00
|
|
|
# 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
|
2021-10-01 11:01:43 +02:00
|
|
|
echo "$line" | awk '{print $1".label " $1}'
|
2021-09-15 21:03:00 +02:00
|
|
|
# setze warn-limits
|
2021-10-01 11:01:43 +02:00
|
|
|
echo "$line" | awk '{print $1".warning " 50}'
|
|
|
|
echo "$line" | awk '{print $1".critical " 75}'
|
2021-09-15 21:03:00 +02:00
|
|
|
done <<< "$list"
|
|
|
|
# setze optionen
|
2021-09-17 08:42:34 +02:00
|
|
|
echo 'graph_title ZFS storage pool - fragmentation' # Titelzeile
|
2021-09-15 22:45:10 +02:00
|
|
|
echo 'graph_vlabel fragmentation in %' # Text links, hochkant
|
|
|
|
echo 'graph_category fs' # Kategorie
|
|
|
|
echo 'graph_info This graph shows the ZFS Pool fragmentation.' # Text über Tabelle/Infos
|
|
|
|
echo 'graph_args -l 0 --upper-limit 100' # wertebegrenzer 0-100
|
2021-09-15 21:03:00 +02:00
|
|
|
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
|
|
|
|
# <name>.value <wert>
|
2021-10-01 11:01:43 +02:00
|
|
|
echo "$line" | awk '{print $1".value " $7}'
|
2021-09-15 21:03:00 +02:00
|
|
|
done <<< "$list"
|
|
|
|
exit 0
|