Just thought I would share another Ruby script - this one takes the output of mpstat, and makes it more like the output of mpstat -a, only the values are floating point. I wrote it to process mpstat -a that I got from a customer. It can also cope with the date (in Unix ctime format) being prepended to every line. Here is some sample output:
CPUs minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
The script is here.
Interestingly, you can use this to get greater accuracy on things like USR and SYS than you would get if you just used vmstat, sar, iostat or mpstat -a. This depends on the number of CPUs you have in your system though.
Now, if you do not have a lot of CPUs, but still want greater accuracy, I have another trick. This works especially well if you are conducting an experiment and can run a command at the beginning and end of the experiment. This trick is based around the output of vmstat -s:
# vmstat -s
Those numbers are "ticks" since the system booted. A tick is usually 0.01 seconds.
NEW: I have now uploaded a script that uses these statistics to track system-wide utilization.