性能监控命令 | MEMORY

原文转自:https://www.jianshu.com/p/b54d0e424fd1

  • CPU
  • MEMORY
  • IO
  • NETWORK
  • LINUX进程内存占用查看方法

MEMORY


首先说说虚拟内存和物理内存:

虚拟内存就是采用硬盘来对物理内存进行扩展,将暂时不用的内存页写到硬盘上而腾出更多的物理内存让有需要的进程来用。当这些内存页需要用的时候在从硬盘读回内存。这一切对于用户来说是透明的。通常在Linux系统说,虚拟内存就是swap分区。在X86系统上虚拟内存被分为大小为4K的页。

每一个进程启动时都会向系统申请虚拟内存(VSZ),内核同意或者拒就请求。当程序真正用到内存时,系统就它映射到物理内存。RSS表示程序所占的物理内存的大小。用ps命令我们可以看到进程占用的VSZ和RSS。

| [work@jx-testing-ps1933.jx.baidu.com ~]$ ps -aux
USER PID %CPU %MEM VSZ [RSS](http://wiki.babel.baidu.com/twiki/bin/view/Com/Main/RSS) TTY STAT START TIME COMMAND
root 1 0.0 0.0 4752 544 ? S 2007 0:01 init [3] 
root 2 0.0 0.0 0 0 ? S 2007 0:22 [migration/0]
root 3 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 2007 0:20 [migration/1]
root 5 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/1]
root 6 0.0 0.0 0 0 ? S 2007 0:18 [migration/2]
root 7 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/2]
root 8 0.0 0.0 0 0 ? S 2007 0:12 [migration/3]
root 9 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/3] |

在命令行使用“Free”命令可以监控内存使用情况

| [work@tc-testing-ps5006.tc.baidu.com ~]$ free
total used free shared buffers cached
Mem: 8165816 8145048 20768 0 22920 5840236
-/+ buffers/cache: 2281892 5883924
Swap: 1024056 2316 1021740 |

输出的含义

在缺省的状态下,free命令以千字节(也就是1024字节为单位)来显示内存使用情况。可以使用—h参数以字节为单位显示内存使用情况,或者可以使用—m参数以兆字节为单位显示内存使用情况。还可以通过—s参数使用命令来不间断地监视内存使用情况。

使甩vmstat命令监视虚拟内存使用情况

| [work@jx-testing-ps1933.jx.baidu.com ~]$ ps -aux
USER PID %CPU %MEM VSZ [RSS](http://wiki.babel.baidu.com/twiki/bin/view/Com/Main/RSS) TTY STAT START TIME COMMAND
root 1 0.0 0.0 4752 544 ? S 2007 0:01 init [3] 
root 2 0.0 0.0 0 0 ? S 2007 0:22 [migration/0]
root 3 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 2007 0:20 [migration/1]
root 5 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/1]
root 6 0.0 0.0 0 0 ? S 2007 0:18 [migration/2]
root 7 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/2]
root 8 0.0 0.0 0 0 ? S 2007 0:12 [migration/3]
root 9 0.0 0.0 0 0 ? SN 2007 0:00 [ksoftirqd/3] |

与内存和IO相关的参数含义

猜你喜欢

转载自www.cnblogs.com/wyf0518/p/12104838.html
今日推荐