[Nottingham] Process CPU and memory usage?

Michael Erskine msemtd at googlemail.com
Tue Sep 23 08:05:08 UTC 2008


2008/9/22 Martin <martin at ml1.co.uk>:
> So how do you get 'realtime' process stats? (Of /currently/ running
> processes.)

Look in /proc or get something else to do it for you: e.g. parse ps
output (with ppid field) or use Proc::ProcessTable in Perl.

> I can't help but think that this is one of those "it must have been done
> already"...

Yes thanks but everybody wanted something slightly different so they
all wrote their own -- what is it that you want? Looks to me like a
job for Perl (or bash if you're a masochist :) ).

> Sorry, but the top/ps/pstree and parse their output seems to be rather
> expensively clunky. Then also, scanning through /proc is also
> expensively clunky...

Um, not really - but then you don't define your terms! What do you
want to achieve with this information? If it's for tracking and
killing/restarting rogue processes then there's plenty of Perl modules
for you: http://cpan.uwinnipeg.ca/chapter/Operating_System_Interfaces/Proc

> And how do you add up correctly for shared memory usage?!

Short answer: you don't - it's shared! Long answer: it depends :)

> Any other ideas?

Forget about it - sounds like a non-feature to me! :)

Regards,
Michael Erskine



More information about the Nottingham mailing list