Why does mpstat show different values when I use the interval setting?

Posted by Abe on Server Fault See other posts from Server Fault or by Abe
Published on 2012-09-18T00:27:01Z Indexed on 2012/09/18 3:40 UTC
Read the original article Hit count: 679

Filed under:
|

Here's the output I get when I run mpstat:

$mpstat
Linux 3.2.0-30-generic (my-laptop-C650)     09/17/2012  _x86_64_    (2 CPU)

05:32:01 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
05:32:01 PM  all    9.16    0.08    2.69    2.00    0.00    0.04    0.00    0.00   86.02

And here's what I get when I run it with a one-second interval:

$mpstat 1
05:31:51 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
05:31:52 PM  all    1.52    0.00    1.01    0.00    0.00    0.00    0.00    0.00   97.47
05:31:53 PM  all    2.04    0.00    1.02    0.00    0.00    0.00    0.00    0.00   96.94
05:31:54 PM  all    1.50    0.00    1.50    0.00    0.00    0.00    0.00    0.00   97.00

Why does the first process show the processor as 86% idle, and the second show it as ~97% idle? I've tried this in a bunch of different configurations, and it's not a real difference in CPU usage -- unless mpstat itself is making the difference.

Which number should I trust?

© Server Fault or respective owner

Related posts about cpu

Related posts about cpu-usage