Mpstat and sar

HI I ma using mpstat and sar commands to check the cpu utilisation

but the results are not matching .I dont understand why thisis happening?

 
$ sar -u 12 5
Linux 2.6.9-89.35.1.ELhugemem (abcd.efgh.com)   03/07/2013
02:43:16 AM       CPU     %user     %nice   %system   %iowait     %idle
02:43:28 AM       all     41.91      0.00     57.86      0.00      0.23
02:43:40 AM       all     43.18      0.00     56.64      0.00      0.19
$ mpstat
Linux 2.6.9-89.35.1.ELhugemem (abcd.efgh.com)   03/07/2013
02:43:47 AM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
02:43:47 AM  all   20.26    0.06   65.69    0.29    0.03    0.00   13.67   2534.05

so in this case mpstat saying 13.67% is idle where as sar is saying .19%
which one to trust
again when i use mpstat 12 5 ,it is giving correct.

 
$ mpstat 12 5
Linux 2.6.9-89.35.1.ELhugemem (abcd.efgh.com)   03/07/2013
02:44:56 AM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
02:45:08 AM  all   36.71    0.00   63.02    0.00    0.02    0.00    0.25   1977.54
02:45:20 AM  all   38.90    0.00   60.77    0.00    0.06    0.00    0.27   3640.83
02:45:32 AM  all   38.86    0.00   60.75    0.02    0.02    0.00    0.35   2614.83
02:45:44 AM  all   67.70    0.00   32.19    0.00    0.02    0.00    0.08   2506.00
02:45:56 AM  all   62.68    0.00   37.28    0.00    0.04    0.00    0.00   1635.89
Average:     all   48.97    0.00   50.80    0.00    0.03    0.00    0.19   2474.71

mpstat is a /proc repository based utility and without any parameters, it will display the averaged output since last reboot or as from the man page

# mpstat
01:19:14 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest
01:19:14 PM  all    2.42    0.00    0.65    3.84    0.00    0.01    0.00    0.00
#

sar also gathering data from /proc gives you the output based on the switches without any averages and the default behavior is to start real time reporting ( without any options)

you should be able to see that both mpstat and the sar start giving same output as below:

# sar -u 1
01:26:30 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
01:26:31 PM     all      0.50      0.00      0.50      0.00      0.00     99.00
01:26:32 PM     all      0.50      0.00      0.00      0.00      0.00     99.50
01:26:33 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
01:26:34 PM     all      1.00      0.00      0.00      0.00      0.00     99.00
01:26:35 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
01:26:36 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
01:26:37 PM     all      0.50      0.00      0.00      1.99      0.00     97.51
01:26:38 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
01:26:39 PM     all      0.50      0.00      0.00      0.00      0.00     99.50
01:26:40 PM     all      0.50      0.00      0.00      0.00      0.00     99.50
# mpstat 1
01:26:32 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
01:26:33 PM  all    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00   99.50
01:26:34 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
01:26:35 PM  all    1.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.00
01:26:36 PM  all    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00   99.50
01:26:37 PM  all    0.50    0.00    0.00    1.01    0.00    0.00    0.00    0.00   98.49
01:26:38 PM  all    0.00    0.00    0.50    0.99    0.00    0.00    0.00    0.00   98.51
01:26:39 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
01:26:40 PM  all    0.50    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.50
01:26:41 PM  all    0.99    0.00    0.50    0.00    0.00    0.00    0.00    0.00   98.51