Linux Special lecture | comprehensive monitoring tool-top

Source: Internet
Author: User
Tags superuser permission

Linux Special lecture | comprehensive monitoring tool-top

ChinaUnix http://woaimaidong.blog.chinaunix.net

The top command is an excellent Interactive performance monitoring tool, you can refresh and display the performance information including memory, CPU, process, user data, and running time at the specified time interval on a unified interface. The command format is as follows:

Top-hv |-bcHisS-d delay-n iterations-p pid [, pid...]
Common options are described as follows:
D. Specify the interval between two screen information refreshes. Of course, you can use the s interactive command to change it.
P only monitors the status of a process by specifying the monitoring process ID.
Q This option will refresh top without any delay. If the caller has the superuser permission, top runs with the highest possible priority.
S indicates the accumulative mode.
S enables the top command to run in safe mode. This removes the potential danger of interactive commands.
I so that top does not show any idle or dead processes.
C. display the entire command line, not just the command name.
Others
The following describes some interactive commands that can be used during top command execution. From the perspective of usage, mastering these commands is more important than mastering the options. These commands are single-letter. If the s option is used in the command line option, some of these commands may be blocked.
Ctrl + L erase and override the screen.
H or? The help screen is displayed, and some brief command summary is provided.
K. terminate a process. The system prompts the user to enter the PID of the process to be terminated and the signal to be sent to the process. Generally, 15 signals can be used to terminate a process. If the process cannot end normally, use signal 9 to forcibly end the process. The default value is signal 15. This command is blocked in security mode.
I ignore idle and dead processes. This is a switch-on command.
Q: exit the program.
R reschedules the priority of a process. The system prompts the user to enter the process PID to be changed and the process priority value to be set. Entering a positive value will lower the priority, and vice versa will give the process a higher priority. The default value is 10.
S switches to the accumulative mode.
S changes the delay time between two refreshes. The system prompts the user to enter a new time in seconds. If there is a decimal number, it is converted to m s. If the input value is 0, the system will be refreshed continuously. The default value is 5 s. It should be noted that if the setting is too small, it is likely to cause constant refresh, so it is too late to see the display, and the system load will increase significantly.
F or F: add or delete a project from the current display.
O or O changes the order of projects displayed.
L switching displays average load and startup time information.
The m switch displays the memory information.
T Switch displays the process and CPU status information.
C switch to display the command name and complete command line.
M is sorted Based on the resident memory size.
P is sorted by CPU usage percentage.
T is sorted by time/accumulative time.
W write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

The running result of the top command is as follows:

Top-19:42:13 up 180 days, 1 user, load average: 0.00, 0.01, 0.00
Tasks: 65 total, 2 running, 63 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: 505240 k total, 495180 k used, 10060 k free, 9268 k buffers
Swap: 0 k total, 0 k used, 0 k free, 131684 k cached

Pid user pr ni virt res shr s % CPU % mem time + COMMAND
1 root 15 0 10368 232 S 116 0.0. 80 init
2 root RT-5 0 0 S 0.0 0.0. 00 migration/0
3 root 34 19 0 0 S 0.0 0.0. 22 ksoftirqd/0
4 root RT-5 0 0 S 0.0 0.0. 00 watchdog/0
5 root 10-5 0 0 S 0.0 0.0. 30 events/0
6 root 10-5 0 0 S 0.0 0.0. 12 khelper
11 root 14-5 0 0 S 0.0 0.0. 98 kthread
15 root 10-5 0 0 S 0.0 0.0. 87 kblockd/0
16 root 20-5 0 0 S 0.0 0.0. 00 kacpid
60 root 12-5 0 0 S 0.0 0.0. 00 cqueue/0
63 root 10-5 0 0 S 0.0 0.0. 01 khubd
65 root 10-5 0 0 S 0.0 0.0. 06 kseriod
133 root 15 0 0 0 S 0.0 0.0. 00 khungtaskd
136 root 10-5 0 0 S 0.0 0.0 145: 17.30 kswapd0
137 root 12-5 0 0 S 0.0 0.0. 00 aio/0
273 root 11-5 0 0 S 0.0 0.0. 00 kpsmoused
285 root 10-5 0 0 0 S 0.0 0: 00. 01 xenwatch
286 root 10-5 0 0 0 S 0.0 0: 00. 01 xenbus
305 root 19-5 0 0 S 0.0 0.0. 00 ata/0

Statistical information area

The first five lines are the overall statistics of the system. The first line is the task queue information, which is the same as the execution result of the uptime command. The content is as follows:

01:06:48 Current Time
Up :22 System running time, in the format of minutes
1 user Current Login User count
Load average: 0.06, 0.60, 0.48 System load, that is, the average length of the task queue.
The three values are the average values from 1 minute, 5 minutes, and 15 minutes ago to the present.

Second and Third, information about the process and CPU. When multiple CPUs exist, the content may exceed two rows. The content is as follows:

Tasks: 29 total Process count
1 running Number of Running Processes
28 sleeping Number of sleep Processes
0 stopped Number of stopped Processes
0 zombie Number of zombie Processes
Cpu (s): 0.3% us CPU usage percentage of user space
1.0% sy CPU usage of kernel space
0.0% ni CPU usage percentage of processes that have changed their priorities in the process space
98.7% id Idle CPU percentage
0.0% wa Percentage of CPU time waiting for Input and Output
0.0% hi
0.0% si

Memory information of the last two behaviors. The content is as follows:

Mem: 505240 k total Total physical memory
495180 k used Total physical memory used
10060 k free Total idle memory
9268 k buffers Memory Used as kernel Cache
Swap: 192772 k total Total number of swap Areas
0 k used Total number of swap zones used
192772 k free Total number of idle swap Areas
131684 k cached The total number of buffer swap areas.
The content in the memory is swapped out to the swap zone and then into the memory, but the used swap zone has not been overwritten,
This value indicates the size of the SWAp zone where the content already exists in the memory.
When the corresponding memory is swapped out again, you do not have to write data to the swap zone.
Process Information area

The details of each process are displayed at the bottom of the statistics area. First, let's take a look at the meaning of each column.

Serial number Column name Description
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 the process owner
G TTY The terminal name of the startup process. Processes not started from the terminal are displayed?
H PR Priority
I NI Nice value. A negative value indicates a high priority, and a positive value indicates a low priority.
J P The last CPU used is only meaningful in multiple CPU environments.
K % CPU CPU usage from the last update to the present
L TIME Total CPU time used by the process, in seconds
M TIME + Total CPU time used by the process, in 1/100 seconds
N % MEM Percentage of physical memory used by the Process
O VIRT Total virtual memory used by the process, in kb. VIRT = SWAP + RES
P SWAP In the virtual memory used by the process, the swap size, in kb.
Q RES Physical memory used by the process, not swapped out, in kb. RES = CODE + DATA
R CODE Physical memory occupied by executable code, in kb
S DATA Physical memory occupied by parts other than executable code (Data Segment + stack), in kb
T SHR Size of shared memory, in kb
U NFLT Page error count
V MCM t The number of pages that have been modified since the last write to the present.
W S Process status.
D = uninterrupted sleep
R = run
S = sleep
T = tracking/stopping
Z = zombie Process
X COMMAND Command name/command line
Y WCHAN If the process is sleeping, the system function name displayed in sleep
Z Flags Task flag, refer to sched. h

By default, only important PID, USER, PR, NI, VIRT, RES, SHR, S, % CPU, % MEM, TIME +, and COMMAND columns are displayed. You can use the shortcut keys below to change the display content.

Change display content

You can use the f key to select the displayed content. Press f to display the column list. Press a-z to display or hide the corresponding column, and press enter to confirm.

Press the o key to change the Column Display sequence. A lower-case a-z can move the corresponding column to the right, while an upper-case A-Z can move the corresponding column to the left. Press enter.

Press the F or O key in upper case, and then press a-z to sort the process according to the corresponding column. The uppercase R key can reverse the current sorting.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.