w command:
w View the debt value of the system
Mainly focus on the average process of cpu 1 minute 5 minutes 15 minutes (whether the load is high)
load average :0.03 0.02 0.05 = system 1 minute load value system 5 minute debt value system 15 minute load value
cat /proc/cpuifo Check the cpu The first line indicates how many logical cpus there are. The logical cpu is related to the system's load value per minute. If there is only 1 logical cpu, then the best load value of the system is 1. If there are 8 logical cpus, then The system load does not exceed 8 per minute, and so on. 5 minutes, 15 minutes the same principle. Mainly focus on process load in 1 minute.
vmstat command:
When the vmstat system load value is too high, you can view some system data
Usage: vmstat 1 5 vmstat = command 1 = collect data every few seconds 5 = end after collecting data several times
r: how many processes are running in the cpu, or waiting processes are queued behind
b: other processes that are blocked, processes waiting in
swpd: If the number is 0, the memory is sufficient. If the number keeps changing frequently, the memory is not enough. You need to increase the memory or migrate the task to another machine to run.
si: The size of the virtual memory read from the disk per second. If this value is greater than 0, it means that the physical memory is not enough
so: The size of virtual memory written to disk per second, if this value is greater than 0
bi: read data in the disk, if the value is large, then the b column will increase
bo: The number of blocks sent by the block device per second. For example, when we read a file, bo must be greater than 0. Bi and bo are generally close to 0, otherwise IO is too frequent and needs to be adjusted
us: The percentage of resources occupied by the user, the value will not exceed 100%
sy: resources occupied by the system
id: idle, waiting resource
(us+sy+id = 100%)
wa: the percentage of waiting cpu, if the value is large, it means that the cpu is not enough
Through the above data, you can determine where the bottleneck of the system lies: whether the cpu is enough, whether the memory is enough, whether the disk io is too large to read and write
procs=cpu memory=memory io=disk read and write
top command:
- top - 22:23:54 [current system time],
- 2 user[2 users currently logged in],
- load average: 0.00, 0.01, 0.05[system load, that is, the average length of the task queue]
- Tasks: 98 total[total number of processes],
- 1 running[number of running processes],
- 97 sleeping[Number of processes sleeping],
- 0 stopped[number of processes stopped],
- 0 zombie[Number of frozen processes (zombie processes)],
- Cpu(s): 0.0us[% of CPU occupied by user space],
- KiB Mem: 1867048k total[total physical memory], 1549988 free[total free memory], 137612k used[total physical memory used],
- KiB Swap:Swap: 4194300k total[total swap area], 4194300k free[total free swap area], 0k used[swap partition used]
- The default sorting is CPU sorting. If you want to use memory sorting, you can press uppercase M to view it. If you want to change back to CPU sorting, you can press uppercase P.
- M memory sort
P CPU sort
Press the number ' 1 ' to view the specified cpu, and the letter q can exit the top
top -c can view the specified command and absolute path of the process
top -bn1 can statically display a comprehensive process (usually used to write scripts)
If you want to close a process, you can use q plus PID to close the process directly
sar command:
yum install -y sysstat install sar command
ls /var/log/sa/ You can view a packet of sar's own existence
sar -n DEV 1 2 View network card traffic 1 in front of it = 1 collection per second and 2 in the back = stop after two collections (the latter numbers can be omitted)
IFACE:LAN Interface=(NIC)
rxpck/s: packets received per second
txpck/s: packets sent per second
rxkbyt/s: bytes received per second
txkbyt/s: bytes sent per second
rxcmp/s: Compressed packets received per second txcmp/s: Compressed packets sent per second rxmcst/s: Multicast packets received per second
rxpck/s = data packets received per second, the data packets received per second are generally within 1~10000, if it exceeds this data range, it must be considered whether to be attacked.
View historical data of cpu load
sar -q can directly view the current load and the effect of the w command is the same
sar -q -f /var/log/sa/sa13 can view historical load data
sa13 (sa13 can also be equal to other names) is a file under sar, the file address path: ls /var/log/sa/ inside
sar -b 1 5 View the read and write data of the disk 1 = collect data once per second 5 = stop after collecting 5 times
tps: Total I/O transfers per second to the physical device
rtps: The total amount of data read from the physical device per second
wtps: The total amount of data written to the physical device per second
bread/s: The amount of data read from the physical device per second, in blocks/s
bwrtn/s: The amount of data written to the physical device per second, in blocks/s
nload command (view network card traffic):
To install an installation package yum install -y epel-release and then install nload
nload press Enter to view the network card information directly ' q ' to exit the interface
Incoming = incoming bandwidth to the server
Outgoing = outgoing bandwidth from the server