Sobes.tech
Junior — Middle

How to determine the current CPU load on a Linux system?

sobes.tech AI

Answer from AI

There are several ways to determine the current CPU load in Linux:

  1. The top command — an interactive process and CPU load monitor.
  2. The htop command — an improved version of top with a user-friendly interface.
  3. The uptime command — shows the average load over 1, 5, and 15 minutes.
  4. Reading the /proc/loadavg file — contains the load average values.

Example of using uptime:

uptime
 14:23:01 up 10 days,  3:12,  2 users,  load average: 0.15, 0.10, 0.05

Load average values show the average CPU load over the last 1, 5, and 15 minutes.

For more precise analysis, you can use mpstat from the sysstat package:

mpstat 1 3

This will show CPU load per core at 1-second intervals, three times.