Top is a general performance analysis tool in Linux. It displays the system load, memory usage, and resource usage of each process in real time.
You can run the top command to show the overall situation of the system. Here is an example:
top - 17:51:14 up 69 days, 20:06, 2 users, load average: 71.81, 71.99, 63.46
Tasks: 1335 total, 1 running, 1334 sleeping, 0 stopped, 0 zombie
%Cpu(s): 34.9 us, 6.0 sy, 0.1 ni, 58.9 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 79180025+total, 53055686+free, 16692761+used, 94315792 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 61829075+avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
52974 hudson 20 0 160.1g 146.3g 73796 S 3893 19.4 1273:28 observer
33773 root 39 19 764452 104396 4408 S 8.2 0.0 14:55.16 bianque_daemon_
8951 root 20 0 3398328 16880 3284 S 4.3 0.0 1787:32 y_watchdog
11959 root 10 -10 247688 107284 4508 S 3.9 0.0 4226:29 AliYunDun
9321 root 20 0 577532 79328 4264 S 3.0 0.0 1074:18 asar
98164 hudson 20 0 159020 3560 1572 R 1.6 0.0 0:00.14 top
95053 root 16 -4 1936116 72160 4460 S 1.3 0.0 2699:29 h2o
97939 root 20 0 169488 24716 788 S 1.3 0.0 0:00.13 vsar
2529 root 20 0 162396 14628 2148 S 1.0 0.0 453:31.03 ob-sm-probe
51856 root 39 19 2215292 56896 4072 S 1.0 0.0 561:25.46 argusage
The first line shows the overall situation of the system.
Specifically, it shows the current system time, the length of system uptime (up) since the last boot, the number of online users, and the average CPU load information over the last 1 minute, 5 minutes, and 15 minutes, respectively.
The second line shows information about the tasks in the system.
Specifically, it shows the total number of tasks, the number of running processes, the number of sleeping processes, the number of stopped processes, and the number of zombie processes.
The third line shows the CPU state percentages on the server.
Specifically, it shows the percentages of time of running un-niced user processes (us), time of running kernel processes (sy), time of running niced user processes (ni), time spent on the kernel idle handler (id), time of waiting for I/O completion (wa), time spent on servicing hardware interrupts (hi), and time spent on servicing software interrupts (si).
To show or hide the information of each CPU, press 1. Here is an example:
%Cpu0 : 24.3 us, 0.0 sy, 0.7 ni, 75.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu1 : 30.7 us, 0.7 sy, 1.0 ni, 67.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu2 : 40.7 us, 0.3 sy, 0.0 ni, 58.6 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st %Cpu3 : 39.1 us, 0.3 sy, 0.0 ni, 60.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu4 : 46.5 us, 0.0 sy, 0.0 ni, 53.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu5 : 10.6 us, 0.3 sy, 0.3 ni, 88.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stThe fourth line shows information about the physical memory of the system.
Specifically, it shows the total physical memory (total), free physical memory (free), used physical memory (used), and cached physical memory (buff/cache) in kibibytes (KiB).
The fifth line shows the memory information in the swap file.
Specifically, it shows the total memory, free memory, used memory, and the estimated available memory in the swap file in KiB.
Starting from the seventh line, the information about each process is shown.
PID: the ID of a process.USER: the owner of a process.PR: the priority of a process. The smaller the value, the higher the priority.NI: the Nice value of a process. A positive value indicates a low priority, a negative value indicates a high priority, and the value0indicates that the priority of the process will not be adjusted.VIRT: the virtual memory used by a process.RES: the physical memory occupied by a process.SHR: the shared memory used by a process.S: the status of a process.Sindicates that the process is in hibernation.Rindicates that the process is running.Zindicates that the process is a zombie process.Nindicates that the priority value of the process is negative.%CPU: the CPU utilization of a process.%MEM: the percentage of physical memory used by the process in the total memory.TIME+: the total CPU time that is occupied by the process after it starts, which indicates the accumulated CPU occupied time.COMMAND: the name of the command used to start the process.
You may use the following options to obtain more information:
H: specifies to display the thread information. You can use this option to view the status of each OBServer thread.P: specifies to sort the processes by CPU utilization.M: specifies to sort the processes by memory usage.I: specifies to display ongoing processes.O: specifies to add a filter. For example,COMMAND:observerreturns only processes with the process nameobserver. It also applies to thread filtering, such asCOMMAND:RpcIO.