Révision 02630d31
add zfs plugins (#1250)
| plugins/zfs/zfs_pool_dataset_count | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
#%# family=auto |
|
| 3 |
|
|
| 4 |
: << EOF |
|
| 5 |
=head1 NAME |
|
| 6 |
zfs_pool_dataset_count - Outputs the count of zfs pools, datasets and snapshots. |
|
| 7 |
|
|
| 8 |
|
|
| 9 |
=head1 AUTHOR |
|
| 10 |
=over 4 |
|
| 11 |
=item * Michael Grote |
|
| 12 |
=back |
|
| 13 |
|
|
| 14 |
=head1 LICENSE |
|
| 15 |
GPLv3 or later |
|
| 16 |
|
|
| 17 |
SPDX-License-Identifier: GPL-3.0-or-later |
|
| 18 |
|
|
| 19 |
=head1 MAGIC MARKERS |
|
| 20 |
=begin comment |
|
| 21 |
These magic markers are used by munin-node-configure when installing |
|
| 22 |
munin-node. |
|
| 23 |
=end comment |
|
| 24 |
#%# family=auto |
|
| 25 |
=cut |
|
| 26 |
|
|
| 27 |
EOF |
|
| 28 |
|
|
| 29 |
if [ "$1" = "autoconf" ]; then |
|
| 30 |
if ! command -v zpool &> /dev/null; then |
|
| 31 |
echo "no (zpool could not be found)" |
|
| 32 |
else |
|
| 33 |
echo "yes" |
|
| 34 |
fi |
|
| 35 |
exit 0 |
|
| 36 |
fi |
|
| 37 |
|
|
| 38 |
|
|
| 39 |
# lese alle pools, sed löscht die erste zeile |
|
| 40 |
list_pools=$(zpool list | sed 1d) |
|
| 41 |
|
|
| 42 |
|
|
| 43 |
if [ "$1" = "config" ]; then |
|
| 44 |
# https://superuser.com/questions/284187/bash-iterating-over-lines-in-a-variable |
|
| 45 |
while read -r line; do |
|
| 46 |
# setze label <pool>.label <pool> snapshots |
|
| 47 |
echo "$line" | awk '{print $1"_snapshot.label " $1 " snapshots"}'
|
|
| 48 |
echo "$line" | awk '{print $1"_dataset.label " $1 " datasets"}'
|
|
| 49 |
done <<< "$list_pools" |
|
| 50 |
echo 'pools.label pools' |
|
| 51 |
# setze optionen |
|
| 52 |
echo 'graph_title zfs - pool, dataset and snapshot count' # Titelzeile |
|
| 53 |
echo 'graph_vlabel count' # Text links, hochkant |
|
| 54 |
echo 'graph_category fs' # Kategorie |
|
| 55 |
echo 'graph_args -l 0' # wertebegrenzer 0-100 |
|
| 56 |
exit 0 |
|
| 57 |
fi |
|
| 58 |
|
|
| 59 |
# lese jede Zeile der Variable $list |
|
| 60 |
# tue für jede Zeile |
|
| 61 |
# "echo" die Zeile, wende awk drauf, Spalte $1/$7 |
|
| 62 |
while read -r line; do |
|
| 63 |
echo pools.value "$(zpool list | sed 1d | wc -l)" |
|
| 64 |
# setze poolnamen |
|
| 65 |
poolname=$(echo "$line" | awk '{ print $1 }')
|
|
| 66 |
# zähle snapshots |
|
| 67 |
echo "${poolname}_snapshot.value" "$(zfs list -r -t snapshot "$poolname" | sed 1d | wc -l)"
|
|
| 68 |
echo "$poolname""_dataset.value" "$(zfs list -r "$poolname" | sed 1d | wc -l)" |
|
| 69 |
done <<< "$list_pools" |
|
| 70 |
exit 0 |
|
| plugins/zfs/zpool_fragmentation | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
#%# family=auto |
|
| 3 |
|
|
| 4 |
: << EOF |
|
| 5 |
=head1 NAME |
|
| 6 |
zpool_fragmentation - Outputs the zpool fragmentation per zfs pool. |
|
| 7 |
|
|
| 8 |
|
|
| 9 |
=head1 AUTHOR |
|
| 10 |
=over 4 |
|
| 11 |
=item * Michael Grote |
|
| 12 |
=back |
|
| 13 |
|
|
| 14 |
=head1 LICENSE |
|
| 15 |
GPLv3 or later |
|
| 16 |
|
|
| 17 |
SPDX-License-Identifier: GPL-3.0-or-later |
|
| 18 |
|
|
| 19 |
=head1 MAGIC MARKERS |
|
| 20 |
=begin comment |
|
| 21 |
These magic markers are used by munin-node-configure when installing |
|
| 22 |
munin-node. |
|
| 23 |
=end comment |
|
| 24 |
#%# family=auto |
|
| 25 |
=cut |
|
| 26 |
|
|
| 27 |
EOF |
|
| 28 |
|
|
| 29 |
if [ "$1" = "autoconf" ]; then |
|
| 30 |
if ! command -v zpool &> /dev/null; then |
|
| 31 |
echo "no (zpool could not be found!)" |
|
| 32 |
else |
|
| 33 |
echo "yes" |
|
| 34 |
fi |
|
| 35 |
exit 0 |
|
| 36 |
fi |
|
| 37 |
|
|
| 38 |
# lese alle pools, sed löscht die erste zeile |
|
| 39 |
# entferne das %-zeichen |
|
| 40 |
list=$(zpool list | sed 1d | tr -d %) |
|
| 41 |
|
|
| 42 |
|
|
| 43 |
if [ "$1" = "config" ]; then |
|
| 44 |
# https://superuser.com/questions/284187/bash-iterating-over-lines-in-a-variable |
|
| 45 |
while read -r line; do |
|
| 46 |
# setze label |
|
| 47 |
echo "$line" | awk '{print $1".label " $1}'
|
|
| 48 |
# setze warn-limits |
|
| 49 |
echo "$line" | awk '{print $1".warning " 50}'
|
|
| 50 |
echo "$line" | awk '{print $1".critical " 75}'
|
|
| 51 |
done <<< "$list" |
|
| 52 |
# setze optionen |
|
| 53 |
echo 'graph_title ZFS storage pool - fragmentation' # Titelzeile |
|
| 54 |
echo 'graph_vlabel fragmentation in %' # Text links, hochkant |
|
| 55 |
echo 'graph_category fs' # Kategorie |
|
| 56 |
echo 'graph_info This graph shows the ZFS Pool fragmentation.' # Text über Tabelle/Infos |
|
| 57 |
echo 'graph_args -l 0 --upper-limit 100' # wertebegrenzer 0-100 |
|
| 58 |
exit 0 |
|
| 59 |
fi |
|
| 60 |
|
|
| 61 |
# lese jede Zeile der Variable $list |
|
| 62 |
# tue für jede Zeile |
|
| 63 |
# "echo" die Zeile, wende awk drauf, Spalte $1/$7 |
|
| 64 |
while read -r line; do |
|
| 65 |
# gebe wert aus |
|
| 66 |
# <name>.value <wert> |
|
| 67 |
echo "$line" | awk '{print $1".value " $7}'
|
|
| 68 |
done <<< "$list" |
|
| 69 |
exit 0 |
|
Formats disponibles : Unified diff