1

My fan is whirring on my Ubuntu laptop and htop is showing my CPU as maxed:

CPU

However, looking at the processes ordered by CPU it doesn't seem like too much is going on other than gjs at 41.3%.

Processes ordered by CPU

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"
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
  • Hey, I don't think I've been awarded the bounty yet, since you accepted my answer in the grace period where you need to award it manually. Thanks – AlexApps99 May 23 '22 at 21:21

1 Answers1

0

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

AlexApps99
  • 3,506
  • 9
  • 21