Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 

Process Utilization per Core

HeikoAnkenbrand
Champion
Champion

espupc123.JPG

With this onliner you can view the process load of each core.
Change the variable CORE to the correct core number (for example CORE=3):

 


   CORE=3; ps --sort=-c -e -o pid,psr,%cpu,%mem,cmd | grep -E "^[[:space:]][[:digit:]]+[[:space:]]+${CORE}"
  

 

ps L       -> List all format specifiers (for example pid, psr, %cpu, %mem, ...)

ps_core_2.jpg

There is still much potential for improvement here 🙂

;
TO ACCESS CHECKMATES TOOLBOX it's simple and free

Disclaimer: Check Point does not provide maintenance services or technical or customer support for third party content provided on this Site, including in CheckMates Toolbox. See also our Third Party Software Disclaimer.




1 Solution

Accepted Solutions

HeikoAnkenbrand
Champion
Champion

I always use this one:

 


   watch -n 1 'CORE=2; ps --sort=-c -e -o pid,psr,%cpu,%mem,wchan,vsize,time,cmd | grep -E "^[[:space:]][[:digit:]]+[[:space:]]+${CORE}"'
  

 

> Refresh display every second
> For core two (set CORE=x parameter)
> Is sorted by CPU load
> The following fields are used:
   - Process ID
   - Core
   - CPU utilization in %
   - Memory utilization in %
   - Process type
   - Process memory usage in KB
   - Process time
   - Process path+command

Output:

onliner_ps_1.JPG

If y

...;
TO ACCESS CHECKMATES TOOLBOX it's simple and free


5 Replies

HeikoAnkenbrand
Champion
Champion

I always use this one:

 


   watch -n 1 'CORE=2; ps --sort=-c -e -o pid,psr,%cpu,%mem,wchan,vsize,time,cmd | grep -E "^[[:space:]][[:digit:]]+[[:space:]]+${CORE}"'
  

 

> Refresh display every second
> For core two (set CORE=x parameter)
> Is sorted by CPU load
> The following fields are used:
   - Process ID
   - Core
   - CPU utilization in %
   - Memory utilization in %
   - Process type
   - Process memory usage in KB
   - Process time
   - Process path+command

Output:

onliner_ps_1.JPG

If y

...;
TO ACCESS CHECKMATES TOOLBOX it's simple and free


KernelGordon
Employee Alumnus
Employee Alumnus

Really like this one-liner, made a small change to have it run over all cores and sort by CPU usage or Memory usage:

Sort by CPU:


   echo "" > coreload.txt ; for (( cpuCore = 0; cpuCore < $(cpstat os -f cpu | grep Number: | awk '{print $3}'); ++cpuCore )); do CORE=${cpuCore}; ps -e -o pid,psr,%cpu,%mem,cmd | grep -E "^[[:space:]][[:digit:]]+[[:space:]]+${CORE}" >> coreload.txt; done ; cat coreload.txt | sort -k3 -gr
  

Sort by Memory:


   echo "" > coreload.txt ; for (( cpuCo
...;
TO ACCESS CHECKMATES TOOLBOX it's simple and free


HeikoAnkenbrand
Champion
Champion

Hi @KernelGordon,

You can use this! It is quick and easy:


   ps --sort=-c -e -o pid,psr,%cpu,%mem,wchan,vsize,time,cmd
  

   ps --sort=-vsize -e -o pid,psr,%cpu,%mem,wchan,vsize,time,cmd
  

You can sort directly into ps with "--sort". If you use a "--sort=-" it will sort in reverse order 🙂

;
TO ACCESS CHECKMATES TOOLBOX it's simple and free


HeikoAnkenbrand
Champion
Champion

Or just to monitor the firewall workers


   watch -n 1 'ps --sort=-c -e -o pid,psr,%cpu,%mem,wchan,time,cmd |grep "fw_worker_"|grep -v pipe|grep -v grep ' 
  

Output:

firewall_worker_1.JPG

;
TO ACCESS CHECKMATES TOOLBOX it's simple and free


KernelGordon
Employee Alumnus
Employee Alumnus

Nice find! I wasn't aware of the 'psr' format specifier. Time to read the man page and see if there are any other neat things to add to this 😀

;
TO ACCESS CHECKMATES TOOLBOX it's simple and free