0

I need to get the IO usage on the disk of processes in UNIX. I need to get it from another c++ process, better not from unix command lines but from some light c++ library. Also, if you have some nice way to know the throughput of network that goes through a process (again, not via command lines) it will also be great. Can you please recommend something? Thanks

walla
  • 293
  • 1
  • 2
  • 16

1 Answers1

0

you can use the time command in order to show all sort of I/O statistics. check the formating the output section

what you are looking for will probably be like this:

time -f "Input: %I \noutput: %O" <some-program>

that's command line, but you can embed it in a c++ program. How to run a bash script from C++ program

Community
  • 1
  • 1
elyashiv
  • 3,623
  • 2
  • 29
  • 52
  • This doesn't work on mac os x (which is UNIX), neither with `/usr/bin/time`, or bash or zsh builtin time. – phadej Nov 10 '13 at 15:11
  • @OlegGrenrus sorry, I automatically translate unix to linux. there is a command for mac named `gtime` : http://superuser.com/questions/196072/fully-featured-time-command-on-mac-os-x – elyashiv Nov 10 '13 at 15:47
  • The problem here is that you need to execute the process in advanced via time. I guess it acts like some kind of virtual machine or sandbox. I need an option to get the IO on already running program. – walla Nov 13 '13 at 15:32
  • @user2963867 look this up: http://stackoverflow.com/questions/2838190/mac-os-x-getting-detailed-process-information-specifically-its-launch-argument – elyashiv Nov 13 '13 at 16:40