Linux – top command indicates a different cpu usage than sar command

cpu-usagelinuxsartop

In my CentOS server, when I check the resources with sar command, user cpu usage is around %15 while in top command the sole 'java' process uses like %99 of cpu. sometimes it's even goes further than %100!
who's lying here?

Best Answer

Neither -- they're just giving a different idea of CPU usage.

Top's idea of CPU is "per-core" -- that is, "this program is using 100% of one core". A multithreaded program can, therefore, be using, say, "400% CPU" -- which makes the eyes water a little sometimes.

On the other hand, sar sees it as as a percentage of total CPU -- so on a 4 core system, one fully utilised CPU core will show as "25% CPU", and the 400%-using program will show as 100%.

There's also the issue of instantaneous vs long-term averages, but I'm going to assume that you've accounted for that.