in reply to Calculating percent cpu in linux?

From /proc/$PID/stat, you can get the amount of cpu time a process has used in user and system mode (similar to times, but for other processes). If you examine this twice, with a few seconds of delay between them, you get the amount of time the cpu spent on it. You then divide this amount with the delay, and there you are. (Of course, on an smp machine you may or may not want to divide with the number of cpus, depending on what you mean by cpu-percent.)

There must be a faster wat though, as ps u can return the percent-cpu faster. As eXile has recommended, get procps from http://procps.sf.net/.