有时候你会用top/htop
查看一下当前系统的负载,会用 free -m
查看下内存的容量,抑或 cat /proc/xxxx
查看详细的记录,但这些metrics总搞不太明白,查了一下,记载这里。
-
top
-
free -m
load
如图中显示:load average: 2.16, 2.22, 2.14
三个值:average: 1min,5min,15min
load 表示当前cpu的负载,以某一时刻为例,单cpu(逻辑核)上运行态进程数为1,等待队列里的就绪态进程数为2,则当前该cpu负载为:1+2=3;
但由于cpu上进程状态转换很快,load 便用了统计平均值。统计时间为过去的1min,5min,15min。
参考:Understanding system load and load averages
cpu
如图中所示:%Cpu(s): 13.2 us, 6.8 sy, 0.0 ni, 79.5 id, 0.3 wa, 0.0 hi, 0.2 si, 0.0 st
数据格式:百分比,表示占用cpu时间的百分比
- us: user 用户进程;
- sy: system 内核进程;
- ni: nice 一个可以用于设置运行优先级的程序;
- id: idle 空闲;
- wa: wait 等待I/O;
- hi: hardware interrupt 硬件中断;
- si: software interrupt 软件中断;
- st: steal
Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor.
详见
参考:Understanding CPU statistics
mem
如图所示:total used free shared buff/cache available
- total: 总的内存量(由于系统内核及其它占用导致少于实际物理内存量);
- used: 已经被占用的内存量;
- free: 处于完全 free 的内存量;与 buff/cache 相比
- buff/cache: 为disk block分配的读写缓冲区,可被其它程序利用;
buffer用于缓冲硬盘文件块的一些元数据,Cache则仅能缓冲数据
-
available: 处于可用状态的内存;
它们的关系实际是:total = used + free + buff/cache;free+buff/cache中包含了 available -
Swap: 属于硬盘空间,用于在mem不足时,进行交换;
参考:
-
https://serverfault.com/questions/377617/how-to-interpret-output-from-linux-top-command
-
http://www.linuxhowtos.org/System/Linux%20Memory%20Management.htm
更多内容可关注本人博客:老香椿(https://laoxiangchun.cn/)