3

Here's the output (first line) of cat /proc/stat:

$ cat /proc/stat
cpu  1089754000 1806405811 36616 32667836 1477 0 11090 12536 0 0

whereas at the same time, if I run top command, this is what it shows:

%Cpu(s):  0.0 us,  0.1 sy,  6.3 ni, 93.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

Which obvious is not consistent between each other (e.g., user=1089754000 and nice=1806405811 is much higher than idle=32667836 in /proc/stat whereas its reversed in top command)

Any idea? Thanks.

1 Answer 1

5

The numbers in /proc/stat are totals from the time the system was booted. The values in top reflect the current utilization, in other words the rate of change of the stat values.

Put another way, the stat values are like the mileage on a car, compared to the speed of the car.

2
  • any idea where does top gets all infos regarding cpu & load balance? Since new relic could still trace instance CPU even if top command if removed from linux. I intend to dig into new relic's mechanism for retrieving metrics on linux since it doesn't provide source code. Thanks.
    – KAs
    Dec 26, 2017 at 18:57
  • 1
    The general solution for this kind of problem is to run strace -s 5000 -f -o /tmp/strace.out top and then examine the /tmp/strace.out file to see what the command is reading.
    – icarus
    Dec 26, 2017 at 19:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .