在/proc/[pid]/io文件里面为我们提供了这个接口。还是先看manpage:
/proc/[pid]/io (since kernel 2.6.20)
This file contains I/O statistics for the process, for example:
# cat /proc/3828/io
rchar: 323934931
wchar: 323929600
syscr: 632687
syscw: 632675
read_bytes: 0
write_bytes: 323932160
cancelled_write_bytes: 0
The fields are as follows:
rchar: characters read
The number of bytes which this task has caused to be read from storage. This is simply the sum of bytes which
this process passed to read(2) and similar system calls. It includes things such as terminal I/O and is unaf-
fected by whether or not actual physical disk I/O was required (the read might have