Learn linux system monitoring tools 1. Learn linux

Source: Internet
Author: User

Learn linux system monitoring tools 1. Learn linux

Make full use of the built-in linux system monitoring tools to quickly and conveniently understand the system performance and other issues, so as to facilitate system analysis and debugging.

Learning articles: Every system administrator needs to know 30 Linux system monitoring tools and learn CPU and process performance monitoring through vmstat.

[1] top-monitoring process commands

CommandtopReal-time Monitoring Chart

1. Understandingtop

top(Different systems may have different names, such as IBM aixtopas) Command to display the system processes and provide a real-time dynamic view (that is, real-time monitoring of Process activities). By default,topThe command displays the processes with the highest CPU usage and updates each 5S.

2. Main Functions
It is mainly used to monitor the Real-Time Load Rate of the system, the resource usage rate of processes, and whether other system status attributes are normal.

3. View Process Monitoring
Terminal input commandtop

Output Recognition

  • Line 1: displays system-level load. The average load has three outputs, representing the average load in the past 1, 5, and 15 minutes. The output of this part is consistent with the command uptime.
  • Row 2: displays general information about processes, such as the current total number of processes, the number of running or sleep processes. In the process listSThe column value isRRepresentativerunning, IfSIssleeping.
  • Row 3: DisplaycpuSome load information, especially%idAnd%waThese two indicators are particularly important.%idToo low,%waVery low.cpuThe usage is very high and there may be somesqlThe statement consumes a lotcpuResource, if%waIf it is very high, it is likely that the system IO has a problem.
  • Row 4: displays the memory usage. If the memory usage is abnormal, you can find it in the highlighted process information.%MEMProcesses that consume a relatively high level.
  • The fifth line shows the swap area. If the memory is sufficient or the system load is not high, there is no big change in the data in this part.

Notte: Parameter description of CPU status information
% Cpu (s): 9.5 us, 4.2 sy, 0.0 ni, 74.5 id, 11.7 wa, 0.0 hi, 0.1 si, 0.0 st

4. Common shortcut keys
DeepintopCommandzShortcut Key black/white switch mode

Shortcut Key Usage

  • T: whether to display summary information
  • M: whether to Display memory information
  • A: sorting processes based on the utilization of various system resources helps to quickly identify tasks with poor system performance.
  • B: enable or disable the bold display of important numbers in the table.
  • C: enter directlytop -cOr (entertopAnd then enter the shortcut keycThe command name of the display process or the input information of the completed command line will be switched.
  • F: Enter the top interactive configuration screen to set top Display Based on specific requirements.
  • O: If you want to customize the displaytopCommand output order.pid,userTo display process information, if you wantuser,pidTo display, you can usecShortcut Key. InputtopAnd then entero, An interactive interface is displayed. If you want to display the column USER first, enterEAnd then press Enter. The result is rearranged.
  • R: renice)
  • K: kill A Process)
  • Z: Switch the color or black/white Mode
[2] vmstat-Virtual Memory statistics

1. Understandingvmstat

vmstat [options] [delay [count]]

vmstatCommands are the most common Linux/Unix monitoring tool. They can display the status values of servers at a given interval, including CPU usage, memory usage, virtual memory switching, and IO read/write.

vmstatCommandmanPage

2. Main Functions
The vmstat Command reports information about processes, memory, paging, block IO, interruptions, and CPU activity.

3. view memory statistics

vmstatMonitoring

Note: Parameter description
Procs ---- memory -----swap--- io ---system--- cpu --
Procs
R B swpd free buff cache si so bi bo in cs us sy id wa st
1.r: Number of kernel threads (number of processes) in the running queue. This value can also determine whether to increase the CPU. (Longer than 1)
2.b: Number of kernel threads placed in the waiting queue (waiting for resources, waiting for input/output); Number of non-interrupted processes in the block queue
Memory
3.swpd: Available virtual swap memory, ifswpdThe value is not 0,SI,SOThe long-term value is 0, which does not affect the system performance.
4.free: Idle physical memory size
5.buff: Memory size used as a buffer
6.cache: The cache memory size. IfcacheDescription when the value is largecacheThe number of files is large, and files that are frequently accessed can becacheThe disk read IO bi will be very small.
Swap
7.si: Number of swap pages from disk to memory (Unit/S)
8.so: Number of swap pages (Unit/S) from swap memory to disk)
IO
9.bi: Number of blocks received by the block device (Block/second)
10.bo: Number of blocks sent to block devices (Block/second)
System
11.in: Number of interrupts per second, including clock interruptions
12.cs: Number of context switches per second
CPU
13.us: Percentage of CPU consumed by all processes in user mode. When the us value is relatively high, it indicates that the CPU time consumed by the process user State is too large. If the CPU time exceeds 50% for a long time, you need to consider optimizing the application.
14.sy: Percentage of kernel system process execution time (system time ).syWhen the value is high, it indicates that the CPU time consumed by the process kernel state is too large; ifus+syExceeds80%CPU resources are insufficient.
15.id: Percentage of idle CPU time
16.wa: IO wait time percentage
17.st: CPU usage percentage of virtual machines. IfwaThe value exceeds20%, DescriptionIOThe wait is serious.stOnly in LinuxvmstatShow

4. options)


Option usage instructions

  • A: displays active and inactive pages.
  • F: displays the total number of processes created after startup.
  • M: DisplayslabInformation
  • N: The header information is only displayed once.
  • S: display the event counters and memory status in a table
  • D: Displays disk statistics.
  • P: displays statistics of specified disk partitions.
  • S: The unit of output information. Parameters include k, K, m, and M, representing 1000, 1024, 1000000, and 1048576 bytes respectively ). The default unit is K (1024 bytes)
  • V: DisplayvmstatVersion information.

5. Parameters

  • Delay: refresh interval. If this parameter is not specified, only one result is displayed.
  • Count: Number of refreshes. If you do not specify the number of refreshes, but specify the interval, the number of refreshes is infinite.

6. Use instances

Instance 1: AveragevmstatTwo numeric parameters are used. The first parameter is the number of sampling intervals, in seconds, and the second parameter is the number of samples,

vmstat 2 1

In fact, in the application process, we often get used to monitoring for a period of time and don't want to directly end monitoring.vmstat

Instance 2: Displays active and inactive memory.

vmstat -a 2 3

Use-aWhen the option shows active and inactive memory, the displayed content is increased.inactAndactive.

Field supplementary description
Memory (Memory ):
Inact: inactive memory size (when used-aOption)
Active: active memory size (when used-aOption)

Instance 3: View how many times the system has fork

vmstat -f

View comments

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.