What is the relation between values from TOP and SAR commands?

Hi,

Please have a look at the look at the below top and sar commands.

top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}'
CPU Load: 0.52

 sar -u 1 1
Linux 3.10.0-514.16.1.el7.x86_64 (mymac)  06/01/2017      _x86_64_        (2 CPU)
 03:27:40 PM    CPU  %user   %nice   %system  %iowait  %steal   %idle
03:27:41 PM     all  12.17   0.00     4.23     0.00     0.00    83.60
Average:        all  12.17   0.00     4.23     0.00     0.00    83.60

Question 1: What is the difference between the CPU load shown by the top command and that shown by the sar command ?

Question 2: How can I get sar command to shown the same value as top ?

You are extracting the 1 minute load average from "top" but your sar command is displaying the CPU usage. These statistics are only loosely related.

You can run "sar -q 1 1", the load average you are picking from "top" output would be column labeled "ldavg-1".

1 Like