Linux systems can view information such as CPU, memory, run time, swap partitions, thread of execution of the system through the top command.The top command is an effective way to find out what's wrong with your system.Not enough memory, not enough CPU processing power, too high IO reading and writing....
[root@foundation6 docker]# top
top - 21:31:26 up 15:16, 5 users, load average: 0.61, 0.82, 0.75
Tasks: 240 total, 2 running, 238 sleeping, 0 stopped, 0 zombie
%Cpu(s): 13.7 us, 1.5 sy, 0.0 ni, 84.2 id, 0.6 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 3775264 total, 250100 free, 2495300 used, 1029864 buff/cache
KiB Swap: 4064252 total, 2789544 free, 1274708 used. 527664 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16507 kiosk 20 0 1935284 201988 10816 R 46.8 5.4 68:11.92 plugin-con+
15773 kiosk 20 0 1784208 497692 40776 S 4.7 13.2 37:05.32 firefox
408 root 20 0 36940 4116 3920 S 3.0 0.1 4:51.67 systemd-jo+
3789 kiosk 20 0 747664 14124 4696 S 2.0 0.4 2:49.76 gnome-term+
2404 root 20 0 439488 106688 84580 S 1.7 2.8 16:08.35 Xorg
2662 kiosk 9 -11 700096 5232 3032 S 1.7 0.1 5:17.25 pulseaudio
21632 kiosk 20 0 812940 167440 30100 S 1.7 4.4 20:15.48 wps
2688 kiosk 20 0 2111764 218776 18580 S 1.3 5.8 20:25.33 gnome-shell
663 root 20 0 399976 3352 2984 S 1.0 0.1 0:46.92 rsyslogd
7349 qemu 20 0 1697464 956932 556 S 0.7 25.3 5:03.80 qemu-kvm
7803 qemu 20 0 1697460 708164 544 S 0.7 18.8 4:16.74 qemu-kvm
18 root 20 0 0 0 0 S 0.3 0.0 0:16.94 rcuos/0
19 root 20 0 0 0 0 S 0.3 0.0 0:18.43 rcuos/1
21 root 20 0 0 0 0 S 0.3 0.0 0:19.62 rcuos/3
671 root 20 0 207984 160 120 S 0.3 0.0 0:01.60 abrt-watch+
5676 root 20 0 0 0 0 S 0.3 0.0 0:00.28 kworker/u1+
1 root 20 0 189128 2900 1432 S 0.0 0.1 0:06.11 systemd
The first line of the top command:
top - 21:31:26 up 15:16, 5 users, load average: 0.61, 0.82, 0.75
Corresponds in turn: the current time of the system up system so far i run time, the number of users currently logged on to the system, the three numbers after load average represent the load of one minute, five minutes, and fifteen minutes, respectively.
Note: The load average data is the number of active processes that are checked every five seconds and then calculated according to a particular algorithm.If this number is divided by the number of logical CPU s, a result higher than 5 indicates that the system is overloaded.
top Second line of command:
Tasks: 240 total, 2 running, 238 sleeping, 0 stopped, 0 zombie
Tasks represent tasks (processes), 240 total represents 240 processes, of which 2 are running, 238 are dormant (suspended), stopped is stopped, and zombie is zombie is zero.
The third line of the top command, cpu status:
%Cpu(s): 13.7 us, 1.5 sy, 0.0 ni, 84.2 id, 0.6 wa, 0.0 hi, 0.0 si, 0.0 st
Correspond in turn: percentage of user space occupied by cpu, percentage of kernel space occupied by cpu, percentage of CPU occupied by processes that have changed priority, percentage of idle cpu, percentage of CPU occupied by IO waiting, percentage of CPU occupied by hard interrupt (Hardware IRQ), percentage of CPU occupied by soft interrupt - software
top command line 4, memory state:
KiB Mem : 3775264 total, 250100 free, 2495300 used, 1029864 buff/cache
Correspond in turn: total physical memory (3.7G), total free memory (2.5G), total in-use memory (2.4G), buffer memory
The total amount of memory in use in the fourth line refers to the number of memory currently controlled by the system's kernel, and the total amount of free memory refers to the number of memory that the kernel has not yet been brought under its control.Kernel-managed memory isn't necessarily in use, but also used memory that can now be reused. The kernel doesn't return this reusable memory to free, so free memory on linux will get smaller and smaller, but don't worry about it
top command line 5, swap swap partition:
KiB Swap: 4064252 total, 2789544 free, 1274708 used. 527664 avail Mem
Correspond in turn: total exchange area (4G), total free exchange area (2.7G), total used exchange area (1.2G), total available exchange area
For memory monitoring, we need to monitor the use of the swap swap partition on the fifth line all the time in top. If this value keeps changing, it means that the kernel is constantly swapping data between memory and swap, which is really not enough memory.
top command line 6 is empty
top command line 7, monitoring of processes:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
Correspond in turn:
PID - Process id
USER - Process Owner
PR - Process Priority
NI-nice value.Negative values indicate high priority and positive values indicate low priority
VIRT - The total amount of virtual memory used by the process in kb.VIRT=SWAP+RES
RES - The size of physical memory used by a process and not swapped out in kb.RES=CODE+DATA
SHR - Shared memory size in kb
S - Process state.D=Uninterrupted Sleep State R=Run S=Sleep T=Track/Stop Z=Zombie Process
%CPU - Percentage of CPU time consumed since last update
%MEM - Percentage of physical memory used by the process
TIME+ - Total CPU time used by a process in 1/100 seconds
COMMAND - Process name (command name/command line)