Linux 系统监控、诊断工具之 top命令详解

(1)系统、任务统计信息:
(2)进程、 cpu 统计信息:
(3)最后两行为内存信息:
3.1  实际的程序可用内存数怎么算呢?
3.2  程序已用内存数又怎么算呢?
3.3  怎么判断系统是否内存不足呢?
3.4  buffer 与cache 的区别
(4)进程信息区:
(5)查看指定列
5.1 f 键选择显示内容
5.2 o 键改变显示顺序
5.3 F/O 键将进程按列排序
(6)常用交互命令
(7)最后的技能:top 命令小技巧
(8)Refer:

接触 Linux 的人对于 top 命令可能不会陌生(不同系统名字可能不一样,如 IBM 的 aix 中叫 topas ),它的作用主要用来监控系统实时负载率、进程的资源占用率及其它各项系统状态属性是否正常。

下面我们先来看张 top 截图:

Linux 系统监控、诊断工具之 top命令详解

实用的top命令

为什么 Linux 的 htop 命令完胜 top 命令

Ubuntu下最强大的进程监视器htop使用

CentOS 6.5中安装htop进程管理监控工具

top命令引起系统负载升高 

(1)系统、任务统计信息:

前 8 行是系统整体的统计信息。第 1 行是任务队列信息,同 uptime 命令的执行结果。其内容如下:

01:06:48   当前时间  
up 1:22   系统运行时间,格式为时:分  
1 user   当前登录用户数  
load average: 0.06, 0.60, 0.48   系统负载,即任务队列的平均长度。

三个数值分别为 1分钟、5分钟、15分钟前到现在的平均值。

注意:这三个值可以用来判定系统是否负载过高——如果值

持续大于系统 cpu 个数,就需要优化你的程序或者架构了。

 
(2)进程、 cpu 统计信息:

第 2~6 行为进程和CPU的信息。当有多个CPU时,这些内容可能会超过两行。内容如下:

Tasks: 29 total   进程总数  
1 running   正在运行的进程数  
28 sleeping   睡眠的进程数  
0 stopped   停止的进程数  
0 zombie   僵尸进程数  
Cpu(s): 0.3% us   用户空间占用CPU百分比  
1.0% sy   内核空间占用CPU百分比  
0.0% ni   用户进程空间内改变过优先级的进程占用CPU百分比  
98.7% id   空闲CPU百分比  
0.0% wa   等待输入输出的CPU时间百分比  
0.0% hi   Hardware IRQ  
0.0% si   Software IRQ  

注:

(1)IRQ: IRQ全称为Interrupt Request,即是“中断请求”的意思。

(2)st(Steal Time):Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor. It's only relevant in virtualized environments. It represents time when the real CPU was not available to the current virtual machine - it was "stolen" from that VM by the hypervisor (either to run another VM, or for its own needs).

So, relatively speaking, what does this mean? A high steal percentage may mean that you may be outgrowing your virtual machine with your hosting company. Other virtual machines may have a larger slice of the CPU’s time and you may need to ask for an upgrade in order to compete. Also, a high steal percentage may mean that your hosting company is overselling virtual machines on your particular server. If you upgrade your virtual machine and your steal percentage doesn’t drop, you may want to seek another provider. A low steal percentage can mean that your applications are working well with your current virtual machine. Since your VM is not wrestling with other VM’s constantly for CPU time, your VM will be more responsive. This may also suggest that your hosting provider is underselling their servers, which is definitely a good thing.0.0% sisi(Software Interrupts) (3)最后两行为内存信息:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/17148.html