0

This is a bit out of my league, but I was wondering if I could write a script that takes a PID as an argument, and tells me how many KB/sec of IO the mentioned PID is using.

  1. I don't know how to give an argument to a script
  2. I am not sure if the /proc/[PID]/io is actually showing me this info. Is the summation of 'read_bytes' + 'write_bytes' the KB of IO used?
  3. How can I update this value every second?
SSF
  • 915
  • 5
  • 23
  • 47
  • Take a look at second script: http://stackoverflow.com/a/24716260/3776858 – Cyrus Sep 29 '14 at 05:10
  • Thanks @Cyrus I had a look at the script. I'm still not sure if I should if I should add read_bytes and write_bytes together to get the IO. The process of IO seems the read&write bytes, is that correct? – SSF Sep 29 '14 at 05:52
  • sorry if this is a stupid question I am very new to these concepts. – SSF Sep 29 '14 at 05:52
  • You can find details of read_bytes and write_bytes there: http://stackoverflow.com/a/3634088/3776858 – Cyrus Sep 29 '14 at 17:20

1 Answers1

0

It sounds to me that you could use the iotop command. you can use it with just iotop or add the flags "-p <pid>" to monitor just a single process.

Example:

sudo iotop -p 7667
davvs
  • 1,029
  • 1
  • 11
  • 18
  • Thanks @davvs. I had come across a few tools such as iotop. But I wanted to keep the script in a way that it would not rely on tools that might not be installed on the server, since I want to do this across many servers. – SSF Sep 29 '14 at 23:58