mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-23 06:35:42 +00:00
Fixed a few issues where it was ignoring values that did not end in K or M. Also made the script compatible with OpenSolaris using gawk.
This commit is contained in:
parent
7a0da0b2cc
commit
36b0898dba
1 changed files with 14 additions and 9 deletions
|
@ -1,11 +1,16 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
zlines=`/sbin/zpool iostat -v| wc -l|sed 's/ //g'`
|
||||
ztail=`echo "-"$zlines`
|
||||
ztmp=/var/run/munin/zpool_iostat
|
||||
zdata=`/sbin/zpool iostat -v 1 2| tail $ztail > $ztmp`
|
||||
zlist=`cat $ztmp|awk '/avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'`
|
||||
zname=`cat $ztmp|awk '/avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'|awk '{gsub("[^a-zA-Z0-9_]", "_", $1); print}'`
|
||||
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}'`
|
||||
zorder=`for o in $zname; do echo $o'_read '; echo $o'_write '; done`
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
@ -18,7 +23,7 @@ if [ "$1" = "config" ]; then
|
|||
echo 'graph_order '$zorder
|
||||
echo $zlist | tr ' ' '\n' | while read i; do
|
||||
case $i in
|
||||
*) name=`echo $i | awk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }'` ;;
|
||||
*) name=`echo $i | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }'` ;;
|
||||
esac
|
||||
echo $name'_read.label '$i
|
||||
echo $name'_read.type GAUGE'
|
||||
|
@ -30,14 +35,14 @@ if [ "$1" = "config" ]; then
|
|||
exit 0
|
||||
fi
|
||||
echo $zlist | tr ' ' '\n' | while read iz; do
|
||||
zlabel=`echo $iz|awk '{print $1}'`
|
||||
zlabel=`echo $iz|gawk '{print $1}'`
|
||||
case $iz in
|
||||
*) name=`echo $iz | awk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }'` ;;
|
||||
*) name=`echo $iz | gawk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }'` ;;
|
||||
esac
|
||||
echo -n $name'_read.value '
|
||||
grep $zlabel $ztmp|awk '{print $6}'|awk '/M/ {print $1*1000}; /K/ {print int($1)}; /^0/ {print $1}'
|
||||
grep '^[ ]*'$zlabel $ztmp|gawk '{print $6}'|gawk '/M/ {print int($1)*1000}; /K/ {print int($1)}; /[0-9]$/ {print int($1)/1000}; /^0/ {print int($1)}'
|
||||
echo -n $name'_write.value '
|
||||
grep $zlabel $ztmp|awk '{print $7}'|awk '/M/ {print $1*1000}; /K/ {print int($1)}; /^0/ {print $1}'
|
||||
grep '^[ ]*'$zlabel $ztmp|gawk '{print $7}'|gawk '/M/ {print int($1)*1000}; /K/ {print int($1)}; /[0-9]$/ {print int($1)/1000}; /^0/ {print int($1)}'
|
||||
done
|
||||
|
||||
rm $ztmp; touch $ztmp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue