Linux – Get CPU utilization in frequency for a specific proccess in Linux

cpu-usagelinux

I want to get the realtime CPU frequency which is using by a process in Linux. I think I should use top command. But I want to know the '%CPU' column in top is the percent of CPU usage for a process per 1 core or per all CPU cores? for example, in the following output of top, how many CPU frequency is used by firefox?

Tasks: 279 total,   1 running, 277 sleeping,   0 stopped,   1 zombie
%Cpu(s):  5.0 us,  1.3 sy,  0.1 ni, 88.8 id,  4.8 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8059824 total,  1540120 free,  3931444 used,  2588260 buff/cache
KiB Swap:  3998716 total,  3998716 free,        0 used.  3626336 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                           
29941 sina      20   0 2345056 304040 144348 S   7.7  3.8   2:02.08 firefox                                                                           
 1222 root      20   0  447092 107272  70064 S   4.3  1.3  53:31.25 Xorg                                                                              
 2857 sina      20   0 1671448 362580  74016 S   4.3  4.5  82:19.20 compiz                                                                            
30582 sina      20   0 1619480 164448 120608 S   3.7  2.0   0:09.28 Web Content

Here's the ouptput of lscpu in my machine:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 60
Model name:            Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz
Stepping:              3
CPU MHz:               3400.265
CPU max MHz:           3400.0000
CPU min MHz:           800.0000
BogoMIPS:              6784.33
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0-3
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm invpcid_single ssbd ibrs ibpb stibp kaiser tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm arat pln pts flush_l1d

Best Answer

From top command press '1', it will give you cores usage on system now specify processes id to limit the output.

Related Topic