Tools for real-time monitoring or viewing system resource usage--top
The top command is a common performance analysis tool under Linux that shows the resource usage of individual processes in the system in real time, similar to the Task Manager for Windows.
Here is a detailed description of how it is used:
(Real-time Monitoring system Resource Usage graph)
The first five elements of the statistical information area are the statistical information of the whole system:
The first line is the task queue information, with the execution result of the uptime command. The contents are as follows:
01:06:48 |
Current time |
Up 1:22 |
System run time, format last: minutes |
1 user |
Number of currently logged on users |
Load average:0.06, 0.60, 0.48 |
System load, which is the average length of the task queue. The three values were 1 minutes, 5 minutes, and 15 minutes ago to the present average. |
Second to third behavior process and CPU information, when there are multiple CPUs, these contents may exceed two lines. The content is as follows:
tasks:29 Total |
Total number of processes |
1 Running |
Number of processes that are running |
Sleeping |
Number of processes for sleep |
0 stopped |
Number of processes stopped |
0 Zombie |
Number of zombie processes |
Cpu (s): 0.3% US |
Percentage of CPU occupied by user space |
1.0% Sy |
Percentage of CPU consumed by kernel space |
0.0% ni |
CPU percentage of processes that have changed priority in user process space |
98.7% ID |
Percentage of idle CPU |
0.0% WA |
Percentage of CPU time waiting for input and output |
0.0% hi |
The total amount of time that the CPU spends on hard interrupts |
0.0% Si, 0.0%st |
The amount of time the CPU spends on soft interrupts, steal |
Last two behavior memory information. The contents are as follows:
MEM:191272K Total |
Total Physical Memory |
173656k used |
Total amount of physical memory used |
17616k Free |
Total Free Memory |
22052k buffers |
Amount of memory to use as the kernel cache |
SWAP:192772K Total |
Total Swap Area |
0k used |
Total number of swap areas used |
192772k Free |
Total Free Swap Area |
123988k Cached |
The total amount of buffer swap area. The in-memory content is swapped out to the swap area and then swapped in to memory, but the used swap area has not been overwritten. This value is the size of the swap area where the content already exists in memory. When the corresponding memory is swapped out again, it is no longer necessary to write to the swap area. |
The details of each process are shown below the process information area statistics area.
Let's start by understanding the meaning of the columns:
Serial number |
Column Name |
Meaning |
1 |
Pid |
Process ID |
2 |
PPID |
Parent Process ID |
3 |
Ruser |
Real User Name |
4 |
Uid |
User ID of the process owner |
5 |
USER |
User name of the process owner |
6 |
GROUP |
Group Name of Process owner |
7 |
Tty |
The terminal name of the startup process. A process that is not started from the terminal is displayed as? |
8 |
PR |
Priority level |
9 |
NI |
Nice value. Negative values indicate high priority, positive number indicates low priority |
10 |
P |
Last CPU used, only meaningful in multi-CPU environment |
11 |
%cpu |
CPU time consumption percentage last updated to current |
12 |
Time |
Total CPU time used by the process, in seconds |
13 |
time+ |
Total CPU time used by the process, Unit 1/100 sec |
14 |
%MEM |
Percentage of physical memory used by the process |
15 |
VIRT |
Total amount of virtual memory used by the process, Unit kb,virt=swap+res |
16 |
SWAP |
The size, in kilobytes, of the virtual memory that the process is using, swapped out. |
17 |
Res |
The amount of physical memory not swapped out by the process, Unit Kb,res=code+data |
18 |
CODE |
The amount of physical memory the executable code occupies, in kilobytes |
19 |
DATA |
The amount of physical memory that is used by parts other than executable code (data segment + stack), in kilobytes |
20 |
Shr |
Shared memory size, in kilobytes |
21st |
Nflt |
Number of page faults |
22 |
Ndrt |
The number of pages that were modified the last time it was written to. |
23 |
S |
Process Status: D= non-interruptible sleep state R= run S= Sleep T= trace/Stop Z= Zombie Process |
24 |
COMMAND |
Command name/command line |
25 |
Wchan |
If the process is sleeping, the system function name in sleep is displayed |
26 |
Flags |
Task Flag, reference sched.h |
Only the more important PID, USER, PR, NI, VIRT, RES, SHR, S,%cpu,%MEM, time+, and COMMAND columns are displayed by default!
You can change the display by using the following shortcut keys:
Change the display by the F key to select what to display (press the F key to display a list of columns, press A-Z to show or hide the corresponding column, and then press ENTER to confirm)
Press the o key to change the order in which the columns are displayed (A-Z in lowercase can move the corresponding column to the right, while the uppercase A-Z can move the corresponding column to the left, and then press ENTER to determine)
Press the uppercase F or O key, and then press A-Z to sort the process by the appropriate column, while the uppercase R key reverses the current sort.
Article reference:
The Linux top command is detailed
http://bbs.linuxtone.org/forum.php?mod=viewthread&tid=1684&fromuid=34304