Projet

Général

Profil

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

root / plugins / system / cpu_ @ 149688a7

Historique | Voir | Annoter | Télécharger (2,24 ko)

1 149688a7 Steve Schnepp
#! /bin/sh
2
# Multigraph CPU plugin
3
# It shows a global cpu graph, and you can drill down per-core
4
5
PLUGINBASE=$(basename $0)
6
7
emit_config()
8
{
9
cat <<'EOF'
10
graph_title CPU usage
11
graph_order system user nice idle iowait irq softirq
12
graph_vlabel %
13
graph_scale no
14
graph_info This graph shows how CPU time is spent.
15
graph_category system
16
graph_period second
17
system.label system
18
system.draw AREA
19
system.min 0
20
system.type DERIVE
21
system.info CPU time spent by the kernel in system activities
22
user.label user
23
user.draw STACK
24
user.min 0
25
user.type DERIVE
26
user.info CPU time spent by normal programs and daemons
27
nice.label nice
28
nice.draw STACK
29
nice.min 0
30
nice.type DERIVE
31
nice.info CPU time spent by nice(1)d programs
32
idle.label idle
33
idle.draw STACK
34
idle.min 0
35
idle.type DERIVE
36
idle.info Idle CPU time
37
iowait.label iowait
38
iowait.draw STACK
39
iowait.min 0
40
iowait.type DERIVE
41
iowait.info CPU time spent waiting for I/O operations to finish when there is nothing else to do.
42
irq.label irq
43
irq.draw STACK
44
irq.min 0
45
irq.type DERIVE
46
irq.info CPU time spent handling interrupts
47
softirq.label softirq
48
softirq.draw STACK
49
softirq.min 0
50
softirq.type DERIVE
51
softirq.info CPU time spent handling "batched" interrupts
52
steal.label steal
53
steal.draw STACK
54
steal.min 0
55
steal.type DERIVE
56
steal.info The time that a virtual CPU had runnable tasks, but the virtual CPU itself was not running
57
guest.label guest
58
guest.draw STACK
59
guest.min 0
60
guest.type DERIVE
61
guest.info The time spent running a virtual CPU for guest operating systems under the control of the Linux kernel.
62
EOF
63
}
64
65
CPUS=$(grep '^cpu[0-9]' /proc/stat | cut -d ' ' -f 1)
66
67
if [ "$1" = "config" ]
68
then
69
	echo multigraph $PLUGINBASE
70
	emit_config
71
	# Emit one subgraph per core
72
	for cpu in $CPUS
73
	do
74
		echo multigraph $PLUGINBASE.$cpu
75
		emit_config
76
	done
77
78
	exit 0
79
fi
80
81
emit_values()
82
{
83
	while read key system user nice idle iowait irq softirq steal guest unused
84
	do
85
		[ "$key" != "$1" ] && continue
86
		cat <<EOF
87
system.value $system
88
user.value $user
89
nice.value $nice
90
idle.value $idle
91
iowait.value $iowait
92
irq.value $irq
93
softirq.value $softirq
94
steal.value $steal
95
guest.value $guest
96
EOF
97
	done < /proc/stat
98
}
99
100
# Values
101
echo multigraph $PLUGINBASE
102
emit_values cpu
103
104
# Emit one subgraph per core
105
for cpu in $CPUS
106
do
107
	echo multigraph $PLUGINBASE.$cpu
108
	emit_values $cpu
109
done
110
111
exit 0