Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / zpool_iostat @ f3cfd7eb

Historique | Voir | Annoter | Télécharger (1,64 ko)

1
#!/bin/sh
2

    
3
zlines=`/sbin/zpool iostat -v| wc -l|sed 's/ //g'`
4
ztail=`echo "-"$zlines`
5
ztmp=/var/run/munin/zpool_iostat
6
zdata=`/sbin/zpool iostat -v 1 2| tail $ztail > $ztmp`
7
zlist=`cat $ztmp|awk '/avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'`
8
zname=`cat $ztmp|awk '/avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'|awk '{gsub("[^a-zA-Z0-9_]", "_", $1); print}'`
9
zorder=`for o in $zname; do echo $o'_read '; echo $o'_write '; done`
10

    
11
if [ "$1" = "config" ]; then
12
        echo 'graph_title zpool iostat'
13
        echo 'graph_args --base 1000 -l 0'
14
        echo 'graph_vlabel write - read KBytes/s'
15
        echo 'graph_category zfs'
16
        echo 'graph_scale no'
17
        echo 'graph_info This graph shows zpool iostat'
18
	echo 'graph_order '$zorder
19
	echo $zlist | tr ' ' '\n' | while read i; do
20
                case $i in
21
                *) name=`echo $i | awk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print }'` ;;
22
                esac
23
                echo $name'_read.label '$i
24
		echo $name'_read.type GAUGE'
25
		echo $name'_read.graph no'
26
		echo $name'_write.label '$i
27
		echo $name'_write.type GAUGE'
28
		echo $name'_write.negative '$name'_read'
29
        done
30
        exit 0
31
fi
32
echo $zlist | tr ' ' '\n' | while read iz; do
33
	zlabel=`echo $iz|awk '{print $1}'`
34
	case $iz in
35
	*) name=`echo $iz | awk '{ gsub("[^a-zA-Z0-9_]", "_", $1); print $1 }'` ;;
36
	esac
37
	echo -n $name'_read.value '
38
	grep $zlabel $ztmp|awk '{print $6}'|awk '/M/ {print $1*1000}; /K/ {print int($1)}; /^0/ {print $1}'
39
	echo -n $name'_write.value '
40
	grep $zlabel $ztmp|awk '{print $7}'|awk '/M/ {print $1*1000}; /K/ {print int($1)}; /^0/ {print $1}'
41
done
42

    
43
rm $ztmp; touch $ztmp