LINUX-CPU Analysis-top__linux

Source: Internet
Author: User
Tags memory usage cpu usage
I. Preface we all know that the tasks under Windows for each run are managed and viewed through Task Manager. So under Linux. Frequently used system performance analysis commands: Top [Displays information about processes currently being executed by the systems, including process IDs, memory usage, CPU usage, etc.] it dynamically takes a real-time view of the resource footprint of each process in the system. This command can sort tasks by [CPU usage/memory usage]
Two. Detailed parameters


In particular, the first five elements of the top command are the basic information of a system, and there are no excessive explanations here. Here's a look at the fourth line of memory parameters, free idle memory total. Not all of the memory included in the kernel is in use, including memory that has been used in the past that can be reused now, and the kernel does not return these reusable memory back to free, so there will be fewer free memory on Linux, but don't worry about it.
If you calculate the amount of available memory out of habit, here's an approximate formula: line fourth Free + line fourth buffers + fifth cached
For memory monitoring, in the top we are constantly monitoring the fifth line of swap partition used, if this value is constantly changing, the kernel is constantly in memory and swap data exchange, this is the real memory is not enough.

Below, expand the description of the above screenshot of the most of a process analysis, that is, "seventh line 1 of things" ~
pid-Process ID user-Process owner pr-process priority Ni-nice value. A negative value indicates a high priority, and a positive value indicates the total amount of virtual memory used by the low-priority virt-process, in kilobytes. Virt=swap+res The amount of physical memory used by the res-process that was not swapped out, in kilobytes. Res=code+data shr-shared memory size, per KB s-process state. d= non-disruptive sleep state r= run s= sleep t= trace/stop z= zombie process%cpu-"Last updated to now percent of CPU time"%mem-"percent of physical memory used by process" time+-total CPU time used by the process, unit 1/100 seconds COMMA nd-Process Name (command name/command line)

Common operations:1. Press the "1" key, Effect: Expand each CPU Usage 2. Press the "X" key, Effect: CPU usage sort 3. Press the SHIFT + > key to Effect: Mem uses sort 4. Top-n 2: Set the number of updates 2 times, 2 times after the expiration of the update display 5. Top-d 3: Set the update period to 3 seconds, from the original 1 seconds brush to 3 seconds 6. Top-p PID: Displays information for the specified process 7. Top-i: Ignoring idle and zombie processes
Three. Analysis note
1.buffers (line fourth) differs from cached (line fifth):Buffers refers to the read-write buffer of a block device, cached refers to the page cache of the file system itself. They are the underlying mechanism of the Linux system, in order to speed access to the disk.
2.Linux System average load 3 digits meaning (first line)"Load Average", the system average load. Let's give you a rough idea of what these 3 numbers mean: The average number of processes in the process queue that the system runs in the last 1 minutes, 5 minutes, and 15 minutes. Run queues, no waiting io, no wait, no kill process all into this queue.
a). 1,5,15 minutes Three arrays, refer to which one. The latter two are better.
b). Then how to analyze the load is too high. Personally, it is safe to have a single core load below 0.7, and more than 0.7 needs to be optimized. Formula: Load value/CPU core = comparison value
c). How to know my CPU is a few cores.
grep ' model name '/proc/cpuinfo | Wc-l
D). There is also a direct command to display the system's average load
Cat/proc/loadavg	 

In addition to the first 3 digits representing the average number of processes, the following 1 fractions, the denominator represents the total number of system processes, the numerator represents the number of processes that are running, and the last number represents the most recently running process ID.

3. Exchange Zone Concept:When the system has insufficient physical memory, it is necessary to release some of the space in physical memory for use by the currently running program. The freed space may come from programs that are not operating for a long time, and these freed spaces are temporarily saved to the swap space, waiting for those programs to run, and then recover the saved data from swap to memory. In this way, the system always swaps when there is not enough physical memory. See more: vmstat:http://blog.csdn.net/ty_hf/article/details/63394960
Related Article

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.