On a heavily loaded database server, I am getting vastly different output from top
and iostat
for cpu usage. Why might the value be different?
top:
%Cpu(s): 84.7 us, 11.8 sy, 0.3 ni, 2.4 id, 0.6 wa, 0.0 hi, 0.2 si, 0.1 st
iostat
avg-cpu: %user %nice %system %iowait %steal %idle
19.78 0.17 2.51 1.10 0.03 76.42
Note that iostat
is reporting significant idle percentage and top
is not.
Best Answer
The reason for this is that on a single run of
iostat
the statistics reported are since system boot.iostat -c 2 2
will report once since boot, then 2 seconds later with a second report since the previous.In this case it matched closely with top.