blob: 8a95a25343843fd6d63110e90f8ee2711840ae3c (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#! /usr/bin/env ktap
# Based on systemtap traceio.stp
#this script is broken, fix it soon.
reads = aggr_table()
writes = aggr_table()
total_io = aggr_table()
trace syscalls:sys_exit_read {
reads[execname()] = sum(arg2)
total_io[execname()] = sum(arg2)
}
trace syscalls:sys_exit_write {
writes[execname()] = sum(arg2)
total_io[execname()] = sum(arg2)
}
function humanread_digit(bytes) {
if (bytes > 1024*1024*1024) {
return bytes/1024/1024/1024
} elseif (bytes > 1024*1024) {
return bytes/1024/1024
} elseif (bytes > 1024) {
return bytes/1024
} else {
return bytes
}
}
function humanread_x(bytes) {
if (bytes > 1024*1024*1024) {
return " GiB"
} elseif (bytes > 1024*1024) {
return " MiB"
} elseif (bytes > 1024) {
return " KiB"
} else {
return " B"
}
}
tick-1s {
ansi.clear_screen()
for (exec, count in pairs(total_io)) {
local readnum = reads[exec]
local writenum = writes[exec]
printf("%15s r: %12d%s w: %12d%s\n", exec,
humanread_digit(readnum), humanread_x(readnum),
humanread_digit(writenum), humanread_x(writenum))
}
printf("\n")
}
|