File: vmstat.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 (108 lines) | stat: -rwxr-xr-x 2,501 bytes parent folder | download
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
#!/bin/sh
#
# Plugin to monitor the number of procs in io-sleep and other wait
# states. Uses `vmstat`.
#
# Parameters: 
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#
# $Log$
# Revision 1.4.2.1  2005/01/28 14:51:22  lupe
# Add graph_info and some filed.info
#
# Revision 1.5  2005/01/28 14:47:31  lupe
# Add graph_info and some filed.info
#
# Revision 1.4  2004/11/28 09:43:54  lupe
# 6-CURRENT support
#
# Revision 1.3  2004/05/20 19:02:36  jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.2  2004/02/01 18:59:54  lupe
# FreeBSD 5 compatibility.
#
# Revision 1.1  2004/01/02 18:50:00  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
#
#
#
# Magick markers (optional):
#%# family=auto
#%# capabilities=autoconf



OSV=`/sbin/sysctl -n kern.osrelease | cut -f1 -d.`

if [ "$1" = "autoconf" ]; then
	if [ "$OSV" -ge "5" ]; then
		/sbin/sysctl -n vm.vmtotal 2>/dev/null >/dev/null
		RESULT=$?
		NAME=/sbin/sysctl
	else
		/usr/bin/vmstat 1 1 2>/dev/null >/dev/null
		RESULT=$?
		NAME=/usr/bin/vmstat
	fi
	if [ $RESULT -eq 0 ]; then
		echo yes
		exit 0
	else
		if [ $RESULT -eq 127 ]; then
			echo "no (could not run \"$NAME\")"
			exit 1
		else
			echo no
			exit 1
		fi
	fi
fi

if [ "$1" = "config" ]; then
	echo 'graph_title VMstat'
	echo 'graph_args --base 1000 -l 0'
	echo 'graph_vlabel process states'
	echo 'graph_category processes'
	echo 'graph_info This graph shows number of processes in each state.'
	if [ "$OSV" -ge "5" ]; then
		echo 'running.label running'
		echo 'running.info processes on CPU or waiting for CPU'
		echo 'running.type GAUGE'
		echo 'diskwait.label diskwait'
		echo 'diskwait.info processes waiting for disk activity'
		echo 'diskwait.type GAUGE'
		echo 'pagewait.label pagewait'
		echo 'pagewait.info processes waiting for page-in'
		echo 'pagewait.type GAUGE'
		echo 'sleep.label sleep'
		echo 'sleep.info processes waiting for some event'
		echo 'sleep.type GAUGE'
	else
		echo 'wait.label wait'
		echo 'wait.type GAUGE'
		echo 'sleep.label sleep'
		echo 'sleep.type GAUGE'
	fi
	exit 0
fi

if [ "$OSV" -ge "5" ]; then
	sysctl -n vm.vmtotal | awk '
/^Processes:/ {
	print "running.value", $3;
	print "diskwait.value", $6;
	print "pagewait.value", $9;
	print "sleep.value", $11+0;
}'
else
	vmstat 1 2| awk 'END { print "wait.value " $1 "\nsleep.value " $2 }' 
fi