Greg Briggs' Technical ArticlesArticle Index

CPU Utilization from the Linux command line

Intro

This C program will display a CPU usage line, similar to top except that it just prints a single line for the system and then exits. This is particularly useful for consumation by scripts.

By default it will average over 3 seconds, but you can select any number of seconds.

Example output:

    Cpu(s): 0.3% us, 0.0% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si

Download

Please see README and LICENSE files in the download. This application is available under the GPL version 2.

cpuutil-0.1.tgz

To uncompress, use any Linux facility. On the command line, "tar -xzvf cpuutil-0.1.tgz".

Also see

Similar commands: top, mpstat, sar

Author

I can be contacted by emailing "greg (at) uofr dot net".


Read more computer-related articles

© 2008 Greg Briggs except where attributed otherwise