I've searched the net but i haven't found a satisfactory solution. Is there any good way to get average CPU utilization for the whole CPU and all processes ? Like the windows taskmanager.

I've tried the following commands, while the system is launching a Minecraft Server. A somewhat intensive task, when it is running a Raspberry Pi:

echo $[100-$(vmstat 1 2|tail -1|awk '{print $15}')]

If i run that command every one second i get everything from 0% to 80%. Not sure that it is reliable.

cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'

This only gives a result between 0% and 2%

grep -P '^processor' /proc/cpuinfo|wc -l

Never gets over 25%, which i also find quite unlikely

I've read that 'top' does not show the actual cpu usage, but something with cpu usage between refreshes or something.

Is there any other way ? Preferably a solution where i do not have to install anything..

  • Of course top shows averages. So does Task Manager. If you try to show atomic values, you won’t be able to see any meaningful information.
    – Daniel B
    Mar 10 '17 at 8:49
  • There are also monitoring tools that will collect your CPU data and provide average, min and max values as well graphic them. Such tools use to be large tools designed for medium and large computer environments, but perhaps you may want take a look to them. Search for Nagios, Zabbix and Cacti for example. Mar 10 '17 at 10:47

CPU usage accuracy comes from retaining CPU state between readings so that usage for the entire period is obtained. Most solutions only get the usage from when the reading is done, or having averaging done over arbitrary periods.

If you really need accuracy, you need to measure very often and centralize the results. That way you could even detect spikes. Depending on many factors, note that it is not at all abnormal for CPU usage not to exceed 25%.

For processes, you will have to use the PIDs. See some practical solutions here .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.