File: io_bytes_.in

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (178 lines) | stat: -rwxr-xr-x 4,544 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/sh
#
# Wildcard-plugin to monitor disks. To monitor a disk,
# link io_<function>_<disk> to this file. E.g.
#
#    ln -s /usr/share/munin/plugins-auto/io_.kstat /etc/munin/node.d/io_busy_sd0
#
# ...will monitor busy and wait on sd0.
#
# These functions are implemented:
#	busy bytes ops
#
# Any device found in /usr/bin/kstat can be monitored.
#
# Configuration variables
#
#   io_*_ignore	 - Perl expression to select devices to ignore
#
#   E.g. io_dad_ignore = $F[1] == 0 ignores dad0.
#   All fields from the kstat line are in @F. Fields are separated
#   by ':' or "\t". $F[0] is the module name, e.g. 'dad'.
#   $F[1] is the instance number. $F[2] is the device name , e.g.
#   'dad0'.
#
# $Log$
# Revision 1.5  2004/12/09 17:48:34  jimmyo
# Major improvements to sunos/io_ops,bytes,busy, by Lupe Christoph (SF#1077898).
#
# Revision 1.4  2004/11/21 00:17:12  jimmyo
# Changed a lot of plugins so they use DERIVE instead of COUNTER.
#
# Revision 1.3  2004/05/20 19:02:38  jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.2  2004/04/30 16:43:00  jimmyo
# Cleaned up Solaris plugins.
#
# Revision 1.1  2004/01/02 18:50:01  jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
#
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf suggest

FUNCTION=`basename $0 | sed -e 's/io_//' -e 's/_.*//'`
MODULE=`basename $0 | sed 's/^.*_//g'`
CLASS=disk
PERL=${PERL:-@@PERL@@}

if [ -z "$FUNCTION" ]; then
	exit
elif [ $FUNCTION = "busy" ]; then
	TITLE="Busy & Wait"
	IN=rtime
	INNAME=busy
	OUT=wtime
	OUTNAME=wait
	CDEF=",100,*"
elif [ $FUNCTION = "bytes" ]; then
	TITLE="I/O"
	IN=nread
	INNAME=$IN
	OUT=nwritten
	OUTNAME=$OUT
elif [ $FUNCTION = "ops" ]; then
	TITLE="Operations"
	IN=reads
	INNAME=$IN
	OUT=writes
	OUTNAME=$OUT
fi

if [ "$1" = "autoconf" ]; then
	if [ -x /usr/bin/kstat ]; then
		echo yes
		exit 0
	else
		echo "no (/usr/bin/kstat not found)"
		exit 1
	fi
fi

if [ "$1" = "suggest" ]; then
	if [ -x /usr/bin/kstat ]; then
		kstat -p -c '/disk|nfs|tape/' -s "/^$IN\$/" | sed -e 's/:.*//' -e 's/ssd/sd/' -e '/^fd$/d' | sort -u
		exit 0
	else
		exit 1
	fi
fi

REGEX="$MODULE"
if [ $MODULE = "sd" ]; then
	REGEX="/^s?sd$/"
	NAME="Disk Device"
elif [ $MODULE = "dad" ]; then
	NAME="IDE Disk Device"
elif [ $MODULE = "md" ]; then
	NAME="Disksuite"
elif [ $MODULE = "nfs" ]; then
	NAME="NFS"
	CLASS=nfs
elif [ $MODULE = "st" ]; then
	NAME="Tape"
	CLASS=tape
else
	NAME="Unknown"
fi

if $PERL -MSolaris::MapDev -e '' >/dev/null 2>&1; then
	HAS_MAPDEV=1
fi

eval IGNORE="\$io_${MODULE}_ignore"
if [ -n "$IGNORE" ]; then
	IGNORE="next if $IGNORE;"
fi

if [ "$1" = "config" ]; then
	echo "graph_title $NAME $TITLE"
	echo 'graph_args --base 1024'
	echo 'graph_category disk'

	export IN INNAME OUT OUTNAME CDEF
	if [ "$HAS_MAPDEV" ]; then
		kstat -p -c $CLASS -m $REGEX -s "/^$IN\$/" | \
		  $PERL -MSolaris::MapDev=inst_to_dev -n -a -F':|\t' \
		       -e $IGNORE'
			  $dev = $F[2];
			  $name = inst_to_dev($dev);
			  $name =~ s/:/_/g;
			  $name = length $name ? $name : $dev;
			  print "${dev}_$ENV{IN}.label ${name}_$ENV{INNAME}\n";
			  print "${dev}_$ENV{IN}.type DERIVE\n";
			  print "${dev}_$ENV{IN}.min 0\n";
			  print "${dev}_$ENV{IN}.max 1000000000\n";
			  print "${dev}_$ENV{IN}.cdef ${dev}_$ENV{IN}$ENV{CDEF}\n" if exists $ENV{CDEF};
			  print "${dev}_$ENV{OUT}.label ${name}_$ENV{OUTNAME}\n";
			  print "${dev}_$ENV{OUT}.type DERIVE\n";
			  print "${dev}_$ENV{OUT}.min 0\n";
			  print "${dev}_$ENV{OUT}.max 1000000000\n";
			  print "${dev}_$ENV{OUT}.cdef ${dev}_$ENV{OUT}$ENV{CDEF}\n" if exists $ENV{CDEF};'
		exit 0
	else
		for dev in `kstat -p -c $CLASS -m $REGEX -s "/^$IN\$/" | $PERL -n -a -F':|\t' -e "$IGNORE"'print $F[2], "\n";'`; do
			echo "${dev}_$IN.label ${dev}_$INNAME"
			echo "${dev}_$IN.type DERIVE"
			echo "${dev}_$IN.min 0"
			echo "${dev}_$IN.max 1000000000"
			if [ -n "$CDEV" ]; then
				echo "${dev}_$IN.cdef ${dev}_$IN$CDEF"
			fi
			echo "${dev}_$OUT.label ${dev}_$OUTNAME"
			echo "${dev}_$OUT.type DERIVE"
			echo "${dev}_$OUT.min 0"
			echo "${dev}_$OUT.max 1000000000"
			if [ -n "$CDEV" ]; then
				echo "${dev}_$OUT.cdef ${dev}_$OUT$CDEF"
			fi
		done
		exit 0
	fi
fi

kstat -p -c $CLASS -m $REGEX -s "/^($IN|$OUT)\$/" | $PERL -n -a -F':|\t' -e "$IGNORE"'
	chomp $F[4];
	print $F[2]."_".$F[3].".value ", int($F[4]), "\n";
'