top - 02:46:29 up 27 days, 3:01, 1 user, load average: 0.39, 0.81, 0.85
Tasks: 201 total, 1 running, 130 sleeping, 0 stopped, 0 zombie
%Cpu0 : 5.3 us, 4.3 sy, 0.0 ni, 86.7 id, 0.0 wa, 0.0 hi, 0.0 si, 3.7 st
%Cpu1 : 4.3 us, 1.3 sy, 0.0 ni, 93.0 id, 0.0 wa, 0.0 hi, 0.3 si, 1.0 st
%Cpu2 : 2.3 us, 1.7 sy, 0.0 ni, 94.7 id, 0.3 wa, 0.0 hi, 0.0 si, 1.0 st
%Cpu3 : 11.5 us, 4.9 sy, 0.0 ni, 81.9 id, 0.3 wa, 0.0 hi, 0.3 si, 1.0 st
%Cpu4 : 5.7 us, 1.7 sy, 0.0 ni, 91.7 id, 0.0 wa, 0.0 hi, 0.0 si, 1.0 st
%Cpu5 : 0.0 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.3 st
%Cpu6 : 1.0 us, 0.3 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.7 st
%Cpu7 : 0.3 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 32577108 total, 2069636 free, 7760236 used, 22747236 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 21844280 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14013 apache 20 0 3531932 505932 446776 S 22.3 1.6 0:04.10 php-fpm
13982 apache 20 0 3526224 601752 548252 S 14.0 1.8 0:05.38 php-fpm
3131 mysql 20 0 13.7g 5.2g 11600 S 4.3 16.7 1729:14 mysqld
14014 apache 20 0 3165860 508212 458164 S 4.0 1.6 0:03.52 php-fpm
13585 apache 20 0 4944108 52548 8900 S 1.0 0.2 0:04.24 httpd
3515 root 20 0 129036 10460 2112 S 0.7 0.0 2:00.99 amazon-ssm-agen
12048 apache 20 0 4157676 54876 8940 S 0.3 0.2 0:08.49 httpd
1 root 20 0 117484 4864 3236 S 0.0 0.0 6:44.44 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:01.25 kthreadd
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
7 root 20 0 0 0 0 S 0.0 0.0 1:57.41 ksoftirqd/0
8 root 20 0 0 0 0 I 0.0 0.0 25:45.43 rcu_sched
( top 中按 F 可看到各縮寫字的原文)
PR : Priority
The scheduling priority of the task. If you see `rt' in this field, it means the task is running
under real time scheduling priority.
數字越低,越優先
NI : Nice Value
The nice value of the task. A negative nice value means higher priority, whereas a positive nice
value means lower priority. Zero in this field simply means priority will not be adjusted in deter‐
mining a task's dispatch-ability.
數字越低,越優先
VIRT : Virtual Memory Size (單位 KiB)
CentOS/Debian manpage 解釋
The total amount of virtual memory used by the task. It includes all code, data and shared libraries
plus pages that have been swapped out and pages that have been mapped but not used.
包括 process 的程式碼、 libraries 、資料data 以及在 swap中的資料
這個值會遠高於總記憶體
VIRT = RES + SWAP
RES : Resident Memory Size (單位 KiB)
CentOS manpage 解釋
The non-swapped physical memory a task is using.
Debian manpage 解釋
A subset of the virtual address space (VIRT) representing the non-swapped physical memory a
task is currently using. It is also the sum of the RSan, RSfd and RSsh fields.
It can include private anonymous pages, private pages mapped to files (including program
images and shared libraries) plus shared anonymous pages. All such memory is backed by the
swap file represented separately under SWAP.
實際記憶體使用量 (不含 swap)
RES = CODE + DATA
**各 process 的 RES 總和可能會「大於總記憶體」,因 shared libraries...
SHR : Shared Memory Size (單位 KiB)
CentOS manpage 解釋
The amount of shared memory available to a task, not all of which is typically resident.
It simply reflects memory that could be potentially shared with other processes.
Debian manpage 解釋
A subset of resident memory (RES) that may be used by other processes. It will include shared
anonymous pages and shared file-backed pages. It also includes private pages mapped to files
representing program images and shared libraries.
CPU 使用率的部分:
%Cpu0 : 5.3 us, 4.3 sy, 0.0 ni, 86.7 id, 0.0 wa, 0.0 hi, 0.0 si, 3.7 st
%Cpu1 : 4.3 us, 1.3 sy, 0.0 ni, 93.0 id, 0.0 wa, 0.0 hi, 0.3 si, 1.0 st
%Cpu2 : 2.3 us, 1.7 sy, 0.0 ni, 94.7 id, 0.3 wa, 0.0 hi, 0.0 si, 1.0 st
%Cpu3 : 11.5 us, 4.9 sy, 0.0 ni, 81.9 id, 0.3 wa, 0.0 hi, 0.3 si, 1.0 st
%Cpu4 : 5.7 us, 1.7 sy, 0.0 ni, 91.7 id, 0.0 wa, 0.0 hi, 0.0 si, 1.0 st
%Cpu5 : 0.0 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.3 st
%Cpu6 : 1.0 us, 0.3 sy, 0.0 ni, 98.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.7 st
%Cpu7 : 0.3 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
man page 的解釋:
us, user : time running un-niced user processes
sy, system : time running kernel processes
ni, nice : time running niced user processes 參考:Linux命令拾遗-top中的%nice是啥?
id, idle : CPU 閒置時間百分比 參考:Linux命令拾遗-%iowait指标代表了什么?
wa, IO-wait : time waiting for I/O completion
hi : time spent servicing hardware interrupts CPU 處理硬體中斷花費的時間% (如光碟機常常檢查是否有光碟片)
si : time spent servicing software interrupts CPU 處理軟體中斷花費的時間%
st , Steal Time : time stolen from this vm by the hypervisor 參考:谁偷走了我的云主机CPU时间:理解CPU Steal Time
這裡有詳細中文說明
https://qastack.cn/unix/18918/linux-top-command-what-are-us-sy-ni-id-wa-hi-si-and-st-for-cpu-usage
https://sodocumentation.net/zh-cn/operating-system/topic/9795/%E7%94%A8%E6%88%B7%E7%A9%BA%E9%97%B4%E5%92%8C%E5%86%85%E6%A0%B8%E7%A9%BA%E9%97%B4
KiB = kibibyte = 1024 bytes
MiB = mebibyte = 1024 KiB = 1,048,576 bytes
GiB = gibibyte = 1024 MiB = 1,073,741,824 bytes
TiB = tebibyte = 1024 GiB =
PiB = pebibyte = 1024 TiB = 1024 * 1024G
EiB = exbibyte = 1024 PiB = 1024 * 1024 * 1024G = 1024 * 1024T
http://orchome.com/298