4. CPU Monitoring

A fundamental skill in managing a Linux system is understanding its performance. One of the most useful commands for a quick health check is uptime.

pete@icebox:~$ uptime
 17:23:35 up 1 day,  5:59,  2 users,  load average: 0.00, 0.02, 0.05

While we've seen uptime before, let's focus on the load average field, which is crucial for Linux CPU monitoring.

Understanding Load Average

The load average provides a snapshot of the CPU load on your system. The three numbers represent the average CPU load over the last 1, 5, and 15-minute intervals. But what is CPU load? It's the average number of processes in the run-queue, meaning they are either actively being executed by the CPU or are waiting for their turn. This metric is a key indicator of process utilization and overall system performance.

A Traffic Analogy

Imagine a single-core CPU as a single-lane highway.

  • If the highway is at full capacity with a steady flow of cars, traffic is at 100%, which corresponds to a load average of 1.0.
  • If a major traffic jam occurs, and cars are backed up twice the capacity of the highway, the load is 200%, or a load average of 2.0.
  • If the highway is half-empty, the load is 0.5.
  • Ideally, you want a low load average, like a highway at 2 AM with no traffic.

In this analogy, the cars are processes waiting to be handled by the CPU.

Interpreting Load Average on Modern Systems

A load average of 1.0 doesn't necessarily mean your system is struggling. Most modern computers have multi-core processors. If you have a quad-core (4-core) processor, a load average of 1.0 means only 25% of your total CPU capacity is being used. Each core acts as an additional lane on the highway.

To properly interpret the load average, you must consider the number of CPU cores. You can view the number of cores on your system with the command cat /proc/cpuinfo.

A general rule for good system performance is to keep your load average below the number of cores. If you find that your machine consistently has a load average higher than its core count, it could indicate a performance bottleneck, such as a runaway process or insufficient hardware resources.

Sign in to save your learning progress

Sign in

Exercises

To gain practical experience with Linux CPU monitoring and analyzing system performance, try these hands-on labs. They will help you apply the concepts of load average and process utilization in real-world scenarios.

  1. Manage and Monitor Linux Processes - Practice interacting with and inspecting processes, and monitoring resources with tools like ps and top, which directly relates to understanding CPU load.
  2. Linux top Command: Real-time System Monitoring - Learn to use the top command for real-time system monitoring, including sorting processes and filtering, providing a deeper dive into CPU and process activity.
  3. Linux free Command: Monitoring System Memory - Learn to monitor and analyze system memory usage, which is often a critical factor alongside CPU load in overall system performance.

Quiz

What command can you use to see the system's load average? Please answer in English, and note that the command is case-sensitive.