469,610 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

finding child cpu usage of a running child

Hi,

Wondering if there is a way to measure a child process's cpu usage
(sys and user) when the child is still running. I see os.times()
working fine in my system (Linux 2.6.9-42.7.ELsmp), but it gives valid
data only after the child has exited. When the child is alive,
os.times() data for child is zero for both child-sys and child-user
cpu.

My script (process P1) launches child process P2 (using
popen2.Popen3). P2 is a long running process (big compilation). Every
minute or so, from P1, I want to measure how much cpu P2 has consumed
and based on that I can make some estimate on the completion time of
P2 (I have a rough idea how much total cpu P2 needs to complete).

I understand it may be too expensive to update this information to the
parent process when any of the child/grand-child completes; but
wondering if any there is any way to get this info; the expensive
operations is on-demand only when the request is made.

Thanks,
Karthik
Jan 26 '08 #1
2 3252
On Jan 26, 5:43 am, Karthik Gurusamy <kar1...@gmail.comwrote:
Hi,

Wondering if there is a way to measure a child process's cpu usage
(sys and user) when the child is still running. I see os.times()
working fine in my system (Linux 2.6.9-42.7.ELsmp), but it gives valid
data only after the child has exited. When the child is alive,
os.times() data for child is zero for both child-sys and child-user
cpu.

My script (process P1) launches child process P2 (using
popen2.Popen3). P2 is a long running process (big compilation). Every
minute or so, from P1, I want to measure how much cpu P2 has consumed
and based on that I can make some estimate on the completion time of
P2 (I have a rough idea how much total cpu P2 needs to complete).

I understand it may be too expensive to update this information to the
parent process when any of the child/grand-child completes; but
wondering if any there is any way to get this info; the expensive
operations is on-demand only when the request is made.

Thanks,
Karthik
I had a similar requirement in December and found:
http://lilypond.org/~janneke/software/

proc-time.c and proc-time.py poll /proc/.... files whilst command
is running to get stats.

Enjoy, - Paddy.
Jan 26 '08 #2
On Jan 25, 11:59 pm, Paddy <paddy3...@googlemail.comwrote:
On Jan 26, 5:43 am, Karthik Gurusamy <kar1...@gmail.comwrote:
Hi,
Wondering if there is a way to measure a child process's cpu usage
(sys and user) when the child is still running. I see os.times()
working fine in my system (Linux 2.6.9-42.7.ELsmp), but it gives valid
data only after the child has exited. When the child is alive,
os.times() data for child is zero for both child-sys and child-user
cpu.
My script (process P1) launches child process P2 (using
popen2.Popen3). P2 is a long running process (big compilation). Every
minute or so, from P1, I want to measure how much cpu P2 has consumed
and based on that I can make some estimate on the completion time of
P2 (I have a rough idea how much total cpu P2 needs to complete).
I understand it may be too expensive to update this information to the
parent process when any of the child/grand-child completes; but
wondering if any there is any way to get this info; the expensive
operations is on-demand only when the request is made.
Thanks,
Karthik

I had a similar requirement in December and found:
http://lilypond.org/~janneke/software/

proc-time.c and proc-time.py poll /proc/.... files whilst command
is running to get stats.
Great, thanks. From proc-time.py looks like all I want are the fields
13 to 16 of /proc/<child-pid>/stat. And I see them updated in real
time (probably the kernel does it on a periodic interrupt).

Thanks,
Karthik
>
Enjoy, - Paddy.
Jan 26 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jamie Green | last post: by
reply views Thread by lawpoop | last post: by
4 posts views Thread by Edward Diener | last post: by
5 posts views Thread by Manish | last post: by
9 posts views Thread by Allan Ebdrup | last post: by
2 posts views Thread by skrebbel | last post: by
21 posts views Thread by Tom Gur | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.