My fan is whirring on my Ubuntu laptop and htop
is showing my CPU as maxed:
However, looking at the processes ordered by CPU it doesn't seem like too much is going on other than gjs
at 41.3%.
I'm assuming there are just a ton of gjs
processes that are adding up to the rest of the CPU.
Is there anyway to work this out other than manually adding up the CPU%?
NAME="Ubuntu"
VERSION_ID="21.10"
You can sum up CPU usage as shown here.
ps -eo pcpu,command --sort=-pcpu | grep gjs | awk '{sum+=$1} END {print sum}'
The solution they linked actually sums memory, not CPU usage (probably a bug they never caught), I've fixed it so it should work for you.
If you want to make a shell script to reuse, write this to cpusum
for example:
ps -eo pcpu,command --sort=-pcpu | grep "$1" | awk '{sum+=$1} END {print sum}'
then make it executable: chmod +x cpusum
,
and run it ./cpusum gjs