Fabian Braennstroem <[EMAIL PROTECTED]> wrote:
> Hi,

>    I would like to track the cpu usage of a couple of
>    programs using python. Maybe it works somehow with
>    piping 'top' to python read the cpu load for a greped
>    application and clocking the the first and last
>    appearence. Is that a good approach or does anyone have
>    a more elegant way to do that?

> Greetings!
> Fabian

 If you're on a Linux system you might be far better accessing
 the /proc/$PID/stat files directly. The values you'd find therein
 are documented:

        http://www.die.net/doc/linux/man/man5/proc.5.html

 (among other places).

 Of course you could write you code to look for file and fall back
 to use the 'ps' command if it fails.  In addition you can supply
 arguments to the 'ps' command to limit it to reporting just on the
 process(es) in which you are interested ... and to eliminate the
 header line and irrelevant columns of output.


-- 
Jim Dennis,
Starshine: Signed, Sealed, Delivered

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to