[lug] Determining CPU usage

Jim Buzbee jbuzbee at nyx.net
Thu May 1 13:00:52 MDT 2008


On Thu, 1 May 2008, Zan Lynx wrote:

...

> To get the value you want, you'd add up the user, system and nice used
> time and store it, get the total run time and store it, then wait 1
> second and do it again.  Find the differences and calculate your 1
> second CPU% usage.

...

Now that I think about it a bit more, I probably need to re-architect what
I'm doing.  If I'm asking for CPU usage, it is over some time period
(e.g. 1 second, as above).  So if I loop one at a time through all of my
pids, which could be 30 or more, it will take 30 seconds minimum for my
script to run. What I really need to do is gather all the pids up and do
the calculation for them simultaneously.

Jim

--------------------------------------------------------------------------------
Jim Buzbee				"I was gratified to be able to 
jbuzbee at nyx.net				answer promptly, and I did. I
http://batbox.org			said I didn't know."   Mark Twain




More information about the LUG mailing list