Z: Color display
x: Show row sequence
Shift < and shift > Sort by other columns
C Displays the absolute path of the command
K Input Pidkill Process
U input User display process information for user
Q Exit Top command
Http://www.cnblogs.com/peida/archive/2012/12/24/2831353.html
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. Top is a dynamic display process where the current state can be refreshed continuously with the user key. If the command is executed in the foreground, it will monopolize the foreground until the user terminates the program. More accurately, the top command provides real-time status monitoring of the system's processor. It will display the most "sensitive" CPU in the system. Task List. This command can be used by CPU. Memory usage and execution time to sort tasks, and many of the features of the command can be set through interactive commands or in personal customization files.
1. Command format:
Top [parameters]
2. Command function:
Displays information about the processes currently being executed by the system, including process IDs, memory usage, CPU utilization, etc.
3. Command parameters:
-B Batch Processing
-C Displays the complete ruling command
-I ignores the failure process
-S Secret mode
-S cumulative mode
-i< time > Set time interval
-u< User name > Specify user name
-p< Process number > Specify process
-n< number of times > cycle display
4. Usage examples:
Example 1: Displaying process information
Command:
Top
Output:
[email protected] log]# toptop-14:06:23 up to Days, 16:44, 2 users, load average:1.25, 1.32, 1.35Tasks:206 Total, 1 running, 205 sleeping, 0 stopped, 0Zombiecpu (s):5.9%us, 3.4%sy, 0.0%ni, 90.4%id, 0.0%wa, 0.0%hi, 0.2%si, 0%stmem:32949016k Total, 14411180k used, 18537836k free, 169884k buffersswap:32764556k total, 0k used, 32764 556k free, 3612636k cached PID USER PR NI VIRT RES SHR S%CPU%MEM time+COMMAND28894 Root 0 1501m 405m 10m S 52.2 1.3 2,534:16Java18249 Root 0 3201m 1.9g 11m S 35.9 6.0 569:39.41Java2808 Root 0 3333m 1.0g 11m S 24.3 3.1 526:51.85Java25668 Root 0 3180m 704m 11m S 14.0 2.2 360:44.53Java574 Root 0 3168m 611m 10m S 12.6 1.9 556:59.63Java1599 Root 0 3237m 1.9g 11m S 12.3 6.2 262:01.14Java1008 Root 0 3147m 842m 10m S 0.3 2.6 4:31.08Java13823 Root 0 3031m 2.1g 10m S 0.3 6.8 176:57.34Java28218 Root 0 12760 1168 808 R 0.3 0.0 0:01.43Top29062 Root 0 1241m 227m 10m S 0.3 0.7 2:07.32Java1 root 0 10368 684 572 S 0.0 0.0 1:30.85Init2 root RT-5 0 0 0 S 0.0 0.0 0:01.01 migration/0 3 Root 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0 4 root RT-5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0 5 root RT-5 0 0 0 S 0.0 0.0 0:00.80 MIGRATION/1 6 Root 0 0 0 S 0.0 0.0 0:00.00 KSOFTIRQD/1 7 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/1 8 root RT-5 0 0 0 S 0.0 0.0 0:20.59 Migra TION/2 9 Root 0 0 0 S 0.0 0.0 0:0 0.09 KSOFTIRQD/2 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 watchdog/ 2 root RT-5 0 0 0 S 0.0 0.0 0:23.66 MIGRATION/3 Root 0 0 0 S 0.0 0.0 0:00.03 KSOFTIRQD/3 root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/3 root RT-5 0 0 0 S 0.0 0.0 0:20.29 MIGRATION/4 Root 34 0 0 0 S 0.0 0.0 0:00.07 KSOFTIRQD/4 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/4 Root RT-5 0 0 0 S 0.0 0.0 0:23.07 MIGRATION/5 Root 0 0 0 S 0.0 0.0 0:00.07 KSOFTIRQD/5 1 9 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/5 Root RT-5 0 0 0 S 0.0 0.0 0:17.16 MIGRATION/6 Root 0 0 0 S 0.0 0.0 0:00.05 KSOFTIRQD/6 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/6 Root RT-5 0 0 0 S 0.0 0.0 0:58.28 MIGRATION/7
Description
Statistical information Area:
The first five elements are the statistical information area of the current system situation as a whole. Let's look at the specific meaning of each line of information.
The first line, the task queue information, and the execution results of the uptime command, specify the following parameters:
14:06:23-Current system time
Up to 70 days, 16:44-the system has been running for 16 hours and 44 minutes (during which the system has not restarted the Yo!). )
2 users-currently has 2 users logged into the system
The three numbers behind the load average:1.15, 1.42, 1.44-load average are 1-minute, 5-minute, 15-minute loads respectively.
The load average data is the number of active processes that are checked every 5 seconds and then calculated by a particular algorithm. If this number is divided by the number of logical CPUs, the result above 5 indicates that the system is overloaded.
The second line, tasks-task (process), specific information is as follows:
The system now has 206 processes, of which there are 1 running, 205 in hibernation (sleep), 0 in the stoped state, and 0 in the zombie State (zombie).
The third line, CPU status information, the specific properties are described as follows:
5.9%us-the percentage of CPU occupied by the user space.
3.4% sy-The percentage of CPU consumed by the kernel space.
0.0% ni-The percentage of CPU that has changed the priority of the process
90.4% id-Idle CPU percentage
0.0% Wa-io waiting for CPU percentage
0.0% hi-Hard Interrupt (Hardware IRQ)% of CPU occupied
0.2% si-Soft Interrupt (software interrupts)% of CPU occupied
Note: In this case the CPU usage ratio differs from the Windows concept, and you need to understand the Linux system user space and kernel space knowledge!
Line four, the memory state, the specific information is as follows:
32949016k total-Total Physical memory (32GB)
14411180k used-Total Memory in use (14GB)
18537836k free-Total free memory (18GB)
169884k buffers-Cache Memory (169M)
Line five, swap swap partition information, specific information as follows:
32764556k total-Swap Area total (32GB)
Total swap area used by 0k used-(0K)
32764556k free-Total Idle swap area (32GB)
3612636k cached-Buffer Swap area total (3.6GB)
Note:
The total amount of memory in use in row four (used) refers to the amount of memory that is now controlled by the system kernel, and the total amount of free memory that the kernel has not included in its control range. The memory that is included in kernel management is not always in use, but also includes the memory that has been used in the past that can now be reused, and the kernel does not return these reusable memory to free, so there is less memory on Linux, but don't worry about it.
If you are accustomed to calculating the number of available memory, here is an approximate formula: The fourth line of Free + fourth row buffers + fifth row of cached, according to this formula this server's available memory: 18537836k +169884k +3612636k = 22GB or so.
For memory monitoring, in the top we have to monitor the fifth line swap partition used, if this value is constantly changing, indicating that the kernel is constantly in memory and swap data exchange, which is really not enough memory.
Line six, blank line.
Line seventh below: status monitoring of each process (task), the project column information is described as follows:
pid-Process ID
user-Process Owner
pr-Process Priority
The Ni-nice value. Negative values indicate high priority, positive values indicate low priority
The total amount of virtual memory used by the virt-process, in kilobytes. Virt=swap+res
The size, in kilobytes, of the physical memory used by the res-process and not swapped out. Res=code+data
shr-shared memory size, in kilobytes
S-process state. d= non-disruptive sleep status r= run s= sleep t= track/stop z= zombie Process
%cpu-percentage of CPU time that was last updated to current
Percentage of physical memory used by the%mem-process
Total CPU time used by the time+-process, Unit 1/100 sec
command-Process Name (command name/command line)
Other tips for use:
1. Multi-u multi-core CPU monitoring
In the top basic view, press the keypad number "1" to monitor the status of each logical CPU:
Observe that the server has 16 logical CPUs, which are actually 4 physical CPUs. Press the number key 1 again to return to the top basic view interface.
2. Highlight the current running process
Tap the keyboard "B" (Turn on/off the highlight effect) and the top view changes as follows:
We found that the "top" process with process ID 2570 was highlighted, and the top process was the only running state (runing) that was shown in the second row of the view, and you could turn off or turn on the highlight of the running process by tapping the "Y" key.
3. Process field Sorting
By default, when Top is reached, the processes are sorted according to CPU consumption, with the process ID 28894 of the Java process First (CPU 142%), and the process ID 574 Java process second (CPU occupied 16%).
Tap the keyboard "X" (The highlight effect on/off the row sequence), and the top view changes as follows:
As you can see, the top default sort column is "%cpu".
4. You can change the column to the right or left by using "SHIFT + >" or "Shift + <"
is to press SHIFT + > once, the view is now sorted by%mem.
Example 2: Show full command
Command:
Top-c
Output:
Description
Example 3: Displaying program information in batch mode
Command:
Top-b
Output:
Description
Example 4: Displaying program information in cumulative mode
Command:
Top-s
Output:
Description
Example 5: Set Information update times
Command:
Top-n 2
Output:
Description
Indicates update two times after the update display is terminated
Example 6: Set Information update time
Command:
Top-d 3
Output:
Description
Indicates an update period of 3 seconds
Example 7: Displaying the specified process information
Command:
Top-p 574
Output:
Description
5.top Interactive Commands
Some of the interactive commands that you can use during the top command execution. These commands are single-letter, and some of these commands may be masked if the S option is used on the command line.
H Display the help screen and give some brief command summary instructions
K Terminates a process.
I ignore idle and zombie processes. This is a switch-type command.
Q Exit Program
R reschedule a process's priority level
S Switch to cumulative mode
s change the delay time between two refreshes (in units of s), and if there are decimals, convert to M S. Enter 0 value and the system will refresh continuously, the default value is 5 s
F or F Add or remove items from the current display
O or O change the order in which items are displayed
L Toggle display of average load and start-up time information
M Toggle Display Memory Information
T toggle display of process and CPU status information
C Toggle Display command name and full command line
M sort based on resident memory size
P Sort by percentage of CPU usage
T Sort by Time/cumulative time
W writes the current settings to the ~/.TOPRC file
Top of Linux commands