View multi-core CPU commands mpstat-p all and sar-p all
Description: Sar-p all > Aaa.txt redirect output to file Aaa.txt
The top command is often used to monitor Linux system conditions, such as CPU, memory use, the programmer basically know the command, but it is strange that there are few people can use it well, such as the top monitor view of the memory value of the meaning of a lot of misunderstanding.
This article describes the meaning of the various data in the top view, including the sorting of the fields of each process (task) in the view, through a top monitor screenshot of a running Web server.
Top Entry View
"Top View 01" is the basic view that just entered the top, and we'll combine this view to explain the meaning of each data.
First line:
10:01:23-Current system time
126 Day, 14:29-the system has been running for 126 days 14 hours and 29 minutes (no reboot during this period)
2 users-currently has 2 user login system
Load average:1.15, 1.42, 1.44-load average the following three numbers are 1 minutes, 5 minutes, 15 minutes of loading.
The load average data is the number of active processes that are checked every 5 seconds, and then the values calculated by a specific algorithm. If this number is divided by the number of logical CPUs, the result is higher than 5, indicating that the system is overloaded.
Second line:
tasks-task (process), the system is now a total of 183 processes, of which 1 are running, 182 in hibernation (sleep), stoped state of 0, zombie State (zombie) has 0.
Third line: CPU state
6.7% the percentage of CPU that us-user space consumes.
0.4% sy-The percentage of CPU consumed by the kernel space.
0.0% ni-Percentage of CPU per process that has changed priority
92.9% id-Idle CPU percent
0.0% Wa-io% of CPU waiting to be consumed
0.0% hi-Hard Interrupt (Hardware IRQ)% of CPU usage
0.0% si-Soft Interrupt (Software interrupts) Percentage of CPU utilization
The CPU usage ratio here is different from the Windows concept, and if you don't understand user space and kernel space, you need to recharge it.
Line four: Memory status
8306544k total-Total Physical memory (8GB)
7775876k used-Total Memory in use (7.7GB)
530668k free-Total free memory (530M)
79236k buffers-Cache Memory (79M)
Line five: Swap swap partition
Total 2031608k total-swap area (2GB)
Total number of swap areas used by 2556k used-(2.5M)
2029052k free-Free Swap area total (2GB)
4231276k cached-Buffer Total swap area (4GB)
To illustrate here is not to use the concept of Windows memory to understand this data, if the Windows way this server "dangerous": 8G of total Memory only 530M of available memory. The memory management of Linux has its particularity, complex point need a book to explain, here is simply point and our traditional concept (Windows) difference.
The total amount of memory in use (used) in line four refers to the amount of memory currently controlled by the system kernel, and the total amount of free memory is the number of cores that have not yet been included in its control range. 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 + fourth line buffers + fifth line cached, press this formula for this server's available memory: 530668+79236+4231276 = 4.7GB.
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.
Line Six is a blank line
Line seventh: Status monitoring for each process (Task)
pid-Process ID
user-Process Owner
pr-Process Priority
Ni-nice value. A negative value indicates a high priority, and a positive value indicates a low priority
Total amount of virtual memory used by the virt-process, in kilobytes. Virt=swap+res
The amount of physical memory that the res-process uses, 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-percentage of CPU time that was last updated to current
Percentage of physical memory used by the%mem-process
Total CPU time used by the time+-process, in units 1/100 seconds
command-Process Name (command name/command line)
Multi-u multi-core CPU monitoring
In the top basic view, press the keyboard number "1" to monitor the status of each logical CPU:
In the view above, the server has 16 logical CPUs, which are actually 4 physical CPUs.
If you do not press 1, the average of all CPUs is displayed in the top view
Process field Sorting
When you go to top by default, processes are sorted by CPU usage, and Java processes with a process ID of 14210 in top view 01 are ranked first (CPU occupies 100%), and process ID 14183 Java processes are ranked second (CPU occupies 12%). You can change the sort fields by keyboard commands, such as monitoring which process takes up the most mem, and I use the following methods generally:
1. Tapping the keyboard "B" (turn on/off brightening effect), the view of top changes as follows:
We found that the "top" process with a process ID of 10704 was highlighted, and the top process was the only running state (runing) that was displayed in the second row of the view, and you could turn off or turn on the highlight effect of the running process by tapping the "Y" key.
2. Tapping the keyboard "X" (The highlight effect on/off the row sequence), the top view changes as follows:
As you can see, the top default sort column is "%cpu".
3. Through SHIFT + > or SHIFT + <, you can change the order of the column to the right or left, and the following illustration is a "SHIFT + >" Effect chart:
The view is now sorted by%mem.
Change the Process display field
1. Tap the "F" key and top into another view, where you can arrange the display fields in the basic view:
This lists all the process fields that can be displayed in the top base view, and fields that have "*" and are marked as uppercase are visible, and fields that do not have "*" and are lowercase letters are not displayed. If you want to display the "CODE" and "DATA" two fields in the basic view, you can click the "R" and "s" Keys:
2. "Enter" return to the basic view, you can see more "CODE" and "DATA" two fields:
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.