| 1 |
#! /usr/bin/env stap |
| 2 |
|
| 3 |
global reads, writes, total_io |
| 4 |
|
| 5 |
probe vfs.read.return { |
| 6 |
reads[execname()] <<< bytes_read |
| 7 |
total_io[execname()] <<< bytes_read |
| 8 |
} |
| 9 |
|
| 10 |
probe vfs.write.return { |
| 11 |
writes[execname()] <<< bytes_written |
| 12 |
total_io[execname()] <<< bytes_written |
| 13 |
} |
| 14 |
|
| 15 |
# print top 10 IO processes every 5 seconds |
| 16 |
probe timer.s(5) { |
| 17 |
printf ("%16s\t%10s\t%10s\n", "Process", "KB Read", "KB Written") |
| 18 |
foreach (name in total_io @sum- limit 10) |
| 19 |
printf("%16s\t%10d\t%10d\n", name, |
| 20 |
@sum(reads[name])/1024, @sum(writes[name])/1024) |
| 21 |
delete reads |
| 22 |
delete writes |
| 23 |
delete total_io |
| 24 |
print("\n") |
| 25 |
} |