How to check Linux server performance with commands

Source: Internet
Author: User

1. View System load

(1) Uptime

This command provides a quick view of the machine's load.

In a Linux system, these data represent the processes that wait for CPU resources and the number of blocked IO processes (process status D).

The output of the command, load average, represents an average load of 1 minutes, 5 minutes, and 15 minutes.

With these three data, you can see whether the server load tends to be tense or tends to ease.

If the 1-minute average load is high and the 15-minute average load is low, the server is commanding a high load situation and needs to further troubleshoot where the CPU resources are being consumed.

Conversely, if the average load of 15 minutes is high and the average load of 1 minutes is low, it is possible that the CPU resource crunch time has passed.

(2) W

Show who's logged on and what they is doing.

Can query the user information logged in to the current system, and what these users are doing now

The three numbers behind the load average show the system's average load for the last 1 minutes, 5 minutes, and 15 minutes.

Attention:

Load average This output value, the size of these three values can not generally be greater than the number of logical CPUs of the system.

If the system in the output has 4 logical CPUs, if the three values of load average are longer than 4 o'clock, the CPU is busy and the load is high, which can affect system performance.

But occasionally greater than 4 o'clock, do not worry, generally does not affect system performance. Conversely, if the output value of the load average is less than the number of CPUs, it indicates that the CPU has idle

2.DMESG | Tail

The command outputs the last 10 lines of the system log.

These logs can help you troubleshoot performance issues.

3.vmstat

Vmstat virtual meomory Statistics (dummy memory statistics) for information about processes, virtual storage, paging space, and CPU activity. This information reflects the load situation of the system.

followed by the parameter 1, indicating that the statistics are output once per second, the header prompts the meaning of each column

(1) Monitoring process procs:

    • R: The number of processes waiting on CPU resources .

This data is more capable of showing CPU load than the average load, and the data does not contain the process of waiting for IO. If this value is greater than the number of machine CPU cores, then the CPU resources of the machine are saturated (CPU bottlenecks are present).

    • B: The number of processes waiting for IO.

(2) Monitoring memory Memoy:

    • SWPD: Current swap memory available (in kilobytes)
    • Free: The number of available memory (in kilobytes) of the system

    • Buff: The amount of memory to buffer (in kilobytes).

    • Cache: The amount of memory that is used as a cache (in kilobytes).

(3) monitor swap swap page

    • Si: The number of swap pages, in kb/seconds, from disk swap to memory.
    • So: the number of swap pages from memory swap to disk, in kb/seconds.

If this data is not 0, the system is already using swap (swap), the machine physical memory is insufficient.

(4) Monitoring IO block devices

    • BI: The number of blocks sent to the block device, in blocks per second.
    • Bo: The number of blocks received from the block device, in blocks per second.

(5) Monitoring of system systems

    • In: Number of interrupts per second, including clock interrupts.
    • CS: The number of environment (context) conversions per second.

(6) Monitor CPU:

    • US: The time used by the user process. expressed as a percentage.
    • SY: The time that the system process was used. expressed as a percentage.
    • ID: The idle time of the central processing Unit. expressed as a percentage.

    us, sy, ID, WA, St: These represent the consumption of CPU time, which represents the user time, System (Kernel) time (SYS), idle time (idle), IO wait Time (wait), and stolen time (stolen, Typically consumed by other virtual machines).

These CPU times allow us to quickly understand whether the CPU is out of a busy state.

Note:

If the IO wait time is long, then the system bottleneck may be in disk IO.

If user time and system time are added very large, the CPU is busy executing instructions.

If there is a lot of CPU time consumed in the user state, that is, the user application consumes CPU time. This is not necessarily a performance issue and needs to be analyzed together with the R queue.

4.mpstat-p all 1

This command can show the occupancy of each CPU, and if there is a particularly high CPU utilization, it is possible that a single-threaded application is causing it.

Multiprocessor statistics is an acronym for real-time system monitoring tools

Some statistical information about its report and CPU, which is stored in the/proc/stat file. In a multi-CPUs system, it not only can view the average status information of all CPUs, but also can view the information of specific CPU.

Format: Mpstat [-P {| All}] [internal [count]]

-P {| All} indicates which CPU is monitored and the CPU is valued in [0,cpu number-1]

Internal interval of two samples adjacent to each other

Count number of samples, count can only be used with delay

All: Refers to all CPUs

%USR: Displays the percentage of CPU utilization that is performed at the user level (for example, application)

%nice: Displays the percentage of CPU utilization that is performed at the user level with the Nice priority

%sys: Percentage of CPU utilization at system level (e.g. kernel) execution

%iowait: Displays the percentage of CPU idle time during the system having outstanding disk I/O requests

%IRQ: Shows the percentage of time spent on CPU service hardware interrupts

%soft: Shows the percentage of time spent on CPU service software outages

%steal: Shows the percentage of virtual CPUs that spend time in an involuntary wait when the virtual Machine Manager is serving a second virtual processor

%guest: Shows the percentage of CPU time spent running virtual processors

%idle: Displays the percentage of time that the CPU is idle and the system does not have outstanding disk I/O requests

The system has two CPUs. If you use the parameter-P and then follow the CPU number to get the utilization of the specified CPU.

(Ubuntu installation: Apt-get install sysstat)

5.Pidstat 1

The PIDSTAT command outputs the CPU usage of the process, which continues to output and does not overwrite previous data, allowing for easy observation of system dynamics

6.iostat-xz 1

The Iostat command is primarily used to view machine disk IO situations

    • R/S, w/s, rkb/s, wkb/s: Indicates the number of reads/writes per second and the amount of read and write data per second (Kbytes). Too much reading and writing can cause performance problems.

    • The average wait time for the Await:io operation, in milliseconds. This is the time it takes for an application to interact with the disk, including the IO wait and the actual operation. If this value is too large, the hardware device may be experiencing a bottleneck or malfunction.

    • Avgqu-sz: The average number of requests made to the device. If this value is greater than 1, it is possible that the hardware device is saturated (some front-end hardware devices support parallel writes).

    • %util: Equipment utilization. This value indicates how busy the device is, and if the experience is more than 60, it may affect IO performance (the average latency of the IO operation can be referenced). If you reach 100%, the hardware device is saturated.

Note: If the data for a logical device is displayed, then the device utilization does not represent that the backend actual hardware device is saturated. It is worth noting that even if the IO performance is not ideal, it does not necessarily mean that the application performance is not good, can be used such as pre-read, write cache policies to improve application performance

7.free-m

The free command can see how the system memory is used, and the-m parameter indicates that it is displayed in megabytes.

The last two columns represent the number of memory used for the IO cache, and the number of memory used for the file system page cache.

Note:

The second line-/+ Buffers/cache, which looks like the cache takes up a lot of memory space. This is the memory usage policy of the Linux system, using the memory as much as possible, and if the application needs memory, this part of the memory is immediately reclaimed and allocated to the application.

If there is very little available memory, the system may use the Swap area (if configured), which increases the IO overhead (which can be iostat in the command) and reduces system performance.

8.sar-n DEV 1

The SAR command here can see the throughput rate of the network device.

When troubleshooting performance issues, you can determine whether the network device is saturated through the throughput of the network device.

9.sar-n tcp,etcp 1

The SAR command is used here to view the status of the TCP connection, which includes:

    • ACTIVE/S: The number of locally initiated TCP connections per second, both of which are created by the Connect call;

    • PASSIVE/S: The number of TCP connections initiated remotely per second, that is, the TCP connection created through the accept call;

    • RETRANS/S: Number of TCP retransmissions per second;

The number of TCP connections can be used to determine whether the performance problem is due to excessive connections, which can be further judged by the active connection or the passively accepted connection. TCP retransmission may be due to poor network environment, or excessive server pressure caused by packet loss.

Ten.top

The top command contains the contents of the check for several previous commands. such as system load conditions (uptime), System memory usage (free), System CPU usage (VMSTAT), and so on.

Therefore, this command allows you to view the source of the system load in a relatively comprehensive way. At the same time, the top command supports sorting and can be sorted by different columns, which makes it easy to find processes such as the most memory consuming process, the highest CPU utilization, and so on.

However, the top command, relative to some of the previous commands, is an instantaneous value that may miss some clues if it is not continually staring. You may need to pause the top command refresh to record and compare the data.

How to check Linux server performance with commands

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.