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:
- The
topcommand — an interactive process and CPU load monitor. - The
htopcommand — an improved version of top with a user-friendly interface. - The
uptimecommand — shows the average load over 1, 5, and 15 minutes. - Reading the
/proc/loadavgfile — 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.