Content-type: text/html
As source for Linux and FreeBSD. Tested with Linux 2.4 & 2.6 and FreeBSD 5. But adaption to other UNIX's should only be a problem of getting the tics counters from the kernel.
Download from:
http://www.net.informatik.tu-muenchen.de/~schneifa/sources/
This tool reads out the tics counter of the operating system and calculates the Percentages spend in each CPU_STATE. This is done twice per second. The output is send to standard out. Supplementary the minimum, maximum and average percentages are displayed. The recording for the average measuring can be limited to start only if the idle value drops under a certain limit (set with the -l limit option) and stops if the idle value returns over that limit again.
The program will execute until a SIGINT is received. This can be done by pressing Strg+C in the corresponding shell or by invoking
where PID is the process ID of cpusage. If your system does not allow to use kill in the described manner, please refer to kill(1) for details.
The output depends on the available information delivered from the kernel this can be differ between operating system and even between different versions of operating systems (e.g.: Linux 2.4.x and Linux 2.6.x). The difference is in the fields the tics are split:
The field will be printed in the upon mentioned order. For the example outputs FreeBSD was chosen.
Every line consists of the fields each with name:value pairs:
user: 3.0%, nice: 0.0%, system: 0.7%, idle: 68.7%, interrupt: 27.6%,
0.0:0.0:0.0:70.7:29.3
Fabian Schneider <fabian@net.in.tum.de>