getrusage vs /proc/pid/stat?

Dan Kegel
2001-06-18T05:16:14Z

I'd like to monitor CPU, memory, and I/O utilization in a
long-running multithreaded daemon under kernels 2.2, 2.4,
and possibly also Solaris (#ifdefs are ok).

getrusage() looked promising, and might even work for CPU utilization.
Dunno if it returns info for all child threads yet, haven't tried it.
In Linux, though, getrusage() doesn't return any info about RAM.

I know I can get the RSS and VSIZE under Linux by parsing /proc/pid/stat,
but was hoping for a faster interface (although I suppose a seek,
a read, and an ascii parse isn't *that* slow). Is /proc/pid/stat
the only way to go under Linux to monitor RSS?
- Dan

--
"A computer is a state machine.
Threads are for people who can't program state machines."
- Alan Cox