티스토리 뷰

CPU 확인하는 방법

1. /proc/cpuinfo

/proc/cpuinfo 의 파일 내용을 보는 방법이 있습니다.

각 CPU Core의 개별 상세 정보를 모두 볼 수 있습니다.

$ cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 85
model name	: Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
stepping	: 4
microcode	: 0x1
cpu MHz		: 2194.842
cache size	: 4096 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f rdseed adx smap clflushopt clwb avx512cd xsaveopt xsavec xgetbv1 arat spec_ctrl
bogomips	: 4389.68
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 85
model name	: Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
stepping	: 4
microcode	: 0x1
cpu MHz		: 2194.842
cache size	: 4096 KB
physical id	: 1
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f rdseed adx smap clflushopt clwb avx512cd xsaveopt xsavec xgetbv1 arat spec_ctrl
bogomips	: 4389.68
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

2. lscpu

sysfs 와 /proc/cpuinfo 로 부터 가져온 CPU architecture 정보를 보여줍니다.

개별 코어의 상세 정보를 모두 보고 싶은 것이 아니라면, lscpu로 보는 것이 간편합니다.

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-15
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             16
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 85
Model name:            Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
Stepping:              4
CPU MHz:               2194.842
BogoMIPS:              4389.68
Virtualization:        VT-x
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              4096K
NUMA node0 CPU(s):     0-15
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f rdseed adx smap clflushopt clwb avx512cd xsaveopt xsavec xgetbv1 arat spec_ctrl

 

메모리 확인 방법

1. free -m

간단하게 전체와 사용된 그리고 가용한 메모리 정보를 MB  단위로 확인할 수 있습니다.

( 보고 싶은 용량 단위에 따라 옵션은 변경 가능합니다. )

$ free -m
              total        used        free      shared  buff/cache   available
Mem:           7981        7048          56         365         876         452
Swap:             0           0           0

Usage:
 free [options]

Options:
 -b, --bytes         show output in bytes
 -k, --kilo          show output in kilobytes
 -m, --mega          show output in megabytes
 -g, --giga          show output in gigabytes
     --tera          show output in terabytes
     --peta          show output in petabytes
 -h, --human         show human-readable output

total : 설치된 총 메모리 크기 / 설치된 스왑? 총 크기

used : total - free - buff/cache 사용중인 메모리 / 사용중인 스왑 크기

free : total - used - buff/cache 실제 사용 가능한 여유 있는 메모리량 / 사용되지 않은 스왑 크기

buffers : 커널 버퍼로 사용중인 메모리

cache : 페이지 캐시와 slab으로 사용중인 메모리

buff/cache : buffers + cache 사용중인 메모리

available : 새로운 프로세스에서 할당 가능한 메모리의 예상 크기

2. /proc/meminfo

cpu 정보를 보는 것과 마찬가지로, /proc/meminfo 파일의 내용을 읽어 확인할 수 있습니다.

$ cat /proc/meminfo

MemTotal:        8173128 kB
MemFree:           62656 kB
MemAvailable:     468600 kB
Buffers:          117088 kB
Cached:           670148 kB
SwapCached:            0 kB
Active:          7646348 kB
Inactive:         234952 kB
Active(anon):    7390500 kB
Inactive(anon):    78252 kB
Active(file):     255848 kB
Inactive(file):   156700 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               200 kB
Writeback:             0 kB
AnonPages:       7094084 kB
Mapped:            57340 kB
Shmem:            374680 kB
Slab:             110748 kB
SReclaimable:      74856 kB
SUnreclaim:        35892 kB
KernelStack:       11248 kB
PageTables:        28204 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1634624 kB
Committed_AS:    7901004 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       21700 kB
VmallocChunk:   34359707388 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      173948 kB
DirectMap2M:     8214528 kB
DirectMap1G:     2097152 kB

 

3. 특정 프로세스의 사용 중인 메모리

cat /proc/{pid}/status 명령어로 현재 특정 프로세스에서 사용 중인 메모리를 확인할 수 있습니다.

$ cat /proc/4686/status
Name:	java
Umask:	0022
State:	S (sleeping)
Tgid:	4686
Ngid:	0
Pid:	4686
PPid:	1
TracerPid:	0
Uid:	516	516	516	516
Gid:	515	515	515	515
FDSize:	1024
Groups:	515
VmPeak:	12128404 kB	// 최대로 할당된 가상메모리 크기
VmSize:	12120768 kB	// 가상 메모리 크기
VmLck:	       0 kB
VmPin:	       0 kB
VmHWM:	 1809408 kB	// 최대로 할당된 물리메모리 크기
VmRSS:	 1809408 kB	// 물리 메모리 크기
RssAnon:	 1772496 kB
RssFile:	   36912 kB
RssShmem:	       0 kB
VmData:	11056316 kB
VmStk:	     132 kB
VmExe:	       4 kB
VmLib:	   22892 kB
VmPTE:	    5416 kB
VmSwap:	       0 kB
Threads:	210

 

특정 프로세스의 CPU와 메모리 사용량 확인

top -b -p pid | grep pid 또는 top -b -n 횟수 -p pid | grep pid

매초 마다 특정 프로세스의 상태를 확인할 수 있습니다.

-n 옵션을 통해 몇 번 확인 할 것인지도 설정할 수 있습니다.

$ top -b -p 353484 | grep 353484
 353484 metatron  20   0 7832788   1.5g  18576 S   0.0   2.4   8:43.17 java
 353484 metatron  20   0 7832788   1.5g  18576 S   0.3   2.4   8:43.18 java
 353484 metatron  20   0 7832788   1.5g  18576 S   0.3   2.4   8:43.19 java
 
 $ top -b -n 2 -p 353484 | grep 353484
 353484 metatron  20   0 7832788   1.5g  18576 S   0.0   2.4   8:43.39 java
 353484 metatron  20   0 7832788   1.5g  18576 S   0.7   2.4   8:43.41 java
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함