summaryrefslogtreecommitdiffstats
path: root/stap_tutorial-1.0/examples/read-write-2.stp
blob: d6a647bcc9a3135ae130c8def34e2439e2f89d69 (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
#!/usr/bin/env stap

global reads, writes

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

probe syscall.read.return {
	if ($return > 0)
		reads[execname()] += $return
}

probe syscall.write.return {
	if ($return > 0)
		writes[execname()] += $return
}

probe end {
	printf("Bytes read by process name:\n")
	foreach (name in reads-)
		printf("%10d %s\n", reads[name], name)

	printf("Bytes written by process name:\n")
	foreach (name in writes-)
		printf("%10d %s\n", writes[name], name)
}