With sar and iowait, we can get CPU time utilization. But, when I executed both commands, I could see significant differences in their outputs.

 > iostat && sar 1 1
Linux 2.6.32-042stab090.4 (LinuxBox)     08/14/2014      _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.46    0.00    0.52    0.07    0.00   98.95

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda              10.53       760.66        44.67 3464410204  203460004
sdb               2.49       368.15       779.18 1676748162 3548769968
sdc               4.09       192.81        10.71  878170395   48792907

Linux 2.6.32-042stab090.4 (LinuxBox)     08/14/2014      _x86_64_        (16 CPU)

10:35:21 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
10:35:22 AM     all      0.00      0.00      0.06      0.00      0.00     99.94
Average:        all      0.00      0.00      0.06      0.00      0.00     99.94

It is very difficult for me to decide which output is more reliable. Which command should be considered as more accurate one?

  • I wouldn't expect accurate IO statistics from inside of a VZ container, regardless of the tool. Anyways, the difference there is sar shows a daily average and iostat without options is since boot. – jordanm Aug 14 '14 at 5:28
  • In order to monitor live data, sar command would be more useful, is it the case? – Mandar Shinde Aug 14 '14 at 5:30

You are running iostat without giving any interval. So, it will report the statistics since the boot time.

Whereas for sar, you mentioned 1 interval. This means in sar report, the report is for the last 1 second.

Both uses /proc/ for getting these reports, where all these values are stored as counters (increases time to time). You can read much about which filesystem that these reports uses from the man pages (scroll to the end of the man page). Also read about counters, if you don't understand my point.

And then, the reports are obtained by knowing the values at any two points of time and calculating the difference in the values for those two points of time. Hence, if interval is not specified, as there is only 1 point of time (i.e., the time you ran the command) and it considers boot time as other point of time. That's why you get the average since boot time.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.