Linux operation and Maintenance management
A W command to view the current system load
Use the following
[[email protected] ~]# w 15:15:19 up 2 min, 1 user, load average: 0.05, 0.08, 0.04USER TTY FROM [email protected] IDLE JCPU PCPU WHATroot pts/0 192.168.72.1 15:14 7.00s 0.08s 0.00s w
The first line starts from the left to show the following information: Time, System uptime, number of logged on users, average load.
The second line starts with all of the following lines, telling us which users are currently logged in, and where they are logged in, and so on. In fact, what we should be most concerned about in this information is the three values behind the ' Load average: ' In the first line.
The first value represents the average load value of the system within 1 minutes;
The second value represents the average load value of the system within 5 minutes;
The third value represents the average load value for a 15-minute system.
We focus on the first value, which represents the number of CPU active processes in a unit time period. Of course, the larger the value, the greater the pressure on your server. in general, this value as long as the number of servers does not have a relationship, if the number of servers CPU is 8, then this value if less than 8, the current server is no pressure, otherwise it will pay attention to.
- View the number of CPU cores, Cat/proc/cpuinfo
[[email protected] ~]# cat /proc/cpuinfo
The processor count here starts at 0, which means that a display is 0 and two shows 1.
[[email protected] ~]# uptime 15:44:37 up 32 min, 1 user, load average: 0.00, 0.01, 0.05
To see how many CPUs the current system has, we can use this command:
Grep-c ' Processor '/proc/cpuinfo
[[email protected] ~]# grep -c ‘processor‘ /proc/cpuinfo2
Two-use Vmstat command to monitor the status of the system
Use the following:
The results of the Vmstat command print are divided into 6 parts: procs, memory, swap, IO, system, CPU. Please focus on the columns R, B, Si, so, bi, Bo, WA.
#vmstat //显示当前系统状态#vmstat 1 //每隔1秒输出一次运行状态,可以是其他任意数值,ctrl+c终止#vmstat 1 5 //每隔1秒输出一次运行状态,输出5次后终止
Procs displays information about the process:
- [] R: Indicates the number of processes running or waiting for CPU time slices. Description: Do not mistakenly think that waiting for the CPU time slice means that the process is not going, in fact, a CPU can only have one process at a time, the other processes can only queue waiting, at this time, these waiting for CPU resources of the process is still running state. If the value is longer than the number of server CPUs, the CPU resources are insufficient.
[] B (Block): Represents the number of processes waiting for a resource, which refers to I/O, memory, and so on. For example: when the disk reads and writes very frequently, writes the data to be very slow, at this time the CPU computation very quickly completes, but the process needs to write the result of the computation to the disk, so the process task is completed, then this process only then slowly waits, so this process is this B state. If the value is greater than 1 for a long time, you need to look at it.
Memory displays information about the RAM:
- [] swpd: Represents the amount of memory switched to the swap partition, in kilobytes.
- [] Free: Indicates the amount of memory currently idle in kilobytes.
- [] Buff: Represents the buffer size (to be written to disk) in kilobytes.
[] cache: Represents the buffer size (read from disk) in kilobytes.
Swap shows the swap of memory:
- [] si: Represents the amount of data written to memory by the swap, in kilobytes.
- [] so: Represents the amount of data written to the swap area by memory, in kilobytes.
IO Displays the usage of the disk:
- [] bi: Represents the amount of data read from a block device (read disk) in kilobytes.
[] Bo: Represents the amount of data written from a block device (write disk), in kilobytes.
The system displays the number of interrupts that occurred during the acquisition interval:
- [] in: Indicates the number of interrupts per second that were observed at a given time interval.
[] CS: Indicates the number of context switches produced per second.
CPU Displays CPU usage status:
- [] US: Displays the percentage of time that the user spends on the CPU.
- [] sy: Displays the percentage of time the system spends on the CPU.
- [] ID: Indicates the percentage of time that the CPU is idle.
Us+sy+id =100%
- [] wa: Represents the percentage of time that I/O waits for the CPU consumed.
- [] St: Indicates the percentage of the stolen CPU (typically 0, no concern)
Each of the parameters described above often focuses on the R column, column B, and WA columns, and the meaning of the three columns represented above is clearly stated above. The IO part of BI and Bo is also an object to refer to frequently. If the disk IO pressure is large, the values of these two columns will be higher. In addition, when the values of the SI, so two columns are relatively high, and are constantly changing, the memory is not enough, the data in memory is frequently exchanged in the swap partition, which often has a great impact on the system performance.
The top command displays the system resources that the process occupies.
Use the following:
The top command is used to dynamically monitor the system resources that the process takes, changing every 3 seconds. This command is characterized by putting the highest processes that occupy system resources (CPU, memory, disk IO, and so on) to the front. The top command prints a lot of information, including system load (Loadaverage), Number of processes (Tasks), CPU usage, memory usage, and swap partition usage.
- TOP-BN1 static display of all processes, representing the use of non-dynamic printing system resources, is commonly used in shell scripts.
- At the same time, you need to focus on the PID, you can kill the process with the kill command.
Four-SAR command to monitor system status
The SAR command is powerful and can monitor all of the system's resource states, such as the average load, network card traffic, disk status, memory usage, and so on. It differs from other system status monitoring tools in that it can print historical information that can display the system status information from 0 o'clock to the current time of the day. If your system does not have this command installed, please use the yum install-y sysstat command. The initial use of the SAR command will be an error, because the SAR tool has not generated the corresponding database files (monitoring will not be at all, because not to query the library file). Its database file is captured in the "/var/log/sa/" directory every 10 minutes, and the resulting file is saved in that directory.
1. View network card traffic Sar-n DEV
Use the following:
This command prints out the network card information that the party listens to and records every 10 minutes. The following parameters are of major concern.
IFACE:表示设备名称.rxpck/s:表示每秒进入收取的包的数量有多少。txpck/s:表示每秒发送出云的包的数量有多少。rxkB/s:表示每秒收取的数据量(单位为KB)。txkB/S:表示每秒发送的数据量
The rest of the columns do not need to be followed. If one day you manage the server drops is very serious, then you should look at this network card traffic is abnormal, if rxpck/s that column value is greater than 4000, or rxbyt/s that column greater than 5000000 is likely to be attacked, The normal server NIC traffic will not be higher than this, unless you are copying the data yourself. This is where you need to view network card traffic in real time
- Sar-n DEV 1 5//1-second output network card traffic status, 5 times after termination
- Use the-F option to view the network card traffic history for a given day, followed by the file name.
But/var/log/sa/saxx can only be saved for one months.
#sar -n DEV -f /var/log/sa/sa27
2. View historical Load Sar-q
This command helps us to check the load status of the server at some time in the past.
- Sar-b View the disk load, read and write situations.
- Sar-b 1 5//output disk load status Every 1 seconds, 5 stops
V. Use the nload command to view network card traffic
Although the SAR can see the network card traffic, but not intuitive, there is a better tool, that is nload.
Install Nload:
[[email protected] ~]# yum install -y nload
The ncoming is the traffic that enters the NIC.
Outgoing the traffic that goes out for the NIC.
The main concern curr that row of data, its units can also be dynamically adjusted automatically, very human.
Press Q to exit the interface.
- Supplementing Saxx and sarxx,xx as dates, Saxx is a binary file that can only be viewed with the sar-f command, and the SAR file takes a day to generate and can be viewed with the cat command
25.Linux System Management Tips-w,vmstat,top,sar,nload command