Linux top commands for monitoring and diagnosis tools

Source: Internet
Author: User

Linux top commands for monitoring and diagnosis tools

Directory

(1) system and task statistics:
(2) process and cpu statistics:
(3) memory information of the last two behaviors:
How does one calculate the actual number of available memory for a program?
How does one calculate the number of memory used by a program of 3.2?
3.3 How can I determine whether the system has insufficient memory?
3.4 difference between buffer and cache
(4) Process Information Zone:
(5) view specified Columns
5.1 f key select display content
5.2 o key change display order
5.3 F/O keys sort processes by Column
(6) common interactive commands
(7) Final skills: top Command tips
(8) Refer:

Linux users may not be unfamiliar with top commands (different system names may be different, such as topas in IBM aix ), it is mainly used to monitor the system's real-time load rate, process resource usage, and other system status attributes.

Next let's take a look at Zhang top:

Practical top Command

Why does Linux's htop command win the top command?

Use the most powerful process monitor htop in Ubuntu

Install htop process management and monitoring tools in CentOS 6.5

Top command causes system load increase

(1) system and task statistics:

The first eight rows are the overall statistics of the system. The second line is the task queue information, which is the same as the execution result of the uptime command. The content is as follows:

01:06:48 Current Time
Up :22 System running time, in the format of minutes
1 user Current Login User count
Load average: 0.06, 0.60, 0.48 System load, that is, the average length of the task queue.

The three values are the average values from 1 minute, 5 minutes, and 15 minutes ago to the present.

Note: These three values can be used to determine whether the system load is too high-if the value

If the number of cpu cores exceeds the limit, you need to optimize your program or architecture.

(2) process and cpu statistics:

2nd ~ 6. Information about the process and CPU. When multiple CPUs exist, the content may exceed two rows. The content is as follows:

Tasks: 29 total Process count
1 running Number of Running Processes
28 sleeping Number of sleep Processes
0 stopped Number of stopped Processes
0 zombie Number of zombie Processes
Cpu (s): 0.3% us CPU usage percentage of user space
1.0% sy CPU usage of kernel space
0.0% ni CPU usage percentage of processes that have changed their priorities in the process space
98.7% id Idle CPU percentage
0.0% wa Percentage of CPU time waiting for Input and Output
0.0% hi Hardware IRQ
0.0% si Software IRQ

Note:

(1) IRQ: IRQ is called Interrupt Request, meaning "Request interruption.

(2) st (Steal Time): Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor. it's only relevant in receivalized environments. it represents time when the real CPU was not available to the current virtual machine-it was "stolen" from that VM by the hypervisor (either to run another VM, or for its own needs ).

So, relatively speaking, what does this mean? A high steal percentage may mean that you may be outgrowing your virtual machine with your hosting company. Other virtual machines may have a larger slice of the CPU’s time and you may need to ask for an upgrade in order to compete. Also, a high steal percentage may mean that your hosting company is overselling virtual machines on your particular server. If you upgrade your virtual machine and your steal percentage doesn’t drop, you may want to seek another provider. A low steal percentage can mean that your applications are working well with your current virtual machine. Since your VM is not wrestling with other VM’s constantly for CPU time, your VM will be more responsive. This may also suggest that your hosting provider is underselling their servers, which is definitely a good thing.0.0% sisi(Software Interrupts)
(3) memory information of the last two behaviors:
Mem: 191272 k total Total physical memory
173656 k used Total physical memory used
17616 k free Total idle memory
22052 k buffers Memory Used as kernel Cache
Swap: 192772 k total Total number of swap Areas
0 k used Total number of swap zones used
192772 k free Total number of idle swap Areas
123988 k cached The total number of buffer swap areas.
The content in the memory is swapped out to the swap zone and then into the memory, but the used swap zone has not been overwritten,
This value indicates the size of the SWAp zone where the content already exists in the memory.
When the corresponding memory is swapped out again, you do not have to write data to the swap zone.

PS: how to calculate available memory and used memory?

In addition to free-m, you can also see top:

 

Mem:    255592k total,   167568k used,    88024k free,    25068k buffersSwap:   524280k total,        0k used,   524280k free,    85724k cached
How does one calculate the actual number of available memory for a program?

The answer is: free + (buffers + cached)

88024 k + (25068 k + 85724 k) = 198816 k

How does one calculate the number of memory used by a program of 3.2?

The answer is: used-(buffers + cached)

167568 k-(25068 k + 85724 k) = 56776 k

3.3 How can I determine whether the system has insufficient memory?

If your swap used value is greater than 0, you can basically determine that you have encountered a memory bottleneck, either optimizing your code or adding memory.

3.4 difference between buffer and cache

A buffer is something that has yet to be "written" to disk. A cache is something that has been "read" from the disk and stored for later use from the application perspective, buffers/cached is equal to available, because buffer/cached is designed to improve file read/write performance, when the application needs to use the memory, buffer/cached will be quickly recycled.
From the application perspective, the available memory = system free memory + buffers + cached.

Buffers is the buffer size for Block devices. It only records the metadata and tracking in-flight pages of the file system.
Cached is used to buffer files.
That is to say: buffers is used for storage. What content and permissions are contained in the directory.
Cached is used directly to remember the files we opened. If you want to know whether the files take effect, you can try and execute two commands one by one # man X, you can obviously feel that the second start is much faster.

Experiment: it is obvious on a machine with no application. Remember that the experiment can only be performed once. If you want to do more, change the file name.

# Free
# Man X
# Free
# Man X
# Free
You can compare the size of buffers after free.
Another experiment:
# Free
# Ls/dev
# Free
You can compare the two sizes. Of course, the buffers are increasing at any time, but if you have ls, the increase will be faster. This is the difference between buffers and chached.
Because Linux uses the memory that you do not currently use as the file and data cache to improve system performance, the system will automatically release the memory when you need it (unlike windows, even if you have a lot of idle memory, you need to access pagefiles on the disk)

(4) Process Information Zone:

The details of each process are displayed at the bottom of the statistics area. First, let's take a look at the meaning of each column.

Serial number Column name Description
A PID Process id
B PPID Parent process id
C RUSER Real user name
D UID User ID of the process owner
E USER User Name of the process owner
F GROUP Group Name of the process owner
G TTY The terminal name of the startup process. Processes not started from the terminal are displayed?
H PR Priority
I NI Nice value. A negative value indicates a high priority, and a positive value indicates a low priority.
J P The last CPU used is only meaningful in multiple CPU environments.
K % CPU CPU usage from the last update to the present
L TIME Total CPU time used by the process, in seconds
M TIME + Total CPU time used by the process, in 1/100 seconds
N % MEM Percentage of physical memory used by the Process
O VIRT Total virtual memory used by the process, in kb. VIRT = SWAP + RES
P SWAP In the virtual memory used by the process, the swap size, in kb.
Q RES Physical memory used by the process, not swapped out, in kb. RES = CODE + DATA
R CODE Physical memory occupied by executable code, in kb
S DATA Physical memory occupied by parts other than executable code (Data Segment + stack), in kb
T SHR Size of shared memory, in kb
U NFLT Page error count
V MCM t The number of pages that have been modified since the last write to the present.
W S Process status.
D = uninterrupted sleep
R = run
S = sleep
T = tracking/stopping
Z = zombie Process
X COMMAND Command name/command line
Y WCHAN If the process is sleeping, the system function name displayed in sleep
Z Flags Task flag, refer to sched. h

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 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.