[CENTOS7 8] 查看記憶體

URL Link //n.sfs.tw/15828

2022-05-10 10:05:00 By 張○○

此篇完全參考[1] 的說明做整理

一、free

# free -h
              total        used        free      shared  buff/cache   available
Mem:           5.7G        302M        245M        350M        5.1G        4.6G
Swap:          2.0G         28M        2.0G

 

二、cat /proc/meminfo

# cat /proc/meminfo
MemTotal:        5946568 kB
MemFree:          245052 kB
MemAvailable:    4849768 kB
Buffers:               0 kB
Cached:          4793488 kB
SwapCached:         1996 kB
Active:          2667892 kB
Inactive:        2243620 kB
Active(anon):     196404 kB
Inactive(anon):   281016 kB
Active(file):    2471488 kB
Inactive(file):  1962604 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2097148 kB
...

 

三、vmstat -s

# vmstat -s
      5946568 K total memory
       297644 K used memory
      2652552 K active memory
      2243688 K inactive memory
       263648 K free memory
            0 K buffer memory
      5385276 K swap cache
      2097148 K total swap
        29156 K used swap
      2067992 K free swap
     12862316 non-nice user cpu ticks
       106196 nice user cpu ticks
      3709876 system cpu ticks
    997861015 idle cpu ticks
      1317075 IO-wait cpu ticks
...

 

四、top

# top
top - 09:53:16 up 39 days, 14:38,  1 user,  load average: 0.15, 0.11, 0.06
Tasks: 132 total,   1 running, 131 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.6 us,  0.2 sy,  0.0 ni, 97.8 id,  0.3 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem :  5946568 total,   256764 free,   304424 used,  5385380 buff/cache
KiB Swap:  2097148 total,  2067992 free,    29156 used.  4862232 avail Mem

 

五、htop 可以查看使用比率(推薦)

htop 非原生,要安裝,在epel包中。

# yum install htop
# htop

 

六、dmidecode -t 17 查看每一個slot的狀況

# dmidecode -t 17
# dmidecode 3.0 <== 非指令
Scanning /dev/mem for entry point.
SMBIOS 2.4 present.
Handle 0x00E3, DMI type 17, 27 bytes
Memory Device
    Array Handle: 0x00E2
    Error Information Handle: No Error
    Total Width: 32 bits
    Data Width: 32 bits
    Size: 4096 MB
    Form Factor: DIMM
    Set: None
    Locator: RAM slot #0 <== 記憶體slot
    Bank Locator: RAM slot #0
    Type: DRAM
    Type Detail: EDO
    Speed: Unknown
    Manufacturer: Not Specified
    Serial Number: Not Specified
    Asset Tag: Not Specified
    Part Number: Not Specified

 

參考資料

[1] https://www.binarytides.com/linux-command-check-memory-usage/