Home >Web Front-end >JS Tutorial >Detailed explanation of top command and output results under Linux
The top command is a commonly used performance analysis tool under Linux. It can display the resource usage of each process in the system in real time. It is often used for server-side performance analysis. This article mainly explains the detailed explanation of the top command parameters and the explanation of the output results. I hope it can help everyone. .
top command description
$ top top - 16:07:37 up 241 days, 20:11, 1 user, load average: 0.96, 1.13, 1.25 Tasks: 231 total, 1 running, 230 sleeping, 0 stopped, 0 zombie Cpu(s): 12.7%us, 8.4%sy, 0.0%ni, 77.1%id, 0.0%wa, 0.0%hi, 1.8%si, 0.0%st Mem: 12196436k total, 12056552k used, 139884k free, 64564k buffers Swap: 2097144k total, 151016k used, 1946128k free, 3120236k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 18411 pplive 20 0 11.9g 7.8g 5372 S 220.2 67.1 16761:00 java 1875 pplive 20 0 3958m 127m 4564 S 4.6 1.1 12497:35 java 4 root 20 0 0 0 0 S 0.3 0.0 184:01.76 ksoftirqd/0 13 root 20 0 0 0 0 S 0.3 0.0 135:49.83 ksoftirqd/2 25 root 20 0 0 0 0 S 0.3 0.0 136:54.49 ksoftirqd/5
The result of the top command is divided into two parts:
Statistical information: The first five lines are the statistical information of the overall system;
Process information: The table-like area below the statistical information displays the detailed information of each process, which is refreshed every 5 seconds by default.
Statistical information description:
Line 1: Top task queue information (system running status and average load), the same as the uptime command result.
Paragraph 1: The current system time, for example: 16:07:37
Paragraph 2: System running time, the time before restarting. The longer the time, the more stable the system will be.
Format: up xx days, HH:MM
For example: 241 days, 20:11, means it has been running continuously for 241 days, 20 hours and 11 minutes
Paragraph 3: The number of currently logged in users, for example: 1 user , indicating that there is currently only one user logged in
Paragraph 4: System load, that is, the average length of the task queue, the three values respectively count the average system load in the last 1, 5, and 15 minutes
Average system load : In the case of a single-core CPU, 0.00 means no load, 1.00 means just full load, more than 1 side means overload, the ideal value is 0.7;
Multi-core CPU load: Number of CPU cores * ideal value 0.7 = ideal load, for example : The 4-core CPU load does not exceed 2.8, which means there is no high load.
Line 2: Tasks process related information
Paragraph 1: Total number of processes, for example: Tasks: 231 total, indicating a total of 231 processes running
Paragraph 2: Number of running processes, For example: 1 running,
Paragraph 3: Number of sleeping processes, for example: 230 sleeping,
Paragraph 4: Number of stopped processes, for example: 0 stopped,
Paragraph 5: Number of zombie processes, For example: 0 zombie
Line 3: Cpus CPU related information. If it is a multi-core CPU, press the number 1 to display the CPU information of each core. At this time, line 1 will be converted to the Cpu core number line, and the number 1 can be switched back and forth. .
Paragraph 1: us user space occupies the CPU percentage, for example: Cpu(s): 12.7%us,
Paragraph 2: sy kernel space occupies the CPU percentage, for example: 8.4%sy,
Paragraph 3 Section: ni The percentage of CPU occupied by processes that have changed priorities in the user process space, for example: 0.0% ni,
Section 4: id The percentage of idle CPU, for example: 77.1% id,
Section 5: wa Waiting The percentage of CPU time for input and output, for example: 0.0% wa,
Paragraph 6: hi The total time spent by the CPU serving hardware interrupts, for example: 0.0% hi,
Paragraph 7: si CPU serving soft interrupts The total time spent, for example: 1.8%si,
Paragraph 8: st Steal time The CPU time stolen by the virtual machine by the hypervisor (if the vm is currently under a hypervisor, the hypervisor actually also consumes part of the CPU processing Time)
Line 4: Mem memory related information (Mem: 12196436k total, 12056552k used, 139884k free, 64564k buffers)
Paragraph 1: Total physical memory, for example: Mem: 12196436k total ,
Paragraph 2: Total amount of physical memory used, for example: 12056552k used,
Paragraph 3: Total amount of free memory, for example: Mem: 139884k free,
Paragraph 4: Used as kernel cache The amount of memory, for example: 64564k buffers
Line 5: Swap swap partition related information (Swap: 2097144k total, 151016k used, 1946128k free, 3120236k cached)
Paragraph 1: Total swap area, For example: Swap: 2097144k total,
Paragraph 2: Total amount of swap area used, for example: 151016k used,
Paragraph 3: Total amount of free swap area, for example: 1946128k free,
Paragraph 4 : Total buffered swap area, 3120236k cached
Process information:
Press f in the top command to view the displayed column information, and press the corresponding letter to turn on/off the column. Capital letters indicate on. Lowercase letters indicate closed. The columns marked with * are the default columns.
A: PID = (Process Id) 进程Id;
E: USER = (User Name) 进程所有者的用户名;
H: PR = (Priority) 优先级
I: NI = (Nice value) nice值。负值表示高优先级,正值表示低优先级
O: VIRT = (Virtual Image (kb)) 进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES
Q: RES = (Resident size (kb)) 进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATA
T: SHR = (Shared Mem size (kb)) 共享内存大小,单位kb
W: S = (Process Status) 进程状态。D=不可中断的睡眠状态,R=运行,S=睡眠,T=跟踪/停止,Z=僵尸进程
K: %CPU = (CPU usage) 上次更新到现在的CPU时间占用百分比
N: %MEM = (Memory usage (RES)) 进程使用的物理内存百分比
M: TIME+ = (CPU Time, hundredths) 进程使用的CPU时间总计,单位1/100秒
b: PPID = (Parent Process Pid) 父进程Id
c: RUSER = (Real user name)
d: UID = (User Id) 进程所有者的用户id
f: GROUP = (Group Name) 进程所有者的组名
g: TTY = (Controlling Tty) 启动进程的终端名。不是从终端启动的进程则显示为 ?
j: P = (Last used cpu (SMP)) 最后使用的CPU,仅在多CPU环境下有意义
p: SWAP = (Swapped size (kb)) 进程使用的虚拟内存中,被换出的大小,单位kb
l: TIME = (CPU Time) 进程使用的CPU时间总计,单位秒
r: CODE = (Code size (kb)) 可执行代码占用的物理内存大小,单位kb
s: DATA = (Data+Stack size (kb)) 可执行代码以外的部分(数据段+栈)占用的物理内存大小,单位kb
u: nFLT = (Page Fault count) 页面错误次数
v: nDRT = (Dirty Pages count) 最后一次写入到现在,被修改过的页面数
y: WCHAN = (Sleeping in Function) 若该进程在睡眠,则显示睡眠中的系统函数名
z: Flags = (Task Flags
X: COMMAND = (Command name/line) 命令名/命令行
top命令选项
-b:以批处理模式操作;
-c:显示完整的治命令;
-d:屏幕刷新间隔时间;
-I:忽略失效过程;
-s:保密模式;
-S:累积模式;
-i<时间>:设置间隔时间;
-u<用户名>:指定用户名;
-p<进程号>:指定进程;
-n<次数>:循环显示的次数。
top命令交互
常用交互操作
基础操作
1:显示CPU详细信息,每核显示一行
d / s :修改刷新频率,单位为秒
h:可显示帮助界面
n:指定进程列表显示行数,默认为满屏行数
q:退出top
面板隐藏显示
l:隐藏/显示第1行负载信息;
t:隐藏/显示第2~3行CPU信息;
m:隐藏/显示第4~5行内存信息;
进程列表排序
M:根据驻留内存大小进行排序;
P:根据CPU使用百分比大小进行排序;
T:根据时间/累计时间进行排序;
详细交互指令:h / ? 可显示帮助界面,原始为英文版,简单翻译如下:
Help for Interactive Commands - procps version 3.2.8 Window 1:Def: Cumulative mode Off. System: Delay 3.0 secs; Secure mode Off. Z,B Global: 'Z' change color mappings; 'B' disable/enable bold Z:修改颜色配置;B:关闭/开启粗体 l,t,m Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info l:隐藏/显示第1行负载信息;t:隐藏/显示第2~3行CPU信息;m:隐藏/显示第4~5行内存信息; 1,I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode 1:单行/多行显示CPU信息;I:Irix/Solaris模式切换 f,o . Fields/Columns: 'f' add or remove; 'o' change display order f:列显示控制;o:列排序控制,按字母进行调整 F or O . Select sort field 选择排序列 <,> . Move sort field: '<' next col left; '>' next col right 上下移动内容 R,H . Toggle: 'R' normal/reverse sort; 'H' show threads R:内容排序;H:显示线程 c,i,S . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time c:COMMAND列命令名称与完整命令行路径切换;i:忽略闲置和僵死进程开关;S:累计模式切换 x,y . Toggle highlights: 'x' sort field; 'y' running tasks x:列排序;y:运行任务 z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y') z:颜色模式;b:粗体开关 仅适用于x,y模式中 u . Show specific user only 按用户进行过滤,当输入错误可按Ctrl + Backspace进行删除 n or # . Set maximum tasks displayed 设置进程最大显示条数 k,r Manipulate tasks: 'k' kill; 'r' renice k:终止一个进程;r:重新设置一个进程的优先级别 d or s Set update interval 改变两次刷新之间的延迟时间(单位为s),如果有小数,就换算成ms。输入0值则系统将不断刷新,默认值是5s; W Write configuration file 将当前设置写入~/.toprc文件中 q Quit 退出 ( commands shown with '.' require a visible task display window ) 注意:带.的命令需要一个可见的任务显示窗口
相关推荐:
The above is the detailed content of Detailed explanation of top command and output results under Linux. For more information, please follow other related articles on the PHP Chinese website!