Projet

Général

Profil

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

root / plugins / zfs / zpool_iostat @ e5ce7492

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

1
#!/bin/bash
2

    
3
if [ "$1" = "autoconf" ]; then
4
                echo yes
5
                exit 0
6
fi
7

    
8
zlines=`/sbin/zpool iostat -v| wc -l|sed 's/ //g'`
9
ztail=`echo "-"$zlines`
10
ztmp=/var/run/munin/zpool_iostat
11
zdata=`/sbin/zpool iostat -v 1 1| tail $ztail > $ztmp`
12
zlist=`cat $ztmp|gawk '/alloc/ {next}; /avail/ {next}; /raid/ {next}; /mirror/ {next}; { if ( $4 >=0 ) print $1}'`
13
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}'`
14
zorder=`for o in $zname; do echo $o'_read '; echo $o'_write '; done`
15

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

    
48
rm $ztmp; touch $ztmp