Projet

Général

Profil

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

root / plugins / processes / cpuutil @ c3660c2a

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

1 a0cb4d43 Stig Sandbeck Mathisen
#!/bin/sh
2 57f012bd Pal Baranyai
3
# See /usr/include/sys/dk.h !
4
PATH=/usr/bin:/usr/sbin:/sbin
5
6
if [ "$1" = "autoconf" ]; then
7
	echo yes
8
	exit 0
9
fi
10
11
#ADBINPUT="./vmunix ."
12
ADBINPUT="/stand/vmunix /dev/kmem"
13
14
NMPINFO=$(	/bin/echo "nmpinfo/D" | \
15
		/bin/adb -o $ADBINPUT 2>/dev/null | \
16
		/bin/sed '/^nmpinfo: *[0-9]/!d;s/^[^:]*://' )
17
18
echo_func () {
19
	echo ${1}.label $2
20
	echo ${1}.draw $3
21
	echo ${1}.type DERIVE
22
	echo ${1}.min 0
23
	echo ${1}.cdef ${1},$NMPINFO,/
24
}
25
26
if [ "$1" = "config" ]; then
27
	echo 'graph_title CPU usage graph based on kernel counters'
28
	echo 'graph_order sys user wio idle'
29
#	graphmax=$(( $NMPINFO * 100 ))
30
	graphmax=100
31
	echo "graph_args -r -l 0 --upper-limit $graphmax"
32
	echo 'graph_vlabel %'
33
	echo 'graph_category processes'
34
	echo 'graph_scale no'
35
	echo 'graph_info This graph shows how CPU time is spent.'
36
37
	echo_func sys system AREA
38
	echo "sys.info CPU time spent in running the kernel code"
39
40
	echo_func user user STACK
41
	echo 'user.info CPU time spent by tunning application code'
42
43
	echo_func wio iowait STACK
44
	echo 'wio.info CPU idle time in waiting IO (disk)'
45
46
	echo_func idle idle STACK
47
	echo 'idle.info Idle CPU time'
48
49
	exit 0
50
fi
51
52
CPU=0
53
MAXCPU=$(( $NMPINFO * 72 ))
54
ADBCMD="0d200\$w"
55
56
while [ $CPU -lt $MAXCPU ]; do
57
	ADBCMD="${ADBCMD}\nmcp_time+0d${CPU}/18D"
58
	CPU=$(( $CPU + 72 ))
59
done
60
61
/bin/echo "${ADBCMD}\n\$q" | /bin/adb -o $ADBINPUT 2>/dev/null | \
62
/bin/sed '/^mcp_time.*:.*[0-9]/!d;s/^[^:]*://' | /bin/awk \
63
	'{ \
64
		uh += $1 ; nh += $3 ; sh += $5 ; ih += $7 ; wh +=  $9 ; \
65
		ul += $2 ; nl += $4 ; sl += $6 ; il += $8 ; wl += $10 ; \
66
	}  END  { \
67
		GIGA = 4294967296 ; \
68
		printf( "sys.value  %0.f\n", sh * GIGA + sl ) ; \
69
		printf( "user.value %0.f\n", ( uh + nh ) * GIGA + ul + nl ) ; \
70
		printf( "wio.value  %0.f\n", wh * GIGA + wl ) ; \
71
		printf( "idle.value %0.f\n", ih * GIGA + il ) ; \
72
	}'