Memory
2.1 vmstat
vmstat统计虚拟内存使用情况
Usage:
vmstat [options] [delay [count]]
Options:
-a, --active active/inactive memory
-f, --forks number of forks since boot
-m, --slabs slabinfo
-n, --one-header do not redisplay header
-s, --stats event counter statistics
-d, --disk disk statistics
-D, --disk-sum summarize disk statistics
-p, --partition <dev> partition specific statistics
-S, --unit <char> define display unit ### 单位k(1000),K(1024),m(1000000),M(1048576) bytes
-w, --wide wide output
-t, --timestamp show timestamp
-h, --help display this help and exit
-V, --version output version information and exit
For more details see vmstat(8).
vmstat查看虚拟内存使用信息
vmstat查看disk、查看slab使用信息
2.2 PSI
Linux pressure stall information (PSI), added in Linux 4.20, includes statistics for memory saturation. These not only show if there is memory pressure, but how it is changing in the last five minutes.
# cat /proc/pressure/memory
some avg10=2.84 avg60=1.23 avg300=0.32 total=1468344
full avg10=1.85 avg60=0.66 avg300=0.16 total=702578
上表数据表明,300秒平均内,内存压力是0.32,近10秒内内存压力平均是2.84,表明压力在增加。这些平均值代表进程阻塞在内存memory上的时间百分比。
some一行表示某些进程(线程)受影响。full一行表示所有的可运行状态进程受影响。
2.3 swapon
swapon, swapoff - enable/disable devices and files for paging and swapping
swapon [options] [specialfile...]
swapoff [-va] [specialfile...]
root@ubuntu:test# swapon
NAME TYPE SIZE USED PRIO
/swapfile file 2G 0B -2
2.4 slabtop
The Linux slabtop(1) command prints kernel slab cache usage from the slab allocator.
Usage:
slabtop [options]
Options:
-d, --delay <secs> delay updates
-o, --once only display once, then exit
-s, --sort <char> specify sort criteria by character (see below)
-h, --help display this help and exit
-V, --version output version information and exit
The following are valid sort criteria:
a: sort by number of active objects
b: sort by objects per slab
c: sort by cache size
l: sort by number of slabs
v: sort by number of active slabs
n: sort by name
o: sort by number of objects (the default)
p: sort by pages per slab
s: sort by object size
u: sort by cache utilization
For more details see slabtop