Detailed Explanation of Common Indicators and Instructions for Liunx Server Inspection

First of all, several analysis indicators of our server inspection are directly given, as shown in the table:

index value
CPU load for 15 minutes 4%
memory remaining available 337M
memory size 3.7g
HDD size 50G
HDD used 3.4G
Network inflow rate (RX) 188kb
Network outflow rate (TX) 131kb

You can use the following command to view the performance metrics of your Linux server:

  1. Memory remaining available and memory size:
free -h

After executing this command, the memory usage of the current system will be output, including total memory, used memory, remaining memory and other information, for example:

              total        used        free      shared  buff/cache   available
Mem:           15Gi       3.3Gi       9.9Gi       128Mi       2.3Gi        11Gi
Swap:         4.0Gi          0B       4.0Gi

Among them, total represents the total memory size, and free represents the remaining available memory size.

  1. Hard Disk Size and Hard Disk Used:
df -h

After executing this command, the hard disk usage of the current system will be output, including disk mount point, total size, used size, available size and other information, for example:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        50G  5.9G   41G  13% /
/dev/sda2        50G   33G   14G  71% /data

Among them, Size indicates the total size, Used indicates the used size, and Avail indicates the available size.

  1. Network ingress rate and network egress rate:
iftop

After executing this command, the inflow and outflow rate and traffic of the network will be displayed in real time, for example:

    1.23Mb      2.46Mb      3.69Mb               4.92Mb      6.15Mb      7.38Mb               
===============================================================================================
TX:             cum:   13.2MB   13.2MB   13.2MB  dev:   0.0%   0.0%   0.0%   0/0B   0/0B   0/0B
RX:             cum:   11.9MB   11.9MB   11.9MB  dev:   0.0%   0.0%   0.0%   0/0B   0/0B   0/0B
TOTAL:          cum:   25.1MB   25.1MB   25.1MB  dev:   0.0%   0.0%   0.0%   0/0B   0/0B   0/0B

Among them, TX indicates network outflow, RX indicates network inflow, cum indicates accumulated traffic, and dev indicates the occupancy rate of network equipment.

Note that the above commands need to be executed on a Linux server. If you are logged into the server via SSH, you can enter these commands directly into the terminal. If you are logged into the server through a remote desktop or web console, you need to open a terminal or command line tool to execute these commands.

  1. CPU load
top -bn1 | grep load

top -bn1 | grep load, used to output CPU load information. After the script is executed, the memory usage, hard disk usage, network traffic and CPU load information of the server will be output in sequence

In the Linux system, Load Average refers to the average number of processes in the running queue over a period of time, and can also be understood as the number of processes that are using the CPU and waiting for the CPU. When the system load is high, it means that the CPU is being used by a large number of processes, or there are a large number of processes waiting for the CPU time slice, which may cause the system to respond slowly.

The load value of a Linux system usually consists of three numbers, representing the average number of processes in 1 minute, 5 minutes, and 15 minutes, respectively. For example, the payload value you provided "0.00, 0.01, 0.16" means:

  • The average number of processes in 1 minute is 0.00;
  • The average number of processes in 5 minutes is 0.01;
  • The average number of processes over a 15-minute period is 0.16.

Generally speaking, when the load value is less than 70% of the number of CPUs, it means that the system load is low; when the load value is greater than 70% of the number of CPUs, it means that the system load is high; when the load value exceeds the number of CPUs, it means that the system load is very high, which may cause the system to respond slowly.

For example, if your server has 4 CPU cores, when the load value is less than 2.8 (4*0.7), it means that the system load is low; when the load value is greater than 2.8, it means that the system load is high; when the load value exceeds 4, it means that the system load is very high.

It should be noted that the load value is not the only performance indicator, and performance indicators such as CPU usage, memory usage, and I/O of the system also need to be considered. It is usually necessary to consider multiple performance indicators comprehensively to evaluate the performance of the system.

To calculate the load percentage, you first need to know the number of CPU cores your server has. Assuming your server has 4 CPU cores, you can use the following formula to calculate the load percentage:

负载百分比 = (load average / CPU 核心数量) * 100%

For example, for the load values ​​you provided "0.00, 0.01, 0.16", the result of calculating the load percentage is:

1 分钟负载百分比 = (0.00 / 4) * 100% = 0%
5 分钟负载百分比 = (0.01 / 4) * 100% = 0.25%
15 分钟负载百分比 = (0.16 / 4) * 100% = 4%

So your server's load percentage for short periods of time is very low, but for long periods of time it might be around 4%, which is relatively low and indicates that the server's CPU is in good health. It should be noted that the load percentage is only a reference value, and other performance indicators need to be considered to evaluate the performance of the system in actual situations.

You can use the following command to see the number of CPU cores of a Linux server:

grep -c ^processor /proc/cpuinfo

After executing this command, the number of CPU cores in the current system will be output, for example:

4

The numbers in it indicate the number of CPU cores in the current system.

In addition, you can also use lscputhe command to view the detailed information of the CPU, including the number of CPU cores, CPU frequency, CPU model, etc. For example, execute the following command to view the number of CPU cores:

lscpu | grep "^CPU(s):"

After executing this command, the number of CPU cores in the current system will be output, for example:

CPU(s):              4

The numbers in it also indicate the number of CPU cores in the current system.

Note that different CPU models may have different numbers of cores and threads, so the same command may output different results on different servers.

attach a shell script

#!/bin/bash

# 内存使用情况
echo "Memory Usage:"
free -h

# 硬盘使用情况
echo "Disk Usage:"
df -h

# 网络流量情况
echo "Network Traffic:"
iftop

# CPU 负载情况
echo "CPU Load:"
top -bn1 | grep load

Guess you like

Origin blog.csdn.net/Tanganling/article/details/131326167