summaryrefslogtreecommitdiffstats
path: root/stap_tutorial-1.0/examples/top-cs.stp
blob: efe57695ca313215eeba0ea526bd09b97fab8ab8 (plain)
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
#!/usr/bin/env stap 
#
# Continuously list the top context switchers  
#

global processes

probe begin {
	printf("Collecting data...\n")
}

function print_top () {
	printf("Process\t\t\t\tCount\n")
	printf("--------------------------------------\n")
	foreach (name in processes- limit 20)
		printf("%-20s\t\t%5d\n",name, processes[name])
	printf("--------------------------------------\n\n")
	delete processes
}

probe scheduler.cpu_on {
	processes[execname()]++
}

# print top context switchers every 10 seconds
probe timer.s(10) {
	print_top ()
}