Linux performance monitoring top and Vmstat commands

Source: Internet
Author: User

Tools for monitoring---top

First line:
    1. 10:01:23 Current system time
    2. 126 days, 14:29 the system has been running for 126 day, 14 hours, 29 minutes (not restarted during this period)
    3. 2 users currently have 2 user login systems
    4. Load average:1.15, 1.42, 1.44

Load how does this thing understand, like a road, there are n lanes, if n process into the driveway, then just one person, one more car will not occupy the driveway, waiting for a car to empty the driveway. In the CPU can be understood as the CPU can be processed in parallel to the number of tasks, then is the "number of CPUs * Number of cores", if the CPU load = number of CPUs * The number of cores so that the CPU is just full load, a little more, there may be a problem, there is no task can be allocated timely processor, then the performance, Preferably less than the number of CPUs * Number of cores *0.7.

Load average is the load of the CPU, which contains information that is not CPU usage, but rather statistics on the sum of the number of processes that the CPU is processing and waiting for CPU processing over a period of time, that is, the CPU Usage Queue Length statistics

Load Average < CPU * Number of cores *0.7

This data is also available in the data you see with Vmstat, Vmstat view R (Load Average)

Second line:

Tasks task (process), the system now has a total of 183 processes, of which there are 1 in the running, 182 in hibernation (sleep), 0 in the stoped state, and 0 in the zombie State (zombie).

Third line: CPU status
    1. 6.7% the percentage of CPU occupied by US user space.
    2. 0.4% Sy Core Space consumes a percentage of the CPU.
    3. 0.0% NI changes the priority of the process to occupy a percentage of the CPU
    4. 92.9% ID Idle CPU percent
    5. 0.0% wa io waiting for CPU percentage
    6. 0.0% Hi Hard Interrupt (Hardware IRQ)% of CPU occupied
    7. 0.0% si soft interrupt (software interrupts)% of CPU occupied
Line four: Memory status
    1. 8306544k Total Physical Memory (8GB)
    2. 7775876k used total memory in use (7.7GB)
    3. 530668k free Memory Total (530M)
    4. 79236k Buffers Cache Memory (79M)
Line five: Swap swap partition
    1. ø2031608k Total swap area (2GB)
    2. Total swap area used by ø2556k used (2.5M)
    3. ø2029052k Free Swap Area total (2GB)
    4. ø4231276k cached buffer Swap area total (4GB)

The total amount of memory in use in row four (used) refers to the amount of memory that is now controlled by the system kernel, and the total amount of free memory that the kernel has not included in its control range. The memory that is included in kernel management is not always in use, but also includes memory that has been used in the past that can now be reused, and the kernel does not return these reusable memory to free, so there is less memory on Linux.

Approximate calculation formula for available memory = line Fourth of Free + fourth line buffers + fifth row of Cached

The used of the five-line swap partition, if this value is constantly changing, indicates that the kernel is constantly swapping memory and swap data, which is really not enough memory.

Line seventh below: status monitoring of each process (Task)
    1. PID Process ID
    2. USER Process Owner
    3. PR Process Priority
    4. NI nice value. Negative values indicate high priority, positive values indicate low priority
    5. The total amount of virtual memory used by the VIRT process, in kilobytes. Virt=swap+res
    6. The size, in kilobytes, of the physical memory used by the RES process and not swapped out. Res=code+data
    7. SHR shared memory size, in kilobytes
    8. S process state. d= non-disruptive sleep status r= run s= sleep t= track/stop z= zombie Process
    9. %cpu percentage of CPU time that was last updated to current
    10. Percentage of physical memory used by the%MEM process
    11. Total CPU time used by the time+ process, Unit 1/100 sec
    12. Command process name (commands name/command line)

  Press the keypad number 1 to monitor the status of each logical CPU

Tools for monitoring---vmstat

VMSTAT--CPU Related parameter Description:
    1. R, the number of threads that can run the queue, all of which are operational, except that the CPU is temporarily unavailable;
    2. b, the number of processes being blocked, waiting for IO requests;
    3. In, number of interrupts processed
    4. CS, number of context switches being made on the system
    5. US, percent of CPU consumed by the user
    6. SYS, the percentage of cores and interrupts consuming CPU
    7. WA, all running threads are blocked waiting for IO, when the percentage of CPU idle
    8. Id,cpu percent of total idle
vmstat--Memory Parameter Description:
    1. SWPD, the size of the SWAP space used, in kilobytes;
    2. Free, the available physical memory size, in kilobytes;
    3. Buff, the buffer size of the physical memory used to cache read and write operations, in kilobytes;
    4. The cache size, in kilobytes, that the physical memory uses to buffer the process address space;
    5. Si, the size of the data read from swap to RAM (swap in), KB units;
    6. So, the size of the data from RAM to swap (swap out), in kilobytes;
    7. Bi, disk blocks from the file system or SWAP read to the size of RAM (blocks in), block units;
    8. Bo, disk blocks from RAM written to file system or SWAP (blocks out) size, block units;

Different system uses are also different, to find performance bottlenecks need to know what the system is running the application, some characteristics, such as webserver to the system is certainly not the same as the file server, so it is important to distinguish between different types of applications, usually the application can be divided into two types:

①io related, IO-related applications are often used to process large amounts of data, require a lot of memory and storage, frequent IO operations to read and write data, and less CPU requirements, most of the time the CPU is waiting for the hard disk, such as database server, file server, etc. ②CPU related, CPU-related applications need to use a large number of CPUs, such as high-concurrency Web/mail server, image/video processing, scientific computing, etc. can be regarded as CPU-related applications.

Take a look at the actual example, the 1th is the feature that the file server displays when copying a large file:

The 2nd is the characteristics of the CPU when it makes a lot of calculations:

The first example: The ID is around 50%, indicating that the CPU is idle; the large value of the Bi,bo indicates that the bottleneck is on the IO

The second example: R is 4 (= number of CPUs * cores), ID 0, indicates CPU is busy; Bi,bo value is small

Linux performance monitoring top and Vmstat commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.