LINUX - CPU Usage
Checking CPU and RAM is one of the important Task. Though we have monitoring enable to check CPU and RAM stats we ran into a situation where we need to check the CPU and RAM utilization live during debugging session.
CPU: To list No of CPU run lscpu same can be checked using cat /proc/cpuinfo
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
Thread(s) per core: 2
Core(s) per socket: 6
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Model name: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Stepping: 10
CPU MHz: 880.944
CPU max MHz: 4600.0000
CPU min MHz: 800.0000
BogoMIPS: 6399.96
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 12288K
NUMA node0 CPU(s): 0-11
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 art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
Command/packages used:
1) top
$ top -b -o %CPU|head -n 14
top - 19:20:05 up 14 days, 7:19, 1 user, load average: 0.26, 0.26, 0.30
Tasks: 405 total, 1 running, 286 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.0 us, 1.5 sy, 0.0 ni, 95.4 id, 0.9 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 32715792 total, 26931648 free, 1041288 used, 4742856 buff/cache
KiB Swap: 32718844 total, 30952632 free, 1766212 used. 30715712 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5361 root 20 0 2493424 60552 19080 S 20.0 0.2 315:28.63 dockerd
8390 root 20 0 4079860 85948 44628 S 20.0 0.3 759:37.65 kubelet
3307040 sivavadd 20 0 42612 3736 3136 R 6.7 0.0 0:00.01 top
1 root 20 0 186072 5872 3356 S 0.0 0.0 1:57.37 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.47 kthreadd
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
2) ps
$ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%cpu|head
3) vmstat
# vmstat 1 5 -w
procs -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu--------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 1766212 26925340 228128 4515200 0 2 13 15 2 2 2 2 95 1 0
0 1 1766212 26925324 228128 4515208 0 0 0 144 2207 5731 1 1 95 3 0
0 0 1766212 26925356 228128 4515184 0 0 0 28 1592 4243 1 0 99 0 0
0 1 1766212 26925208 228128 4515184 0 0 0 64 2601 6819 1 0 98 1 0
1 0 1766212 26924828 228128 4515184 0 0 0 32 1507 4017 0 1 99 0 0
Comments
Post a Comment