2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/zfs/zpool_iostat

48 lines
1.9 KiB
Plaintext
Raw Normal View History

2016-12-04 15:12:59 +01:00
#!/bin/sh
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
2011-01-23 00:07:49 +01:00
2016-12-04 15:21:25 +01:00
zlines=$(/sbin/zpool iostat -v | wc -l | sed 's/ //g')
2011-01-23 00:07:49 +01:00
ztmp=/var/run/munin/zpool_iostat
2016-12-04 15:21:25 +01:00
/sbin/zpool iostat -v 1 1 | tail "-$zlines" > "$ztmp"
zlist=$(gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}' "$ztmp")
zname=$(gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}' "$ztmp" | gawk '{gsub("[^a-zA-Z0-9_]", "_", $1); print}')
zorder=$(for o in $zname; do echo "${o}_read "; echo "${o}_write "; done)
2011-01-23 00:07:49 +01:00
if [ "$1" = "config" ]; then
echo 'graph_title zpool iostat'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel write - read KBytes/s'
echo 'graph_category fs'
2011-01-23 00:07:49 +01:00
echo 'graph_scale no'
echo 'graph_info This graph shows zpool iostat'
2016-12-04 15:21:25 +01:00
echo "graph_order $zorder"
echo "$zlist" | tr ' ' '\n' | while read -r i; do
case "$i" in
*) name=$(echo "$i" | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }') ;;
2011-01-23 00:07:49 +01:00
esac
2016-12-04 15:21:25 +01:00
echo "${name}_read.label $i"
echo "${name}_read.type GAUGE"
echo "${name}_read.graph no"
echo "${name}_write.label $i"
echo "${name}_write.type GAUGE"
echo "${name}_write.negative ${name}_read"
2011-01-23 00:07:49 +01:00
done
exit 0
fi
2016-12-04 15:21:25 +01:00
echo "$zlist" | tr ' ' '\n' | while read -r iz; do
zlabel=$(echo "$iz" | gawk '{print $1}')
case "$iz" in
*) name=$(echo "$iz" | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }') ;;
2011-01-23 00:07:49 +01:00
esac
2016-12-04 15:21:25 +01:00
echo -n "${name}_read.value "
gawk '{ if ($1 == "'"$zlabel"'") print $6; }' "$ztmp"|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
2016-12-04 15:21:25 +01:00
echo -n "${name}_write.value "
gawk '{ if ($1 == "'"$zlabel"'") print $7; }' "$ztmp"|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
2011-01-23 00:07:49 +01:00
done
2016-12-04 15:21:25 +01:00
rm "$ztmp"; touch "$ztmp"