mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
[zpool_iostat] fix shellcheck warnings
This commit is contained in:
parent
806a9172f4
commit
67af152b9e
1 changed files with 22 additions and 23 deletions
|
@ -5,13 +5,12 @@ if [ "$1" = "autoconf" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
zlines=`/sbin/zpool iostat -v| wc -l|sed 's/ //g'`
|
zlines=$(/sbin/zpool iostat -v | wc -l | sed 's/ //g')
|
||||||
ztail=`echo "-"$zlines`
|
|
||||||
ztmp=/var/run/munin/zpool_iostat
|
ztmp=/var/run/munin/zpool_iostat
|
||||||
zdata=`/sbin/zpool iostat -v 1 1| tail $ztail > $ztmp`
|
/sbin/zpool iostat -v 1 1 | tail "-$zlines" > "$ztmp"
|
||||||
zlist=`cat $ztmp|gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'`
|
zlist=$(gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}' "$ztmp")
|
||||||
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}'`
|
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`
|
zorder=$(for o in $zname; do echo "${o}_read "; echo "${o}_write "; done)
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo 'graph_title zpool iostat'
|
echo 'graph_title zpool iostat'
|
||||||
|
@ -20,29 +19,29 @@ if [ "$1" = "config" ]; then
|
||||||
echo 'graph_category fs'
|
echo 'graph_category fs'
|
||||||
echo 'graph_scale no'
|
echo 'graph_scale no'
|
||||||
echo 'graph_info This graph shows zpool iostat'
|
echo 'graph_info This graph shows zpool iostat'
|
||||||
echo 'graph_order '$zorder
|
echo "graph_order $zorder"
|
||||||
echo $zlist | tr ' ' '\n' | while read i; do
|
echo "$zlist" | tr ' ' '\n' | while read -r i; do
|
||||||
case $i in
|
case "$i" in
|
||||||
*) name=`echo $i | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }'` ;;
|
*) name=$(echo "$i" | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }') ;;
|
||||||
esac
|
esac
|
||||||
echo $name'_read.label '$i
|
echo "${name}_read.label $i"
|
||||||
echo $name'_read.type GAUGE'
|
echo "${name}_read.type GAUGE"
|
||||||
echo $name'_read.graph no'
|
echo "${name}_read.graph no"
|
||||||
echo $name'_write.label '$i
|
echo "${name}_write.label $i"
|
||||||
echo $name'_write.type GAUGE'
|
echo "${name}_write.type GAUGE"
|
||||||
echo $name'_write.negative '$name'_read'
|
echo "${name}_write.negative ${name}_read"
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo $zlist | tr ' ' '\n' | while read iz; do
|
echo "$zlist" | tr ' ' '\n' | while read -r iz; do
|
||||||
zlabel=`echo $iz|gawk '{print $1}'`
|
zlabel=$(echo "$iz" | gawk '{print $1}')
|
||||||
case $iz in
|
case "$iz" in
|
||||||
*) name=`echo $iz | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }'` ;;
|
*) name=$(echo "$iz" | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }') ;;
|
||||||
esac
|
esac
|
||||||
echo -n $name'_read.value '
|
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}'
|
gawk '{ if ($1 == "'"$zlabel"'") print $6; }' "$ztmp"|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
||||||
echo -n $name'_write.value '
|
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}'
|
gawk '{ if ($1 == "'"$zlabel"'") print $7; }' "$ztmp"|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
||||||
done
|
done
|
||||||
|
|
||||||
rm $ztmp; touch $ztmp
|
rm "$ztmp"; touch "$ztmp"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue