-1

iostat screenshot

I need to IO utilization for Process by Process ID without using any tool like iostat,iotop etc.

Can any please help me to get IO utilization using info files using /proc/PID?

Thanks in ADV.

3
  • 2
    And why don't you want to use any of the standard tools for this?
    – ewwhite
    Mar 8, 2016 at 12:26
  • Thanks ewwhite. I dont want to use any tool and i want to know the core process of calculating IO utilization of any process. Mar 9, 2016 at 4:58
  • You could take a look at the source code for one or more of the tools to get this type of information.
    – mdpc
    Mar 10, 2016 at 15:38

1 Answer 1

4

You can get the io stats by process from proc. The information is available under /proc/[PID]/io

The information is stored like this:

cat /proc/2039/io

rchar: 293898605
wchar: 63376205
syscr: 114996
syscw: 51573
read_bytes: 98484224
write_bytes: 29159424
cancelled_write_bytes: 8192

The definitions of the fields are:

rchar: number of bytes the process read, using any read-like system call (from files, pipes, tty...).

wchar: number of bytes the process wrote using any write-like system call.

syscr: number of read-like system call invocations that the process performed.

syscw: number of write-like system call invocations that the process performed.

read_bytes: number of bytes the process directly read from disk.

write_bytes: number of bytes the process originally dirtied in the page-cache (assuming they will go to disk later).

cancelled_write_bytes: number of bytes the process "un-dirtied" - e.g. using an "ftruncate" call that truncated pages from the page-cache.

source

For further information on /proc/[pid]/io, take a look at the documentation or this Stack Overflow Q&A.

If you want to calculate the utilization you will also need stats from /proc/diskstats. The definition of the fields is defined in the Kernel documentation.

However as you can see /proc/diskstats users different metrics from /proc/[PID]/io which means you will need a lot of calculation to get utilization metrics. That is why I don't think it is a very fruitful idea to calculate these metrics manually.

1
  • Thanks knowhy,How can we get IO utilization(%) for Process by Process ID using cat /proc/2039/io? Mar 9, 2016 at 5:01

Not the answer you're looking for? Browse other questions tagged .