5

When I use command mpstat, I see an idle value, for example 25%. It means 75% of CPU power is used.

If there are 4 cores on CPU, then does 25% idle mean that 3 cores are fully used and 1 core is not used at all?

What command shall I use to see the total CPU usage of all cores?

fixer1234
  • 28,064
alwbtc
  • 3,085
  • 13
  • 35
  • 43

2 Answers2

3

If you want to see the stats for all individual cores, use mpstat -P ALL:

enter image description here

Without -P ALL, you'll get the average of all cores. Displayed in the shown output in the all line.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
2

25% idle on a four core machine means that the average core was 25% idle. That could mean that three cores were used all the time and one was idle. It could also mean that all four cores were active 75% of the time. It can mean anything in-between.

What command shall I use to see the total CPU usage of all cores?

It's just math. If you have 4 cores and they were 25% idle, the total CPU usage of all cores is

    4 * (1 - 25/100)
or 3.0 -- the equivalent of three cores at 100% usage.

If you want to see individual cores, the easiest way is to run top and then hit the 1 key to show all cores. You can then use H to show threads and f j <enter> to show which core each thread last ran on (the P column).