gopsutil
gopsutil copied to clipboard
[process][linux]collect rchar and wchar from /proc/${pid}/io
Is your feature request related to a problem? Please describe. IOCountersStat now have ReadBytes and WriteBytes, but /proc/${pid}/io also provides rchar and wchar, which is not affected by possible disk pagecache. Users may want these two value(rchar and wchar) as well as read_bytes and write_bytes.
Describe the solution you'd like
- [x] On linux, these two values are easy to get.
- [x] IOCounters is not implemented on darwin.
- [ ] Not sure how to get these on windows, either set them 0 or the same as read_bytes, write_bytes makes sense to me...
Describe alternatives you've considered
Additional context An example from the doc.
Example
-------
test:/tmp # dd if=/dev/zero of=/tmp/test.dat &
[1] 3828
test:/tmp # cat /proc/3828/io
rchar: 323934931 <----
wchar: 323929600
syscr: 632687
syscw: 632675
read_bytes: 0 <----
write_bytes: 323932160
cancelled_write_bytes: 0
@roccowong95 when will two metrics rchar and wchar be helpful? Isn't it enough to monitor typical metrics read_bytes or write_bytes?
So rchar has a value even if read_bytes are 0 in sometimes, correct? If so, how about use rchar value as read_bytes if read_bytes is 0.
According to your cited URL, rchar is
The number of bytes which this task has caused to be read from storage
so it can be used as read_bytes and no need to add other fields IMO.
There is significant difference between metrics
- rchar - bytes read from an application point of view. files may read from pagecache. also include process pipes.
- read_bytes - bytes read from the storage layer.
So if process not used pipes you can monitor pagecache usage by difference.
(https://man7.org/linux/man-pages/man5/proc.5.html)
@maizy The significance is understandable, but what insight or advantage do we get by monitoring these two metrics?
@maizy The significance is understandable, but what insight or advantage do we get by monitoring these two metrics?
@mznet in my case it was indirect way to monitor pagecache usage. lightweight alternative to eBPF solution.