One .top Role of command
top The order is Linux Common performance analysis tools , It can display the resource usage of each process in the system in real time , Be similar to Windows Task manager . How to use it is described in detail below .top Is a dynamic display process , That is to say, the current status can be refreshed continuously by pressing the button of the user . If the command is executed in the foreground , It will have exclusive foreground , Until the user terminates the program . To be more precise ,top Command provides real-time status monitoring of system processors . It will be displayed in the system CPU most “ sensitive ” Task list for . The command can be pressed CPU Use . Sort tasks by memory usage and execution time ; And many features of this command can be set through interactive command or in personal customization file .
Displays information about the processes currently being executed by the system , Including process ID、 Memory usage 、CPU Occupancy rate, etc
Two .top Command related parameters
top [ Parameters ]
-b The batch
-c Show full command
-I Ignore failure process
-s Confidentiality mode
-S Cumulative mode
-i< Time > Set interval
-u< user name > Specify user name
-p< Process number > Specify process
-n< frequency > Number of cycles
3、 … and .top Use cases of commands
Statistics area :
The first five lines are the overall statistical information area of the current system . Let’s look at the specific meaning of each line of information .
first line , Task queue information , Same as uptime Command execution results , The specific parameters are as follows :
17:25:49 — Current system time
up 10 days, 22min— The system is already running 70 God 16 Hours 44 minute ( During this period, the system did not restart !)
1 users — The current is 2 Users log in to the system
load average: 0.00, 0.01, 0.05 — load average The next three numbers are 1 minute 、5 minute 、15 Minute load .
load average The data is every 5 Check the number of active processes per second , The value calculated according to the specific algorithm . If this number is divided by logic CPU The number of , Results higher than 5 It means that the system is overloaded .
The second line ,Tasks — Mission ( process ), The details are as follows :
System now shared 121 A process , Some of them are in operation 1 individual ,120 Sleeping (sleep),stoped There are 0 individual ,zombie state ( Corpse ) There are 0 individual .
The third line ,cpu State information , The specific attributes are as follows :
0.1%us — User space occupancy CPU Percent of .
0.0% sy — Kernel space footprint CPU Percent of .
0.0% ni — Change the priority of the process occupied CPU Percent of
99.9% id — Free CPU percentage
0.0% wa — IO Waiting for occupation CPU Percent of
0.0% hi — Hard interrupt (Hardware IRQ) Occupy CPU Percent of
0.0% si — Soft interrupt (Software Interrupts) Occupy CPU Percent of
remarks : ad locum CPU Usage ratio and windows Different concepts , You need to understand linux Knowledge of system user space and kernel space !
In the fourth row , Memory status , The details are as follows :
10074990k total — Total physical memory
815796k used — Total memory in use
4967136k free — Total free memory
4291968k buffers — Amount of memory cached
The fifth row ,swap Exchange partition information , The details are as follows :
4193276k total — Total exchange area
4193276k used — Total swap area used
0k free — k free
4772912k cached — Total number of swap buffers buffered
remarks :
Total memory in use in line 4 (used) It refers to the amount of memory controlled by the system kernel , Total free memory (free) It’s the number of cores that haven’t been under its control . Not all the memory included in kernel management is in use , It also includes memory used in the past that can be reused now , The kernel does not return the reusable memory to the free In the middle , So in linux On free Less and less memory , But don’t worry about it .
If you are used to calculating the available memory , Here is an approximate formula : On the fourth line free + On the fourth line buffers + The fifth row cached, According to this formula, the available memory of this server
For memory monitoring , stay top We need to monitor the fifth line all the time swap Swap partitioned used, If this value is constantly changing , It indicates that the kernel is in continuous memory and swap Data exchange of , It’s really out of memory .
Below line 7 : Processes ( Mission ) Status monitoring of , The project line information is described as follows :
PID — process id
USER — Process owner
PR — Process priority
NI — nice value . Negative value indicates high priority , A positive value indicates a low priority
VIRT — Total virtual memory used by the process , Company kb.VIRT=SWAP+RES
RES — Used by process 、 Physical memory size not swapped out , Company kb.RES=CODE+DATA
SHR — Shared memory size , Company kb
S — Process status .D= Uninterrupted sleep R= function S= sleep T= track / stop it Z= Zombie process
%CPU — Last updated to now CPU Percentage of time used
%MEM — Percentage of physical memory used by the process
TIME+ — Used by process CPU Total time , Company 1/100 second
COMMAND — Process name ( Command name / Command line )
Four . Relevant command
Show Full command
command :
top -c
top -h
5、 … and . Troubleshooting of thread deadlock command
https://www.jianshu.com/p/8d5782bc596e