Linux-exposed people may not be unfamiliar with the top command (different system names may differ, such as IBM's Aix called Topas), and its role is primarily to monitor the system's real-time load rate, process resource utilization, and other System State properties.
Let's take a look at top of the table first:
(1) System and task statistic information:
The first 8 lines are the statistical information of the system as a whole. Line 1th is the task queue information, with the result of the execution 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 Current number of users logged on
Load average:0.06, 0.60, 0.48 system payload, 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.
Note: These three values can be used to determine if the system is under load--If a value
continues to be larger than the number of system CPUs, you need to optimize your program or architecture.
(2) process, CPU statistic information:
The 2nd to 6th 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 process totals
1 running number of running processes
Sleeping The number of sleep processes
0 number of processes stopped stopped
0 Zombie number of zombie processes
CPU (s): 0.3% US user space consumes CPU percentage
1.0% sy core space CPU percent occupied
0.0% CPU Percentage of processes that have changed priority within NI user process space
98.7% ID Idle CPU percent
0.0% wa wait for the input output CPU time percentage
0.0% hi Hardware IRQ
0.0% si software IRQ
Note:
(1) IRQ:IRQ is all called the interrupt request, which means "interrupt requests".
(2) St (Steal Time): Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicin G another virtual processor. It ' s only relevant in virtualized environments. It represents time when the real CPU is not available to the current virtual machine-it is "stolen" from this VM by th e hypervisor (either to run another VMS, or for its own needs).
So, relatively speaking, what's does this mean? A High steal percentage may mean so you may be outgrowing your Vsan with your hosting company. Other virtual machines could have a larger slice of the CPU's time and you could need to ask for a upgrade in order to Compet E. Also, a high steal percentage could mean that your hosting company are overselling virtual machines on your particular SER Ver. If you upgrade your Vsan and your steal percentage doesn ' t drop, you may be want to seek another provider. A low steal percentage can mean that your applications is working well with your current virtual machine. Since your VMS are not wrestling with other VMs ' s constantly for CPU time, your VM would be more responsive. This could also suggest that your hosting provider was underselling their servers, which is definitely a good thing.0.0% Sisi (software interrupts)
(3) Last two behavior memory information:
mem:191272k Total physical memory
Total physical memory used by 173656k used
17616k free Memory Total
The amount of memory that 22052k buffers uses as the kernel cache
Total swap area of swap:192772k
Total swap area used by 0k used
192772k free Swap area total
123988k Cached buffers The total number of swap areas.
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.
PS: How to calculate available memory and used memory?
In addition to FREE-M, you can also look at top:
mem:255592k Total, 167568k used, 88024k free, 25068k buffers
swap:524280k Total, 0k used, 524280k free, 85724k cached
3.1 Actual program available memory how to calculate?
The answer Is:free + (buffers + cached)
88024k + (25068k + 85724k) = 198816k
3.2 The number of memory used in the program how to calculate it?
The answer is:used– (buffers + cached)
167568k– (25068k + 85724k) = 56776k
3.3 How to tell if the system is not enough memory?
If your swap used value is greater than 0, you can basically tell that you have experienced a memory bottleneck, either optimizing your code or adding memory.
3.4 The difference between buffer and cache
A buffer is something that have yet to being "written" to disk. A cache is something that have been "read" from the disk and stored for later using from the application point of view, buffers/cached is equal to available because buffer/ Cached is designed to improve the performance of file reads and writes, and buffer/cached is quickly recycled when applications need to use memory.
So from the application's point of view, available memory = System Free Memories + buffers + cached.
Buffers is the buffer size used to make a block device, and he only records the metadata of the filesystem and tracking in-flight pages.
Cached is used to buffer files.
That is to say: buffers is used to store, what content inside the directory, permissions and so on.
and cached directly to the memory of our open files, if you want to know if he is really effective, you can try, successively executed two times the command #man X, you can obviously feel that the second opening is much faster.
Experiment: Doing something on a machine with no application can be seen more clearly. Remember that the experiment can only be done once, if you want to do more please change a file name.
#free
#man X
#free
#man X
#free
You can compare the size of the buffers after the free.
Another experiment:
#free
#ls/dev
#free
You compare the size of two, of course, this buffers is increasing at any time, but you have the LS, the increase in speed will become faster, this is the difference between buffers/chached.
Because Linux uses your temporary unused memory as a file and data cache to improve system performance, when you need these memory, the system will automatically release (unlike Windows, even if you have a lot of free memory, he will have access to the disk pagefiles)
(4) Process Information area:
The details of each process are shown below the statistics area. Let's start by understanding the meaning of the columns.
Ordinal column name meaning
A PID Process ID
b PPID parent Process ID
C ruser Real user name
D UID Process owner's user ID
E username of user process Owner
Group name of the F group Process owner
The terminal name of the G TTY boot process. Processes that are not started from the terminal are displayed as?
H PR -Priority
I NI Nice value. Negative values indicate high priority, positive values indicate low priority
The last CPU used by J P is meaningful only in a multi-CPU environment
K %cpu CPU time consumption percentage last updated to current
The total CPU time, in seconds, used by the timing process
The total CPU time used by the M time+ process, in units 1/100 seconds
N The percentage of physical memory used by the%MEM process
o The total amount of virtual memory used by the VIRT process, in kilobytes. Virt=swap+res
The p Swap process uses the size of the virtual memory, which is swapped out, in kilobytes.
The size of the physical memory, in kilobytes, that the Q RES process uses and has not been swapped out. Res=code+data
R code executable code occupies the physical memory size, in kilobytes
The amount of physical memory that is used outside of the S data executable code (data segment + stack), in kilobytes
T SHR shared memory size, in kilobytes
U nflt page Error count
V NDRT The number of pages that have been modified in the last write to now.
W S process state.
d= non-disruptive sleep state
R= Run
S= Sleep
t= Tracking/Stopping
z= Zombie Process
x 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
(5) View the specified column
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:
5.1 F key to select display content
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.
5.2 O Key to change the display order
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.
5.3 f/o key to sort processes by column
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.
(6) Common interactive commands
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+l Erase and rewrite the screen.
H or? Display the help screen and give a brief summary of the commands.
K Terminates 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.
I ignore idle and zombie processes. This is a switch-type command.
Q quit the program.
R reschedule 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.
S switch to cumulative mode.
s changes 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 F Add or remove items from the current display.
O or O change the order in which items are displayed.
L Toggle Display Average load and start time information.
M toggles display memory information.
T toggles the display of process and CPU status information.
The C toggle Displays the command name and the full command line.
M sorts based on the size of the resident memory.
P is sorted according to the percentage size of CPU usage.
T is sorted by time/accumulated time.
W writes the current settings to the ~/.TOPRC file. This is the recommended way to write top configuration files.
(7) Last skill: Top command Tips
1. Enter uppercase P, the result is sorted by CPU consumption in descending order.
2. Enter capital M, and the results are sorted in descending order of memory consumption.
3. Press the number 1 to show the load of all CPU cores.
4, top-d 5 refresh every 5 seconds, default 1 seconds
5. Top-p 4360,4358 Monitor the specified process
6, Top-u JohnDoe ' U ' for real/Active/save/File system user name.
7, Top-u ' U ' as a valid user ID
8, Top-bn 1 displays all process information, Top-n 1 displays only one screen of information for pipeline calls
9. Top-m #show Memory Summary in megabytes not kilobytes
10, Top-p 25097-n 1-b #-B to avoid output control characters, the pipe call appears garbled
11, Top page: top-bn1 | Less
12, the enhanced version of Top:htop, a more powerful interactive process manager:
File:Htop.png
Linux system monitoring, diagnostic tools Top