Using Load Average to Measure CPU Usage

In Linux and other UNIX-based operating systems, the CPU usage is often measured in terms of load average . Load average is displayed using three numerical values. Put simply, the load average is the average number of processes waiting to be executed by the operating system over a given time interval. Over a period of time, these readings give a good indication of the computer s current and recent processing load. You can examine the load average in various ways:

  • You can examine the contents of the file /proc/loadavg . Figure 2-42 shows a typical /proc/loadavg file.

    click to expand
    Figure 2-42

    In this example, the first three figures ( 0.44 , 0.29 , 0.17 ) show the load average of the system taken over the last 1, 5, and 15 minutes.

  • You can execute the uptime program, as shown in Figure 2-43.

    click to expand
    Figure 2-43

    Figure 2-43 shows output from a machine whose load average is currently very low, and has actually been decreasing over the last 15 minutes.

    The output from this program also shows the amount of time the computer has been running ”Figure 2-43 shows that the machine has been up for nearly 151/2 hours. It also shows that there are two terminals with users logged into this machine, and the current time on the system.

  • You can execute the top program. This program shows a wealth of information, as specified in Figure 2-44. The display also updates itself every few seconds.

    click to expand
    Figure 2-44

    The first part of the display shows the system s load average and the memory usage in the system. The rest of the display shows the processes running on the system, along with a wealth of information on each process, such as the user privilege under which the process is running, and the process identifier.

    This output is also interactive, allowing you to change various properties of the display and even to kill processes. For more on this, take a look at the Interactive Commands section of the manual (type man top at the command line and space down until you find it).

When you want to exit the top display, press q on your keyboard.

Beginning Fedora 2
Beginning Fedora 2
ISBN: 0764569961
EAN: 2147483647
Year: 2006
Pages: 170 © 2008-2017.
If you may any questions please contact us: