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

7,433

When you run mpstat for first time, it calculates the idle time since the server has booted up to the point where you have run mpstat.

But when you run it with intervals, you are getting the value within the defined time amount you specified, here 1 second. And not the entire time since boot up and then to that moment.

In fact, iostat, vmstat all work in this same way as I told,

Share:
7,433

Related videos on Youtube

Abe
Author by

Abe

Updated on September 18, 2022

Comments

  • Abe
    Abe over 1 year

    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?

  • Amos Folarin
    Amos Folarin over 9 years
    mpstat -P ALL 2 5