Linux top command

1. Concept

   The top command is often used to monitor the system status of Linux. It is a commonly used performance analysis tool and can display the resource occupancy of each process in the system in real time.

2. Grammar

   In the Linux output: top -help, the following situations occur:

 Usage : top [-d number] | top [-bnp]

Parameter description :

       -d: number represents the number of seconds, which represents the interval between updates of the page displayed by the top command. The default is 5 seconds.

       -b: Execute top in batches.

       -n: Used in conjunction with -b to indicate that the output of the top command needs to be performed several times.

       -p: Specify a specific pid process number for observation.

On the page displayed by the top command, you can also enter the following keys to perform the corresponding functions (note that the case is distinguished):

     ?: Display the commands that can be entered in top

     P: Display in order of CPU usage resources

     M: Display in order of memory usage resources

     N: display in pid order

     T: The time used by the process is cumulatively sorted and displayed

     k: Give a signal to a pid. Can be used to kill the process

     r: Re-customize a nice value (that is, priority) for a pid. q: Exit top (you can also exit top by using ctrl+c).

Three, example

1. Display process information: top

 Output information description :

1. The first line: top-14:21:47 up 7 days, 36 min, 2 users, load average: 0.00, 0.00, 0.00

The first line is the task queue information, the parameters are as follows:

content

meaning

14:21:47

Indicates the current time

up 7 days

The format of the system running time is: day

36 min

The format of the system running time is: minutes

2 users

Number of currently logged in users

load average: 0.00, 0.00, 0.00

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.

Note: load average: If this number is divided by the number of logical CPUs, when the result is higher than 5, it indicates that the system is overloaded. 

2. The second and third lines process and cpu information:

Tasks: 205 total, 1 running, 204 sleeping, 0 stopped, 0 zombie

Cpu (s): 0.3% us, 0.4% sy, 0.0% ni, 99.3% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st

content

meaning

205 total

Total number of processes

1 running

Number of running processes

204 sleeping

Number of sleeping processes

0 stopped

Number of stopped processes

0 zombie

Number of zombie processes

0.3%us

Percentage of CPU occupied by user space

0.4% sy

Percentage of CPU occupied by kernel space

0.0% ni

Percentage of CPU occupied by processes that have changed their priority in the user process space

99.3%id

Idle CPU percentage

0.0% wa

Percentage of CPU time waiting for input and output

0.0%hi

Hard interrupt (Hardware IRQ) occupies the percentage of CPU

0.0% yes

The percentage of CPU occupied by Software Interrupts

0.0%st

 

3. The fourth and fifth lines represent memory information:

Mem: 24564108k total, 24320760k used, 243348k free, 243188k buffers

Swap: 0k total, 0k used, 0k free, 17973516k cached

content

meaning

Mem: 24564108k total

Total physical memory

24320760k used

Total physical memory used

243348k free

Total amount of free memory

243188k buffers

Amount of memory used as kernel cache

Swap: 0k total

Total exchange area

0k used

Total exchange area used

0k free

Total amount of free swap area

17973516k cached

The total amount of buffered swap area.

3156100 avail Mem

Represents the amount of physical memory that can be used for the next allocation of the process

The total amount of buffered swap area mentioned above, here is an explanation. The so-called total amount of buffered swap area, that is, the content of the memory is swapped out to the swap area, and then swapped into the memory, but the used swap area If it has not been overwritten, the value is the size of the swap area where the content already exists in the memory. When the corresponding memory is swapped out again, it is unnecessary to write to the swap area. 

There is an approximate formula for calculating the amount of available memory: 

Free in the fourth line + buffers in the fourth line + cached in the fifth line

4. Process information

Column name

meaning

PID

Process id

PPID

Parent process id

RUSER

Real user name

UID

The user id of the process owner

USER

The user name of the process owner

GROUP

The group name of the process owner

TTY

The name of the terminal that started the process. Processes that are not started from the terminal are displayed as?

PR

priority

NI

nice value. Negative value indicates high priority, positive value indicates low priority

P

The last CPU used is only meaningful in a multi-CPU environment

%CPU

Percentage of CPU time from the last update to the present

TIME

The total CPU time used by the process, in seconds

TIME+

The total CPU time used by the process, in units of 1/100 second

%MEM

Percentage of physical memory used by the process

VIRT

The total amount of virtual memory used by the process, in kb. VIRT=SWAP+RES

SWAP

The size of the virtual memory used by the process to be swapped out, in kb

RES

The size of the physical memory used by the process that has not been swapped out, in kb. RES=CODE+DATA

CODE

The size of physical memory occupied by executable code, in kb

DATA

The size of physical memory occupied by parts other than executable code (data segment + stack), in kb

SHR

Shared memory size, unit kb

nFLT

Page faults

nDRT

The number of pages that have been modified since the last write.

S

Process status. D=uninterruptible sleep state R=running S=sleeping T=tracking/stopping Z=zombie process

COMMAND

Command name/command line

WCHAN

If the process is sleeping, display the name of the system function in sleep

Flags

Mission sign

 

 

Study address:

https://blog.csdn.net/yjclsx/article/details/81508455

 

Guess you like

Origin blog.csdn.net/baidu_28068985/article/details/108253346