Linux kernel 2.6.20 and later supports per process I/O accounting. You can access every process/thread's I/O read/write values by using /proc filesystem. You can check if your kernel has built with I/O account by just simply checking /proc/self/io file. If it exists then you have I/O accounting built-in.
$ cat /proc/self/io
rchar: 3809
wchar: 0
syscr: 10
syscw: 0
read_bytes: 0
write_bytes: 0
cancelled_write_bytes: 0
Field Descriptions:
rchar - bytes read
wchar - byres written
syscr - number of read syscalls
syscw - number of write syscalls
read_bytes - number of bytes caused by this process to read
from underlying storage
write_bytes - number of bytes caused by this process to written from
underlying storage
As you know, ever process is presented by it's pid number under /proc directory. You can access any process's I/O accounting values by just looking /proc/#pid/io file. There is a utility called
iotop which collects these values and shows you in like top utility. You see your processes I/O activity with iotop utility.
3 comments:
Most interesting :)
I was thinking about needing something like this just yesterday! Thx for the tip
Not even latest Red Hat version (5.4) has this feature. Too bad.
Well, RHEL 5.4 kernel does have this feature. Check this out,
# uname -r
2.6.18-164.2.1.el5
# cat /proc/self/io
rchar: 1900
wchar: 0
syscr: 7
syscw: 0
read_bytes: 28672
write_bytes: 0
cancelled_write_bytes: 0
Post a Comment