I was wondering if there might exist a linux command or php function that will tell me how busy my CPU is? I've gotten accustomed to typing 'w' which gives me a load average (not quite the same thing as CPU utilization but pretty good) or 'top' (which does actually calculate some kind of CPU % utilization).
Unfortunately, the 'w' command only shows load averages over 1, 5, and 15 minutes. I need something that looks at a shorter interval (e.g., 15 seconds). Can anyone tell me how I might get load average on the order of seconds rather than minutes?
Why do I need this? Because I'm writing a multi-threaded PHP script and would like it to be able to utilize all available resources up to a point -- I want to check the CPU utilization before deciding how many threads to spawn.