The top command is an excellent interactive performance monitoring tool that refreshes the display of performance information including memory, CPU, process, user data, uptime, and so on, at a user-specified time interval, in a single, unified interface. Its command format is as follows:
TOP-HV | -bchiss-d delay-n iterations-p pid [, PID ...]
Common option descriptions are shown below
DSpecifies the time interval between each two screen information refresh. Of course the user can use the s interactive command to change it.
PMonitor only the state of a process by specifying the monitoring process ID.
QThis option will cause top to refresh without any delay. If the calling program has Superuser privileges, top will run at the highest possible priority.
SSpecify cumulative mode
sMake the top command run in Safe mode. This removes the potential danger of interactive commands.
ISo that top does not show any idle or zombie processes.
CDisplay the entire command line instead of just displaying the command name
other
The following are some of the interactive commands that you can use during the execution of the top command. From a point of view of use, mastering these commands is more important than mastering the options. These commands are single-letter, and if you use the S option in command-line options, some of these commands may be masked out.
ctrl+lErase and rewrite the screen.
h or?Display the help screen and give a brief summary of the commands.
kTerminates a process. The user will be prompted for the process PID to be terminated and what signal needs to be sent to the process. The normal termination process can use a 15 signal, and if not, use signal 9 to force end the process. The default value is signal 15. This command is masked in safe mode.
IIgnore idle and zombie processes. This is a switch-type command.
QExits the program.
RReschedule the priority level of a process. The user is prompted to enter the process PID that needs to be changed and the process priority value that needs to be set. Entering a positive value lowers the priority and, conversely, it gives the process a higher priority. The default value is 10.
SSwitch to cumulative mode.
sChange the delay time between two refreshes. The user will be prompted to enter a new time in S. If there are decimals, it is converted into M S. Enter a value of 0 and the system will refresh continuously, the default value is 5 S. It is important to note that if you set too small a time, it is likely to cause a constant refresh, so it is too late to see the display, and the system load will be greatly increased.
F or FAdd or remove items from the current display.
o or OChange the order in which items are displayed.
LToggles the display of average load and start time information.
mToggles display memory information.
TToggles the display of process and CPU status information.
CToggles the display of the command name and the full command line.
MSorts based on the size of the resident memory.
PSorts according to the percentage size of CPU usage.
TSort by Time/cumulative time.
WWrites the current settings to the ~/.TOPRC file. This is the recommended way to write top configuration files.
the results of the top command run as follows:
Top-19:42:13 up, 4:27, 1 user, load average:0.00, 0.01, 0.00
TASKS:65 Total, 2 running, sleeping, 0 stopped, 0 zombie
Cpu (s): 0.0%us, 0.0%sy, 0.0%ni, 99.7%id, 0.3%wa, 0.0%hi, 0.0%si, 0.0%st
mem:505240k Total, 495180k used, 10060k free, 9268k buffers
swap:0k Total, 0k used, 0k free, 131684k cached
PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
1 Root 0 10368 232 S 0.0 0.0 4:19.80 Init
2 root RT-5 0 0 0 S 0.0 0.0 0:00.00 migration/0
3 Root 0 0 0 S 0.0 0.0 0:01.22 ksoftirqd/0
4 root RT-5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
5 root 10-5 0 0 0 S 0.0 0.0 102:43.30 events/0
6 root 10-5 0 0 0 S 0.0 0.0 0:00.12 khelper
Root 14-5 0 0 0 S 0.0 0.0 3:42.98 kthread
Root 10-5 0 0 0 S 0.0 0.0 0:00.87 kblockd/0
Root 20-5 0 0 0 S 0.0 0.0 0:00.00 kacpid
Root 12-5 0 0 0 S 0.0 0.0 0:00.00 cqueue/0
Root 10-5 0 0 0 S 0.0 0.0 0:00.01 KHUBD
10-5 Root 0 0 0 S 0.0 0.0 0:00.06 kseriod
133 Root 0 0 0 0 S 0.0 0.0 0:00.00 KHUNGTASKD
136 Root 10-5 0 0 0 S 0.0 0.0 145:17.30 kswapd0
137 root 12-5 0 0 0 S 0.0 0.0 0:00.00 aio/0
273 Root 11-5 0 0 0 S 0.0 0.0 0:00.00 kpsmoused
285 root 10-5 0 0 0 S 0.0 0.0 0:00.01 Xenwatch
286 root 10-5 0 0 0 S 0.0 0.0 0:00.01 Xenbus
305 Root 19-5 0 0 0 S 0.0 0.0 0:00.00 ata/0
Statistical information Area
The first five elements 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. |
The second to third behavior process and CPU information. When there are multiple CPUs, the content may be more than two lines. The contents are 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 |
|
0.0% si |
|
The last two behavior memory information. The contents are as follows:
M em:505240k Total |
amount of physical memory |
495180k used |
Total amount of physical memory used |
10060k free |
Total idle memory |
9268k buffers |
amount of memory to use as the kernel cache |
swap:192772k total |
Swap area totals |
0k US Ed |
Total number of swap areas used |
192772k free |
Total idle swap area |
131684k cached |
buffer the total of swap areas. The contents of the memory are swapped out to the swap area and then swapped in to memory, but the used swap area has not been overwritten, and The value is the size of the swap area where the content already exists in memory . The corresponding memory is swapped out again without having to write to the swap area again. |
Process Information Area
The details of each process are shown below the statistics area. Let's start by understanding the meaning of the columns.
Serial number |
Column Name |
Meaning |
A |
Pid |
Process ID |
B |
PPID |
Parent Process ID |
C |
Ruser |
Real User Name |
D |
Uid |
User ID of the process owner |
E |
USER |
User name of the process owner |
F |
GROUP |
Group Name of Process owner |
G |
Tty |
The terminal name of the startup process. Processes that are not started from the terminal are displayed as? |
H |
PR |
Priority level |
I |
NI |
Nice value. Negative values indicate high priority, positive values indicate low priority |
J |
P |
Last CPU used, only meaningful in multi-CPU environment |
K |
%cpu |
CPU time consumption percentage last updated to current |
L |
Time |
Total CPU time used by the process, in seconds |
M |
time+ |
Total CPU time used by the process, Unit 1/100 sec |
N |
%MEM |
Percentage of physical memory used by the process |
O |
VIRT |
The total amount of virtual memory used by the process, in kilobytes. Virt=swap+res |
P |
SWAP |
The size, in kilobytes, of the virtual memory that the process is using, swapped out. |
Q |
Res |
The size, in kilobytes, of the physical memory that the process used and was not swapped out. Res=code+data |
R |
CODE |
The amount of physical memory The executable code occupies, in kilobytes |
S |
DATA |
The amount of physical memory that is used by parts other than executable code (data segment + stack), in kilobytes |
T |
Shr |
Shared memory size, in kilobytes |
U |
Nflt |
Number of page faults |
V |
Ndrt |
The number of pages that were modified the last time it was written to. |
W |
S |
Process state. D= non-interruptible sleep state R= run S= Sleep T= trace/Stop Z= Zombie Process |
X |
COMMAND |
Command name/command line |
Y |
Wchan |
If the process is sleeping, the system function name in sleep is displayed |
Z |
Flags |
Task Flag, reference sched.h |
By default, only the more important PID, USER, PR, NI, VIRT, RES, SHR, S,%cpu,%MEM, time+, and COMMAND columns are displayed. You can change the display by using the following shortcut keys.
Change what is displayed
The F key allows you to select what is displayed. 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 the lower case moves the corresponding column to the right, while the uppercase A-Z moves the corresponding column to the left. Finally, press ENTER to confirm.
Press the uppercase F or O key, and then press A-Z to sort the process by the appropriate column. The uppercase R Key can reverse the current sort.
This article is from the "efficient operation and Maintenance" blog, please make sure to keep this source http://76543211234567.blog.51cto.com/7961566/1599223
Linux Featured explaining | Integrated Monitoring Tools-TOP