Reputation: 825
I have found that htop command was the only way to display nicely each CPU core's load. I need an average of each CPU core from the last few seconds. However, I do not know how to extract those numbers in a command line. For example, using grep or -n 1. I am running Ångström where I am not allowed to install any more extra packages.
I would like my end result to be:
CPU0: X%
CPU1: X%
I would appreciate any help.
Upvotes: 1
Views: 4301
Reputation: 50248
Instead of htop
which is more of a gui, go straight to /proc/stat and grab what you need.
Using awk:
awk '$1~/cpu[0-9]/{usage=($2+$4)*100/($2+$4+$5); print $1": "usage"%"}' /proc/stat
Upvotes: 1