48

How to log CPU load to a file in order to investigate a problem?

3

6 Answers 6

64

This works very well:

 while true; do uptime >> uptime.log; sleep 1; done
  • This will log your cpu load every second and append it to a file uptime.log.

    You can then import this file into Gnumeric or the OpenOffice spreadsheet to create a nice graph (select 'separated by spaces' on import).

As Scaine noticed, this won't be enough to diagnose the problem. So, additionally, run this (or use his answer for this part):

while true; do (echo "%CPU %MEM ARGS $(date)" && ps -e -o pcpu,pmem,args --sort=pcpu | cut -d" " -f1-5 | tail) >> ps.log; sleep 5; done
  • This will append the Top 10 most CPU hungry processes to a file ps.log every five seconds.

    Note that this is not the full boat-load of information top would give you. This is just the top 10, and just their CPU Usage, Memory Usage and the first argument (i.e. their command without further arguments, as in /usr/bin/firefox)

After you've used a Spreadsheet to create a graph to see when your CPU load went through the roof, you can then search this file for the nearest time to see what process has caused it.

This is what those files will look like:

uptime.log

~$ cat uptime.log 
 22:57:42 up 1 day,  4:38,  4 users,  load average: 1.00, 1.26, 1.21
 22:57:43 up 1 day,  4:38,  4 users,  load average: 0.92, 1.24, 1.21
 22:57:44 up 1 day,  4:38,  4 users,  load average: 0.92, 1.24, 1.21
 22:57:45 up 1 day,  4:38,  4 users,  load average: 0.92, 1.24, 1.21
 ...

ps.log

%CPU %MEM ARGS Mo 17. Jan 23:09:47 CET 2011
 0.7  0.9 /usr/bin/compiz
 0.8  0.5 /usr/lib/gnome-panel/clock-applet
 1.1  1.7 /opt/google/chrome/chrome
 1.2  0.3 /usr/bin/pulseaudio
 1.8  4.0 /opt/google/chrome/chrome
 2.6  1.5 /opt/google/chrome/chrome
 2.6  3.2 /usr/bin/google-chrome
 3.6  2.6 /opt/google/chrome/chrome
 4.9  1.5 /usr/bin/X
 5.7  1.6 /opt/google/chrome/chrome
%CPU %MEM ARGS Mo 17. Jan 23:09:48 CET 2011
 0.7  0.9 /usr/bin/compiz
 0.8  0.5 /usr/lib/gnome-panel/clock-applet
 1.0  1.7 /opt/google/chrome/chrome
 1.2  0.3 /usr/bin/pulseaudio
 1.8  4.0 /opt/google/chrome/chrome
 2.6  1.5 /opt/google/chrome/chrome
 2.6  3.2 /usr/bin/google-chrome
 3.6  2.6 /opt/google/chrome/chrome
 4.9  1.5 /usr/bin/X
 5.7  1.6 /opt/google/chrome/chrome
 ...
4
  • 3
    Does this actually print the correct CPU usage?? I tried this on centos and only the memory usage was correct :(
    – Menelaos
    Jan 18, 2014 at 15:02
  • How can I make this command keep running on my VPS even after I close the Putty connection? Feb 8, 2017 at 1:59
  • 1
    If the CPU usage reported by ps is nonsensical, try running it as root. Feb 21, 2017 at 9:45
  • 1
    How can I make this command keep running on my VPS even after I close the Putty connection????
    – Mostafa
    Sep 7, 2019 at 7:20
16

You can run the top command in batch mode by using the -b option, then dump that to a file.

On start up of your PC, open a terminal, run

top -b > ~/cpu.txt

Then when your PC freezes, simply open the (probably huge) text file and check the last entry for some detail on what was running just before the crash. In the fact the file will be so stupidly large that you're better off running a tail -250 ~/cpu.txt instead.

Also check your /var/log/kern.log in case your issue is hardware related (unlikely if this is only happening after an upgrade, but worth checking nonetheless).

6

I found a great answer by Christopher to this question on Unix and Linux that uses top:

top -n 1 -b > top.out

This will give you 1 iteration of top then stop, and then push it to a file.

1

For those who need to run this command after your putty ( SSH client ) session end. you can use command screen ( or install it using apt-get )

0

I`ve got an script for get the process load, with rotating logs:

#!/bin/bash 
MaxFileSize=204800
DaysToKeep=7
echo -e "\n Fecha:"`date` >> /var/log/ps.log
echo -e "\n Uptime: "`uptime` >> /var/log/ps.log
ps -e -o pcpu,pmem,args --sort=pcpu | tail >> /var/log/ps.log
#Get size in bytes** 
file_size=`du -b /var/log/ps.log | tr -s '\t' ' ' | cut -d' ' -f1`
if [ $file_size -gt $MaxFileSize ];then   
    timestamp=`date +%s`
    mv /var/log/ps.log /var/log/ps.log.$timestamp
    gzip /var/log/ps.log.$timestamp
    touch /var/log/ps.log
    # remove old files
    find /var/log -name "ps.log.*" -type f -mtime +$DaysToKeep -delete 
fi

My original source can be browsed here

0

Here's a logging script I wrote and use: cpu_logger.py. It logs continuously to a set of rotating log files. It allows me to write reports to Google like this: Chrome Google Meet CPU usage is still too high (see plots and CPU usage during Google Meet with my camera ON vs OFF).

Run it at a high priority with the soft real-time Round Robin (rr) scheduler so it can log even when your system freezes:

sudo chrt -rr 1 path/to/eRCaGuy_dotfiles/useful_scripts/cpu_logger.py

View the output live with:

less -N --follow-name +F ~/cpu_log.log

Here is some sample output for only 2 log periods (at logging loop iterations 2 and 3):

2022-12-13__11:15:54, INFO, ======================== START of loop count 2 =============================

Output from `psutil`:
===> Overall CPU usage:  6.74% <===     Individual CPUs:     7.10%,  5.40%,  6.60%,  8.40%,  6.80%,  8.10%,  6.10%,  5.40%

Output from `ps`:
     1/10)   9.60%  cmd:    /opt/google/chrome/chrome --type=gpu-process --enable-logging --v=1 --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --enable-logging --v=1 --shared-files --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     2/10)   9.60%  cmd:    /opt/google/chrome/chrome --enable-logging --v=1
     3/10)   7.10%  cmd:    /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/46153590/gdm/Xauthority -background none -noreset -keeptty -verbose 3
     4/10)   3.60%  cmd:    /usr/bin/gnome-shell
     5/10)   2.80%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=2676 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=66582148957 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     6/10)   2.70%  cmd:    /opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --enable-logging --v=1 --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     7/10)   2.70%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=84780073 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     8/10)   2.70%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=251 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=197275785 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     9/10)   2.30%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=92 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=134655739 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
    10/10)   1.80%  cmd:    /home/gabriel.staples/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_19.0.1.v20221102-1007/jre/bin/java --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED -Dosgi.requiredJavaVersion=17 [email protected]/eclipse-workspace -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms1024m -Xmx12288m --add-modules=ALL-SYSTEM -Declipse.p2.max.threads=4 -Doomph.update.url=https://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ --add-opens=java.base/java.lang=ALL-UNNAMED -Djava.security.manager=allow -jar /home/gabriel.staples/eclipse/cpp-2022-09/eclipse//plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -os linux -ws gtk -arch x86_64 -showsplash /home/gabriel.staples/.p2/pool/plugins/org.eclipse.epp.package.common_4.25.0.20220908-1200/splash.bmp -launcher /home/gabriel.staples/eclipse/cpp-2022-09/eclipse/eclipse -name Eclipse --launcher.library /home/gabriel.staples/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.600.v20220720-1916/eclipse_11701.so -startup /home/gabriel.staples/eclipse/cpp-2022-09/eclipse//plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar --launcher.appendVmargs -exitdata c8003 -product org.eclipse.epp.package.cpp.product -vm /home/gabriel.staples/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_19.0.1.v20221102-1007/jre/bin/java -vmargs --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED -Dosgi.requiredJavaVersion=17 [email protected]/eclipse-workspace -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms1024m -Xmx12288m --add-modules=ALL-SYSTEM -Declipse.p2.max.threads=4 -Doomph.update.url=https://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ --add-opens=java.base/java.lang=ALL-UNNAMED -Djava.security.manager=allow -jar /home/gabriel.staples/eclipse/cpp-2022-09/eclipse//plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar

Output from `top`:

top - 11:15:58 up 18:48,  1 user,  load average: 1.22, 0.97, 1.00
Tasks: 553 total,   1 running, 463 sleeping,   0 stopped,   0 zombie
%Cpu(s):  7.0 us,  1.5 sy,  0.0 ni, 91.0 id,  0.3 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem : 32653848 total,  1021180 free, 17097652 used, 14535016 buff/cache
KiB Swap: 67108860 total, 67037692 free,    71168 used. 11074732 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
18471 root      -2   0   54124   5616   4340 R  23.5  0.0   0:00.05 top
 4924 gabriel+  20   0  1.104t 154220  96964 S  11.8  0.5  30:31.56 chrome
 3861 gabriel+  20   0 1665116 461364 419480 S   5.9  1.4  80:44.29 Xorg
 4663 gabriel+  20   0 32.845g 343052 172952 S   5.9  1.1 108:34.41 chrome
 4667 gabriel+  20   0 32.531g 159260  95968 S   5.9  0.5  31:32.68 chrome
10621 gabriel+  20   0  1.104t 622144 111376 S   5.9  1.9  30:56.39 chrome
    1 root      20   0  226380   8948   5576 S   0.0  0.0   1:08.29 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.13 kthreadd
    6 root       0 -20       0      0      0 I   0.0  0.0   0:01.80 kworker/0:+
    7 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_+
    8 root      20   0       0      0      0 S   0.0  0.0   0:04.77 ksoftirqd/0
    9 root      20   0       0      0      0 I   0.0  0.0   1:43.23 rcu_sched
   10 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.11 migration/0
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.22 watchdog/0
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1
   15 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 watchdog/1
   16 root      rt   0       0      0      0 S   0.0  0.0   0:00.07 migration/1
   17 root      20   0       0      0      0 S   0.0  0.0   0:01.78 ksoftirqd/1
   19 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:+
   20 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2
   21 root      rt   0       0      0      0 S   0.0  0.0   0:00.19 watchdog/2
   22 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/2
   23 root      20   0       0      0      0 S   0.0  0.0   0:01.87 ksoftirqd/2
   25 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/2:+
   26 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/3
   27 root      rt   0       0      0      0 S   0.0  0.0   0:00.22 watchdog/3
   28 root      rt   0       0      0      0 S   0.0  0.0   0:00.06 migration/3
   29 root      20   0       0      0      0 S   0.0  0.0   0:08.57 ksoftirqd/3
   31 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/3:+
   32 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/4
   33 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 watchdog/4
   34 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/4
   35 root      20   0       0      0      0 S   0.0  0.0   0:01.34 ksoftirqd/4
   37 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/4:+
   38 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/5
   39 root      rt   0       0      0      0 S   0.0  0.0   0:00.19 watchdog/5
   40 root      rt   0       0      0      0 S   0.0  0.0   0:00.07 migration/5
   41 root      20   0       0      0      0 S   0.0  0.0   0:01.02 ksoftirqd/5
   43 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/5:+
   44 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/6
   45 root      rt   0       0      0      0 S   0.0  0.0   0:00.19 watchdog/6

2022-12-13__11:15:58, INFO, ======================== START of loop count 3 =============================

Output from `psutil`:
===> Overall CPU usage:  9.01% <===     Individual CPUs:    10.70%,  7.70%,  8.70%,  9.40%,  8.10%, 10.90%,  7.60%,  9.00%

Output from `ps`:
     1/10)   9.60%  cmd:    /opt/google/chrome/chrome --type=gpu-process --enable-logging --v=1 --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --gpu-preferences=WAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAABAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA== --enable-logging --v=1 --shared-files --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     2/10)   9.60%  cmd:    /opt/google/chrome/chrome --enable-logging --v=1
     3/10)   7.10%  cmd:    /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/46153590/gdm/Xauthority -background none -noreset -keeptty -verbose 3
     4/10)   3.60%  cmd:    /usr/bin/gnome-shell
     5/10)   2.80%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=2676 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=66582148957 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     6/10)   2.70%  cmd:    /opt/google/chrome/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --enable-logging --v=1 --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     7/10)   2.70%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --extension-process --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=6 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=84780073 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     8/10)   2.70%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=251 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=197275785 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
     9/10)   2.30%  cmd:    /opt/google/chrome/chrome --type=renderer --crashpad-handler-pid=4597 --enable-crash-reporter=, --change-stack-guard-on-fork=enable --enable-logging --v=1 --lang=en-US --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=92 --time-ticks-at-unix-epoch=-1670887632073225 --launch-time-ticks=134655739 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,10345357081311849081,14286725297577549623,131072
    10/10)   1.80%  cmd:    /home/gabriel.staples/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_19.0.1.v20221102-1007/jre/bin/java --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED -Dosgi.requiredJavaVersion=17 [email protected]/eclipse-workspace -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms1024m -Xmx12288m --add-modules=ALL-SYSTEM -Declipse.p2.max.threads=4 -Doomph.update.url=https://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ --add-opens=java.base/java.lang=ALL-UNNAMED -Djava.security.manager=allow -jar /home/gabriel.staples/eclipse/cpp-2022-09/eclipse//plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -os linux -ws gtk -arch x86_64 -showsplash /home/gabriel.staples/.p2/pool/plugins/org.eclipse.epp.package.common_4.25.0.20220908-1200/splash.bmp -launcher /home/gabriel.staples/eclipse/cpp-2022-09/eclipse/eclipse -name Eclipse --launcher.library /home/gabriel.staples/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.600.v20220720-1916/eclipse_11701.so -startup /home/gabriel.staples/eclipse/cpp-2022-09/eclipse//plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar --launcher.appendVmargs -exitdata c8003 -product org.eclipse.epp.package.cpp.product -vm /home/gabriel.staples/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_19.0.1.v20221102-1007/jre/bin/java -vmargs --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED -Dosgi.requiredJavaVersion=17 [email protected]/eclipse-workspace -Dsun.java.command=Eclipse -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=11 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Xms1024m -Xmx12288m --add-modules=ALL-SYSTEM -Declipse.p2.max.threads=4 -Doomph.update.url=https://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ --add-opens=java.base/java.lang=ALL-UNNAMED -Djava.security.manager=allow -jar /home/gabriel.staples/eclipse/cpp-2022-09/eclipse//plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar

Output from `top`:

top - 11:16:02 up 18:48,  1 user,  load average: 1.20, 0.97, 1.00
Tasks: 553 total,   1 running, 463 sleeping,   0 stopped,   0 zombie
%Cpu(s):  7.0 us,  1.5 sy,  0.0 ni, 91.0 id,  0.3 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem : 32653848 total,   992152 free, 17102156 used, 14559540 buff/cache
KiB Swap: 67108860 total, 67037692 free,    71168 used. 11045748 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
18480 root      -2   0   54124   5712   4440 R  29.4  0.0   0:00.05 top
 4663 gabriel+  20   0 32.848g 343408 173340 S  11.8  1.1 108:34.77 chrome
 3861 gabriel+  20   0 1664572 461292 419408 S   5.9  1.4  80:45.05 Xorg
 7377 gabriel+  20   0  1.108t 420352 117716 S   5.9  1.3  26:53.60 chrome
    1 root      20   0  226380   8948   5576 S   0.0  0.0   1:08.30 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.13 kthreadd
    6 root       0 -20       0      0      0 I   0.0  0.0   0:01.80 kworker/0:+
    7 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_+
    8 root      20   0       0      0      0 S   0.0  0.0   0:04.77 ksoftirqd/0
    9 root      20   0       0      0      0 I   0.0  0.0   1:43.24 rcu_sched
   10 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.11 migration/0
   12 root      rt   0       0      0      0 S   0.0  0.0   0:00.22 watchdog/0
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1
   15 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 watchdog/1
   16 root      rt   0       0      0      0 S   0.0  0.0   0:00.07 migration/1
   17 root      20   0       0      0      0 S   0.0  0.0   0:01.78 ksoftirqd/1
   19 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:+
   20 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2
   21 root      rt   0       0      0      0 S   0.0  0.0   0:00.19 watchdog/2
   22 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/2
   23 root      20   0       0      0      0 S   0.0  0.0   0:01.87 ksoftirqd/2
   25 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/2:+
   26 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/3
   27 root      rt   0       0      0      0 S   0.0  0.0   0:00.22 watchdog/3
   28 root      rt   0       0      0      0 S   0.0  0.0   0:00.06 migration/3
   29 root      20   0       0      0      0 S   0.0  0.0   0:08.57 ksoftirqd/3
   31 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/3:+
   32 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/4
   33 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 watchdog/4
   34 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/4
   35 root      20   0       0      0      0 S   0.0  0.0   0:01.34 ksoftirqd/4
   37 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/4:+
   38 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/5
   39 root      rt   0       0      0      0 S   0.0  0.0   0:00.19 watchdog/5
   40 root      rt   0       0      0      0 S   0.0  0.0   0:00.07 migration/5
   41 root      20   0       0      0      0 S   0.0  0.0   0:01.02 ksoftirqd/5
   43 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/5:+
   44 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/6
   45 root      rt   0       0      0      0 S   0.0  0.0   0:00.19 watchdog/6
   46 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/6
   47 root      20   0       0      0      0 S   0.0  0.0   0:01.05 ksoftirqd/6

You can also use cpu_load.py to view your CPU load. Example run and output of cpu_load:

$ gs_cpu_load 
Measuring CPU load for 2 seconds...
Overall: 15.21%
Individual CPUs: 13.60%  12.20%  15.20%  14.90%  14.60%  18.50%  15.80%  16.90%

See also my answer here: Stack Overflow: How to get overall CPU usage (e.g. 57%) on Linux and my Q&A here: Unix & Linux: How to get overall CPU usage (e.g. 57%) on Linux.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .