Detailed Linux top command (Centos7.5)

Detailed explanation of Linux top command

Preface

In the daily development, operation and maintenance process, there will always be system cpu, memory and other resources to check, so you should understand the top command under the linux system. This content is a memo for this, inquiries and learning, After all, the top command is a commonly used performance analysis tool under Linux, which can display the resource occupancy status of each process in the system in real time, similar to the task manager of Windows.

top command execution effect
Insert picture description here

Parameter interpretation

  1. Statistics Information Area
top - 15:16:04 up 46 days,  1:17,  1 user,  load average: 1.87, 1.97, 2.07
Tasks: 154 total,   2 running, 152 sleeping,   0 stopped,   0 zombie
%Cpu(s):100.0 us,  0.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1884124 total,    71904 free,  1707868 used,   104352 buff/cache
KiB Swap:  1679356 total,   400900 free,  1278456 used.    36672 avail Mem 
  • top - 15:16:04 up 46 days, 1:17, 1 user, load average: 1.87, 1.97, 2.07

Indicates the current system time,
system running time (initially at hour: minute), the
number of currently logged-in users, and 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.

  • Tasks: 154 total, 2 running, 152 sleeping, 0 stopped, 0 zombie

Indicates the total number of current processes, the number of
running processes, the number of
sleeping processes, the number of
stopped processes, and the number of
zombie processes (also called useless child processes, because the parent process is not finished, so it has not been released)

  • %Cpu(s):100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

The percentage of CPU occupied by user space, the percentage of CPU occupied by
kernel space, the percentage of CPU occupied by
processes in the user process space that have changed priority, the percentage of
idle CPU, the percentage
of CPU time waiting for input and output, the percentage of
hardware CPU interrupts, the percentage of
software interrupts, and the
virtual Percentage of machine occupancy

  • KiB Mem : 1884124 total, 68944 free, 1708872 used, 106308 buff/cache

The total amount
of physical memory, the total amount of physical memory used, the total amount of
free memory, the amount
of memory used as kernel cache

  • KiB Swap: 1679356 total, 407128 free, 1272228 used. 34512 avail Mem

The total amount
of swap area, the total amount of swap area used, the total amount of
free swap area, the total amount of
buffered swap area, the content in the memory is swapped out to the swap area, and then it is swapped into the memory, but the swap area is used 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, there is no need to write to the swap area.

  1. Process information area

The default display is as follows:

PID   USER   PR  NI    VIRT    RES    SHR  S %CPU %MEM     TIME+ COMMAND
695   root   20   0  314308   1544   1124  S  0.3  0.1  25:06.09 vmtoolsd
22610 root   20   0 2591468 484956      0  S  0.3 25.7   7:18.97 java
31202 root   20   0  157788   2328   1608  R  0.3  0.1   0:00.09 top
1     root   20   0  125248    956    412  S  0.0  0.1   1:47.86 systemd
2     root   20   0       0      0      0  S  0.0  0.0   0:00.14 kthreadd
3     root   20   0       0      0      0  S  0.0  0.0  57:44.16 ksoftirqd/0
7     root   rt   0       0      0      0  S  0.0  0.0   0:00.00 migration/0
8     root   20   0       0      0      0  S  0.0  0.0   0:00.00 rcu_bh
9     root   20   0       0      0      0  S  0.0  0.0  33:22.96 rcu_sched
10    root   rt   0       0      0      0  S  0.0  0.0   0:11.31 watchdog/0
  • PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

Process id,
user name,
priority, and
nice value of the process owner . Negative value means high priority, positive value means low priority, the
total amount of virtual memory used by the process, in kb. VIRT=SWAP+RES, the
size of physical memory used by the process that has not been swapped out, in kb. RES=CODE+DATA,
shared memory size, unit kb,
process status (D=uninterruptible sleep state, R=running, S=sleep, T=track/stop, Z=zombie process)
last updated to the current CPU The percentage of time occupied, the percentage
of physical memory
used by the process, the total CPU time used by the process, the unit is 1/100 second,
the command name/command line being executed

Command use

Use format: top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
display this command, command line execution under linux:top --help

Parameter interpretation

  • -h|-v: display help or version information
  • -b: execute top in batches
  • -c: The command line column displays the program name and parameters
  • -H: Set thread mode
  • -i: Only display active processes
  • -O: display the order of items
  • -S: switch to accumulation mode
  • -s: change the delay time between two refreshes
  • -d: Set the refresh interval at startup
  • -n + number: display the specified number of processes
  • -u|-U + username: display the process of the specified user
  • -p + pid: Only monitor the status of a certain process by specifying the monitoring process ID.
  • -o: sort sort, -o fieldname, specify the field to be sorted
  • -W: Write the current settings into the ~/.toprc file.

The above is welcome to correct and learn.

Guess you like

Origin blog.csdn.net/rao991207823/article/details/106142485