Re: collect process IO stats (linux newbie)

From: Loic Domaigne (loic-dev_at_gmx.net)
Date: 07/28/04


Date: Wed, 28 Jul 2004 11:14:52 +0200

Hi,

> I have a requirement to gather statistics of a linux application
> we developed. I need to gather other than the user time, system time..
> information like the I/O time i.e the amount of time the process spent
> in doing the I/O. I also want statistics on how much I/O (in KB or MB)
> the process has done.

Use getrusage(). Or eventually parse the /proc/pid. But the former way
is definitively better.

> I have thoroughly searched the newsgroups for pointers on the this and
> also read the man pages of time(1), times(2), getrusage(3p), proc(5)
> for information on the same.

Oh, come on... There is really nothing difficult about getrusage(). Just
  follows the man page!

Cheers,
Loic.

/* !! Sender address is *buggy* !! */
/* Use my 32/64 bits, ANSI C89, compliant email-address instead. */
unsigned y[]=
{0,34432,26811,16721,41866,63119,61007,48155,26147,10986};
void x(z){putchar(z);}; unsigned t;
main(i){if(i<10){t=(y[i]*47560)%65521;x(t>>8);x(t&255);main(++i);}}