Révision 9640be36
[zpool_iostat] remove usage of temporary file
| plugins/zfs/zpool_iostat | ||
|---|---|---|
| 12 | 12 |
fi |
| 13 | 13 |
|
| 14 | 14 |
zlines=$("$ZPOOL_BIN" iostat -v | wc -l | sed 's/ //g')
|
| 15 |
ztmp=/var/run/munin/zpool_iostat |
|
| 16 |
"$ZPOOL_BIN" iostat -v 1 1 | tail "-$zlines" > "$ztmp" |
|
| 17 |
zlist=$(gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}' "$ztmp")
|
|
| 18 |
zname=$(gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}' "$ztmp" | gawk '{gsub("[^a-zA-Z0-9_]", "_", $1); print}')
|
|
| 15 |
pool_iostat=$("$ZPOOL_BIN" iostat -v 1 1 | tail "-$zlines")
|
|
| 16 |
zlist=$(echo "$pool_iostat" | gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}')
|
|
| 17 |
zname=$(echo "$pool_iostat" | gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}' | gawk '{gsub("[^a-zA-Z0-9_]", "_", $1); print}')
|
|
| 19 | 18 |
zorder=$(for o in $zname; do echo "${o}_read "; echo "${o}_write "; done)
|
| 20 | 19 |
|
| 21 | 20 |
if [ "$1" = "config" ]; then |
| ... | ... | |
| 45 | 44 |
*) name=$(echo "$iz" | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }') ;;
|
| 46 | 45 |
esac |
| 47 | 46 |
echo -n "${name}_read.value "
|
| 48 |
gawk '{ if ($1 == "'"$zlabel"'") print $6; }' "$ztmp"|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
|
| 47 |
echo "$pool_iostat" | gawk '{ if ($1 == "'"$zlabel"'") print $6; }' | gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
|
| 49 | 48 |
echo -n "${name}_write.value "
|
| 50 |
gawk '{ if ($1 == "'"$zlabel"'") print $7; }' "$ztmp"|gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
|
| 49 |
echo "$pool_iostat" | gawk '{ if ($1 == "'"$zlabel"'") print $7; }' |gawk '/M/ {print strtonum($1)*1000}; /K/ {print strtonum($1)}; /[0-9]$/ {print int($1)/1000}'
|
|
| 51 | 50 |
done |
| 52 |
|
|
| 53 |
rm "$ztmp"; touch "$ztmp" |
|
Formats disponibles : Unified diff