查看swap使用情况
静态使用情况
free -m 查看内存、swap使用情况,单位为M,默认为K
[sage.wang@machine /proc/19843]$ free -m
total used free shared buffers cached
Mem: 3830 3700 130 0 42 691
-/+ buffers/cache: 2965 865
Swap: 4095 86 4009
历史使用情况
它能列出系统在各个时间的SWAP使用情况,使用sar命令。-S查看swap,-r查看内存使用情况
[sage.wang@machine ~]$ sar -S
Linux 2.6.32-358.23.2.el6.x86_64 (machine) 08/03/2018 _x86_64_ (4 CPU)
12:00:01 AM kbswpfree kbswpused %swpused kbswpcad %swpcad
12:10:01 AM 4105976 88320 2.11 25788 29.20
12:20:01 AM 4105976 88320 2.11 25788 29.20
12:30:01 AM 4105976 88320 2.11 25788 29.20
12:40:01 AM 4105976 88320 2.11 25788 29.20
[sage.wang@machine ~]$ sar -r
Linux 2.6.32-358.23.2.el6.x86_64 (machine) 08/03/2018 _x86_64_ (4 CPU)
12:00:01 AM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
12:10:01 AM 608928 3313760 84.48 5256 322840 3185080 39.24
12:20:01 AM 588864 3333824 84.99 6616 342316 3185072 39.24
12:30:01 AM 571256 3351432 85.44 7928 359152 3185080 39.24
12:40:01 AM 551160 3371528 85.95 9296 375488 3185084 39.24
实时大小
使用vmstat查看实时的数据,可以显示刷新频率,每隔1秒刷新一次:
[sage.wang@machine ~]$ vmstat 1
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 88248 118900 39112 727652 0 0 4 7 0 0 1 0 99 0 0
0 0 88248 118892 39112 727684 0 0 0 0 333 406 1 0 99 0 0
0 0 88248 118916 39112 727716 0 0 0 0 337 442 1 0 99 0 0
0 0 88248 118900 39120 727740 0 0 0 12 458 448 2 0 98 0 0
关注几个值
Memory
swpd: the amount of virtual memory used. 使用的虚拟内存大小
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (-a option)
active: the amount of active memory. (-a option)
Swap
si: Amount of memory swapped in from disk (/s). 磁盘->内存
so: Amount of memory swapped to disk (/s). 内存->磁盘
如果它们一直是零当然最好不过了,偶尔不为零也没啥,糟糕的是一直不为零。
1 |
|
sudo权限执行
https://huoding.com/2012/11/08/198
https://my.oschina.net/shyl/blog/477122
查看磁盘io