I do not know if this was your issue or not, nor if it is the only issue. This hack seems to fix this issue: top -b -n 2 | grep Cpu | sed 's/:/ /g' | awk '' | sed -n '2 p' ![]() ![]() Indeed, the output running your command gives an incorrect answer sometimes (running it in a loop,where the real load is always 100%): CPU Load: 100.00 Looking in more detail, I'll add the field number below (remember, the default field delimiters are space and tab): %Cpu(s): 98.9 us, 1.1 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stġ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 On the other hand, the htop command offers a. t threshold ignore samples where the CPU usage delta per second less than the given threshold. Notice in the 2nd printing there are only 16 fields instead of 17, because the normal space between the : and the first digit of the "us" load isn't there having been taken up by the "1", and therefore the referencing would be wrong. In terms of system monitoring both commands offer the same functionality. The above example will print the CPU activities after 3 seconds. Using the sar command, you can monitor the CPU usage at a certain interval as follows: sudo apt install sysstat. %Cpu(s): 98.9 us, 1.1 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st This utility displays short details in the form of a report about CPU usage. One example, there may be more: top -b -n 2 | grep Cpu Your processor are taking about one and half of one processor's 'maximum' performance each, and. You are counting fields backwards from the last one, assuming the number is always the same. In top - 100 is the 'full' load of one CPU 'thread' - on a non HT processor, that's one physical core, and on a Hyperthreading capable processor (where you can run 2, or even more threads per physical processor), one of the virtual cores.
0 Comments
Leave a Reply. |