10.1 Using W to view system load
- The W command displays a list of users who have logged in to the system and displays the instructions that the user is executing. Execute this command to know who is currently logged in to the system, and which programs they are executing. Executing the W command individually displays all users, or you can specify a user name to display information about only one user.
- This command displays the information that the first line displays from the left to the following: the time when the command was run, the system run time, the number of logged on users, and the average load.
- The second line starts with all of the following lines, telling us what users are currently logged on to, and where they are logged in, and so on (Tty1 is a user who is logged in directly at the server terminal, and pts/0 is a user logged on through a remote connection). This should focus on the three values behind the ' Load average: ' In the first row.
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, and the third value represents the average load value of the 15-minute system. The meaning of this value is the number of CPU active processes per unit time period. 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.
- The uptime command can also view the system load, but only the system load-related information, not enough w command to Rich.
Note:
Cat/proc/cpuinfo-----> View CPU Cores
10.2 vmstat Command
- The meaning of the
- vmstat command is to display the virtual memory status ("Viryual memor Statics"), but it can report on the overall operational state of the system, such as process, memory, I/O, etc. The W command can see the load on the system as a whole, by looking at that value to know if there is any pressure on the current system, but where it is (CPU, memory, disk, etc.) it is impossible to judge. And through the vmstat can know exactly where there is pressure.
- The results of the
-
Vmstat command are divided into 6 parts: procs, memory, swap, IO, system, CPU. To focus on a few columns of R b si so bi bo .
1) procs Display process-related information
R: Indicates the number of processes running and waiting for CPU time slices, if the long-term is greater than the number of server CPUs, the CPU is not enough;
B: Represents the number of processes waiting for a resource. such as waiting for I/O, memory, and so on, if the value of this column is longer than 1, you need to pay attention to;
2) memory-related information
SWPD: Indicates the amount of memory switched to the swap partition;
Free : The amount of memory currently idle,
Buff: Buffer size (to be written to disk),
cache size, (read from disk),
3) Swap memory Exchange status
Si : The amount of data written to memory by the swap area;
So: The amount of data written to the swap by memory;
4) IO disk usage
Bi: The amount of data read from a block device (read disk);
Bo: The amount of data written from the block device (write disk);
5) The system displays the number of interrupts that occurred during the acquisition interval
In: Indicates the amount of device interrupts observed per second in a time interval;
CS: Indicates the number of context switches produced per second;
6) CPU displays CPU usage status
Us: Shows the percentage of CPU time spent by the user;
Sy: Displays the percentage of CPU time that the system spends;
ID: Indicates the percentage of time that the CPU is idle;
WA: Indicates the percentage of CPU time consumed by I/O waits;
St: Indicates the percentage of the stolen CPU (typically 0, without concern);
- When using Vmstat to view the state of a system, this is usually the way it looks:
[Email protected] ~]# Vmstat 1 5
Or:
[Email protected] ~]# Vmstat 1
The front indicates that the status is printed every second, printing 5 times, and the subsequent representation prints the state every 1 seconds, until we press Ctrl + C to end
10.3 Top Command
- The top command is used to dynamically monitor the system resources of the process, changing every 3 seconds, and the command is characterized by putting the highest processes that occupy system resources (CPU, memory, disk IO, and so on) to the front.
- Top should focus on the next half of the process using system resource details, focusing on%cpu,%MEM, command several, RES this is the amount of memory that the process occupies, and%MEM is the percentage of memory used.
- In the top state, press SHIFT + M to sort by memory usage size. Press "SHIFT + P" to sort by CPU usage size. Press the number ' 1 ' to list the usage status of each CPU.
The top-bn1 command represents the use of non-dynamic printing system resources and can be used in shell scripts. The only difference between the top command is that it outputs all the information at once rather than displaying it dynamically.
10.4 SAR Command
- The SAR command monitors all resource states of the system, 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 this command is not installed on the system, install it using 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 file (can wait about 10 minutes after the review will not error). Its database file is saved for one months by default in the "/var/log/sa/" directory.
- /var/log/sa/directory has similar sa22, Sar22 file (for illustrative purposes only, its 22 represents the date of 22nd), the difference is that the sa22 is a binary file, can only be viewed through the SAR command, and Sar22 can be viewed directly through the cat command.
1) View network card traffic Sar-n DEV
- Iface This column represents the device name, rxpck/s indicates the number of packets per second entered, TXPCK/S indicates the number of packets sent per second, rxkb/s represents the amount of data received per second, and txkb/s represents the amount of data sent per second. If one day you manage the server drops is very serious, then you should look at the network card traffic is abnormal . rxpck/s data volume Thousands of is relatively normal, tens of thousands of what is to be concerned about , Could have been attacked. The normal server NIC traffic is not so high unless you are copying the data yourself.
- You can also view the network card traffic history for a given day, using the-f option followed by the file name
Sar-f/var/log/sa/saxx
2) View historical load Sar-q
This command is used to view the load status of the server at some time in the past.
3) View disk read-write sar-a
This command is used to view disk read and write status.
10.5 nload Command
The nload command can also be used to dynamically view current network card traffic. The default nload command is not installed, and you need to run the yum instal epel-release install Epel-release package before running the yum instal nload install nload package.
Note:
nload command State, you can press Q to exit the nload command, press the left and RIGHT arrow keys to switch between different network cards to see the traffic situation of each network card.
2018-1-22 Linux Learning Notes