Linux Top commands

Source: Internet
Author: User

Linux Top commands

View multi-core CPU commands

Mpstat-p all and sar-P ALL

Description: sar-p all> aaa.txt redirects the output content to the aaa.txt file.

 

Top commands are often used to monitor linux system conditions, such as cpu and memory usage. Programmers generally know this command, but it is strange that few people can use it well, for example, the memory value in the top monitoring view has many misinterpretations.

This article describes the meaning of various data in the top view through top monitoring of a running WEB server, and sorts the fields of various processes (tasks) in the view.

 

Top entry View

Top view 01

[Top View 01] is the basic view of top. We will use this view to explain the meaning of each data.

The first line:
10:01:23-current system time
126 days,-the system has been running for 126 days, 14 hours, and 29 minutes (no restart during this period)
2 users-there are currently two users logging on to the system
Load average: 1.15, 1.42, 1.44-load average, the three numbers after which are 1 minute, 5 minutes, and 15 minutes respectively.

The load average data checks the number of active processes every five seconds and then calculates the value based on a specific algorithm. If this number is divided by the number of logical CPUs, the system is overloaded when the result is higher than 5.

Row 2:
Tasks-task (process), the system now has a total of 183 processes, of which one is running, 182 are sleeping, and 0 are stoped, zombie status (zombie) has 0.

Row 3: cpu status
6.7% us-Percentage of CPU used by user space.
0.4% sy-Percentage of CPU occupied by kernel space.
0.0% ni-Percentage of CPU used by processes with changed priorities
92.9% id-Percentage of idle CPU
0.0% percentage of CPU occupied by wa-IO wait
0.0% hi-Percentage of CPU used by Hardware IRQ
0.0% CPU usage of si-Soft Interrupt (Software Interrupts)

Here, the CPU usage rate is different from that of windows. If you do not understand the user space and kernel space, you need to recharge your instance.

Row 4: memory status
8306544 k total-total physical memory (8 GB)
7775876 k used-total memory in use (7.7 GB)
530668 k free-total idle memory (530 MB)
79236 k buffers-cache memory (79 M)

Row 5: swap Partition
2031608 k total-total swap zone (2 GB)
2556 k used-Total number of swap zones used (2.5 M)
2029052 k free-Total number of free swap areas (2 GB)
4231276 k cached-total buffer swap zone (4 GB)

It should be noted that the concept of memory in windows cannot be used to understand the data. If the server is "dangerous" in windows mode: 8 GB memory is left with only MB of available memory. Linux memory management has its own particularity, And the complexity needs to be explained in a book. Here is just a simple introduction and our traditional concepts (windows) are different.

In Row 4, the total memory used (used) refers to the number of memories currently controlled by the system kernel. The total idle memory (free) is the amount of memory that the kernel has not yet incorporated into its control scope. The memory included in the kernel management is not always in use, but also the memory that can be reused in the past, the kernel does not return the reusable memory to free. Therefore, free memory will become fewer and fewer on linux, but you don't have to worry about it.

If you calculate the number of available memory out of habit, there is an approximate formula: free in the fourth row + buffers in the fourth row + cached in the fifth row, according to this formula, the available memory of this server is 530668 + 79236 + 4231276 = 4.7 GB.

For memory monitoring, we need to monitor the used of the fifth-line swap partition in top. If this value is constantly changing, it means that the kernel is constantly exchanging data between memory and swap, this is the real insufficient memory.

Row 6 is empty

Line 7: Status monitoring of processes (tasks)
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.
VIRT-Total virtual memory used by the process, in kb. VIRT = SWAP + RES
RES-physical memory used by the process, not swapped out, in kb. RES = CODE + DATA
SHR-shared memory size, in kb
S-Process status. D = non-disruptive sleep state R = running S = sleep T = tracking/stopping Z = botnets
% CPU-Percentage of CPU time occupied since the last update
% MEM-Percentage of physical memory used by the Process
TIME +-total cpu time used by the process, in the unit of 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:

Top view 02

Observe that the server has 16 logical CPUs, which are actually 4 physical CPUs.

  • 1
  • 2
  • 3
  • 4
  • Next Page

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.