[Nottingham] Process CPU and memory usage?

Jim Moore jmthelostpacket at googlemail.com
Mon Sep 22 12:59:15 UTC 2008


Martin wrote:
> Camilo Mesias wrote:
>   
>>> From within a program, at intervals how can I find out how much CPU and
>>> how much memory has been used so far for all child/forked processes?
>>>       
>> Take a look at getrusage(), maybe consider writing a wrapper program
>> that does the stats for you (then you can reuse it directly instead of
>> pasting the same code into the next project)
>>     
>
> ... But that don't work.
>
> Two aspects, one is:
>
> http://linux.die.net/man/2/getrusage
> "for resources used by those of its children that have terminated and
> have been waited for"
>
> And two, it doesn't work... For example:
> http://zwillow.blogspot.com/2006/05/broken-getrusage-in-linux.html
>
> So is this where you must do a costly trog through all of /proc/pid...?
>
>
> What do others do for this?
>
> Cheers,
> Martin
>
>   

Thought: is there a way of passing the output from /top/ to a logfile? 
Thereafter, to be processed by <insert favourite statistical package here>?

Cheers,

TLP



More information about the Nottingham mailing list