2011-03-23 23:44:38 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
fi
|
2011-01-23 00:07:49 +01:00
|
|
|
|
|
|
|
zlines=`/sbin/zpool iostat -v| wc -l|sed 's/ //g'`
|
|
|
|
ztail=`echo "-"$zlines`
|
|
|
|
ztmp=/var/run/munin/zpool_iostat
|
2011-03-23 23:44:38 +01:00
|
|
|
zdata=`/sbin/zpool iostat -v 1 1| tail $ztail > $ztmp`
|
|
|
|
zlist=`cat $ztmp|gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'`
|
|
|
|
zname=`cat $ztmp|gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'|gawk '{gsub("[^a-zA-Z0-9_]", "_", $1); print}'`
|
2011-01-23 00:07:49 +01:00
|
|
|
zorder=`for o in $zname; do echo $o'_read '; echo $o'_write '; done`
|
|
|
|
|
|
|
|
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 zfs'
|
|
|
|
echo 'graph_scale no'
|
|
|
|
echo 'graph_info This graph shows zpool iostat'
|
|
|
|
echo 'graph_order '$zorder
|
|
|
|
echo $zlist | tr ' ' '\n' | while read i; do
|
|
|
|
case $i in
|
2011-03-23 23:44:38 +01:00
|
|
|
*) name=`echo $i | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }'` ;;
|
2011-01-23 00:07:49 +01:00
|
|
|
esac
|
|
|
|
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'
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo $zlist | tr ' ' '\n' | while read iz; do
|
2011-03-23 23:44:38 +01:00
|
|
|
zlabel=`echo $iz|gawk '{print $1}'`
|
2011-01-23 00:07:49 +01:00
|
|
|
case $iz in
|
2011-03-23 23:44:38 +01:00
|
|
|
*) name=`echo $iz | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }'` ;;
|
2011-01-23 00:07:49 +01:00
|
|
|
esac
|
|
|
|
echo -n $name'_read.value '
|
2013-03-13 23:36:19 +01:00
|
|
|
grep '^[ ]*'$zlabel $ztmp|gawk '{print $6}'|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
2011-01-23 00:07:49 +01:00
|
|
|
echo -n $name'_write.value '
|
2013-03-13 23:36:19 +01:00
|
|
|
grep '^[ ]*'$zlabel $ztmp|gawk '{print $7}'|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
|
|
|
|
|
|
|
|
rm $ztmp; touch $ztmp
|