----- vmstat linux command of Resource Management

First, the role and grammar:
Linux command to display the status of the virtual memory system can also report on the overall operation status of processes, memory, I / O systems.
vmstat [options] [delay [count]]
Two, vmstat The fields
======================================================
[root@smiletest /]# vmstat
procs ----------- memory- --------- --- swap- - ----- io- --- - system -- ------ cpu- ----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 3592 123600 127964 1229856 0 0 0 25 2 7 0 0 100 0 0
======================================================
1、procs
r: represents the running and waiting for CPU time slice number of processes (that is really how many processes assigned to CPU), if the value is greater than the number of long-term system CPU, indicating insufficient CPU, the need to increase CPU
b: represents the number of processes waiting for resources, such as are waiting for I / O or memory exchange.
2、memory
swpd: represents the total amount of memory to use exchange , namely the size of the virtual memory used (in KB), if greater than 0, indicating a lack of physical memory to your machine, if not the cause of memory leaks program, then you should upgrade the memory or the memory-intensive tasks migrate to other machines.
free: indicates when the front free physical memory
buff: represents baffers cached memory size, i.e. the buffer size, generally read and write device only needs to block buffer
Cache: represents the page cached memory size, cache size is generally buffered as a file system, frequently accessed files are cached, if the cache is very large value Description more cache files, if the bi io at this time is relatively small, documentation system efficiency is better
3、swap
si: data into the data rate (kb / s) swap is , if this value is greater than 0, indicating that not enough physical memory or a memory leak, and memory-intensive process're looking to get rid of.
SO : the rate of data leaving the swap (kb / s)
Note: The value si, so under normal circumstances are zero, if the value si, so the long-term is not zero, it indicates lack of system memory, the need to increase system memory
4, I
bi: from a block device to a data read speed of the system, i.e. the disk reading unit kb / s
bo: represents the total amount of written data block devices, i.e. write to disk, the unit kb / s
Note: If bi + bo of value is too large, and wa larger value, it means that the system disk IO bottleneck
5、system
in: indicates the number of the terminal observes a certain time interval per device
cs: indicates the number of context switches generated per second,
For example, we call the system function, it is necessary context switching, switching threads, but also a process context switch, the value to be as small as possible, too, to lower the number of threads or processes to be considered, such as the apache and nginx this kind of web server, we generally will be doing performance testing or even tens of thousands of concurrent concurrent test, select the web server process may have been reduced from a peak of processes or threads, pressure measurement, until cs to a relatively small value, this process and the number of threads is a more appropriate value. System call is, each call system function, our code will enter the kernel space, resulting in a context switch, this is a waste of resources, we should try to avoid frequent calls the system function. Context switch too many times that you wasted most of CPU context switching, resulting in less CPU time doing serious things, CPU is not fully utilized, it is not desirable.
note:
The larger of these two values, consumed by the more core CPU
6、CPU
us: that the user process consumes CPU time percentage, the higher the value us, indicating that the more CPU time consumed by user process, if more than 50% of long-term, you need to consider the optimization program or algorithm
sy: a system kernel process the percentage of CPU time consumed, us + sy in general should be less than 80%, if more than 80%, indicating that there may be a bottleneck CPU
id: indicates the percentage of time the CPU is in state space
wa: indicates the percentage of CPU time to wait for IP occupied, the higher the values wa, indicating I / O wait more serious, according to the experience value of wa 20%, if it exceeds 20%, indicating that I / O wait severe, causing I / O wait may be the cause of a large number of random read and write disk caused, it could be a disk bottleneck loans or monitor (mainly block operation) caused
In summary, if the evaluation CPU, we need to focus on the value of r column values ​​and CPU procs items wanted us, sy, wa column
Third, the use of practice
Vmstat tool is generally used by two numeric parameters to complete, the first parameter is the number of sampling time intervals, in seconds, the second parameter is the number of samples, such as:
[root@smiletest /]# vmstat 2 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 3592 124444 128008 1229888 0 0 0 25 2 7 0 0 100 0 0
2 represents two seconds each time the server acquisition state, 1 represents only collected once.

Guess you like

Origin www.cnblogs.com/--smile/p/11121524.html