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
|
#! /usr/bin/env stap
global opens, reads, writes, totals
probe begin { printf("starting probe\n") }
probe syscall.open {
e=execname();
opens[e] <<< 1 # statistics array
}
probe syscall.read.return {
count = $return
if ( count >= 0 ) {
e=execname();
reads[e] <<< count # statistics array
totals[e] += count
}
}
probe syscall.write.return {
count = $return
if (count >= 0 ) {
e=execname();
writes[e] <<< count # statistics array
totals[e] += count
}
}
probe end {
printf("\n%16s %8s %8s %8s %8s %8s %8s %8s\n",
"", "", "", "read", "read", "", "write", "write")
printf("%16s %8s %8s %8s %8s %8s %8s %8s\n",
"name", "open", "read", "KB tot", "B avg", "write", "KB tot", "B avg")
foreach (name in totals- limit 20) { # sort by total io
printf("%16s %8d %8d %8d %8d %8d %8d %8d\n",
name, @count(opens[name]),
@count(reads[name]),
(@count(reads[name]) ? @sum(reads[name])>>10 : 0 ),
(@count(reads[name]) ? @avg(reads[name]) : 0 ),
@count(writes[name]),
(@count(writes[name]) ? @sum(writes[name])>>10 : 0 ),
(@count(writes[name]) ? @avg(writes[name]) : 0 ))
}
}
|