Use w to view system load vmstat command top command sar command nload command

Use w to view system load:

1. w/uptime View system load:

[root@localhost ~]# w

23:41:31 up 20 min, 2 users, load average: 0.32, 0.08, 0.05

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT

root tty1 23:41 11.00s 0.02s 0.02s -bash

root pts/0 192.168.0.108 23:22 3.00s 0.03s 0.01s w

•illustrate:

• 23:41:31 means the current time;

• up 20 min indicates how long the machine runs;

• 2 users indicates how many users log in to this machine;

• load average: 0.32, 0.08, 0.05 1 minute, 5 minutes, 15 minutes system load average. This value defines the number of active CPU processes per unit time. Of course, the larger the value, the greater the pressure on the server. In general, it does not matter as long as the number of cores of the CPU is not exceeded. Otherwise, it is necessary to pay attention to whether the load is too high.

• USER indicates which user is used to log in;

• TTY means the way to log in to linux; tty means to log in locally on the server; pts/0 means to use the remote terminal tool to log in;

• FROM indicates the machine on which to log in;

• LOGIN@ indicates the user login time;

• IDLE indicates how long it has been idle;

• JCPU indicates the CPU time occupied by all processes and child processes under the current terminal;

• PCPU indicates how much time the current command w takes;

• WHAT indicates what the current command is;

Uptime can also view the system load. In fact, the result displayed by uptime is the same as the first line of w

[root@localhost ~]# uptime

00:23:37 up 1:02, 2 users, load average: 0.00, 0.01, 0.05

/proc/cpuinfo This file records the detailed information of cpu;

grep -c 'processor' /proc/cpuinfo to view the number of cpu cores;

vmstat command:

2. vmstat monitors system status

• Use vmstat 1 to display once a second, press ctrl + c to end

• Use vmstat 1 5 to display once per second, 5 times in total

[root@localhost ~]# vmstat

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----

r b swpd free buff cache si so bi bo in cs us sy id wa st

2 0 0 1620388 764 152852 0 0 9 0 39 44 0 0 100 0 0

The w mentioned above refers to the overall load of the system. By looking at the value, you can know whether the current system is under pressure. But it is impossible to judge where the pressure is (cpu, memory, disk, etc.), and you can know where the pressure is through vmstat. The vmstat print result is divided into 6 parts:

procs, memory, swap, io, system, cpu. Focus on the columns rb si so bi bo.

• procs displays process related information:

r: Indicates the number of processes running and waiting for cpu time slices. If it is greater than the number of server CPUs for a long time, it means that the CPUs are not enough

used. (Indicates how many tasks are in the running state)

b: Indicates the number of processes waiting for resources. For example, waiting for I/O memory, etc. If the value of this column is greater than 1 for a long time, you need to close

Note it. (Number of blocked processes)

• memory Memory related information:

swpd: Indicates the amount of memory switched to the swap partition; the unit is KB; (some programs will put the data in the memory down

exchange)

free: the current amount of free memory

buff: buffer size, (to be written to disk, temporary memory space) how many buffs are left

cache: cache size, (read from disk) how much cache is left

• swap memory swap situation

si: The amount of data written to the memory by the swap area; the unit is KB

so: The amount of data written to the swap area from memory; the unit is KB

• io disk usage

bi: The amount of data read from the block device (reading the disk); the data is written to the memory, more than 1000 hard disks are under pressure

bo: the amount of data written from the block device (write to disk); from memory to disk;

• system displays the number of interrupts that occurred within the acquisition interval

in: Indicates the number of device interrupts per second observed in a time interval

cs: Indicates the number of context switches generated per second

• CPU Displays the cpu usage status

us: shows the percentage of cpu time spent under the user

sy: Displays the percentage of CPU time spent by the system

id: Indicates the percentage of time the cpu is idle

wa: Indicates the percentage of time spent waiting for I/O

st: Indicates the percentage of stolen CPUs (usually 0)

us +sy +id = 100

top command: 

• top view process resource usage

• top -d 1 refreshes once in a second (top refreshes once in 3 seconds by default)

• top -c displays detailed process information

• top -bn1 shows all processes statically

• q to quit, number 1 to show all core cpus, capital letter M to sort by memory usage

• Capital P to sort by cpu usage

• top only shows one screen, the rest can be scrolled down by pressing shift >

sar command:

sar (System Activity Reporter system activity report) is one of the most comprehensive system performance analysis tools on Linux. It can report system activities from various aspects, including: file read and write, system call usage, disk I/O, CPU efficiency, memory usage, process activity, and IPC-related activities.

sar will generate a file named sa + date in the /var/log/sa/ directory every day, cover it monthly, and count the system status every 10 minutes.

 

• yum install -y sysstat

After installing the sysstat package you can use the sar command

 

Options:

1. sar lists the CPU resource status of the day

CPU: all means that the statistics are the average of all CPUs.

%user: Displays the percentage of total CPU time spent running at the user level (application).

%nice: Displayed at the user level for nice operations, the percentage of the total CPU time occupied.

%system: The percentage of total CPU time used to run at the kernel level.

%iowait: Displays the percentage of total CPU time spent waiting for I/O operations.

%steal: The percentage of virtual CPUs that the hypervisor is waiting for to serve another virtual process.

%idle: Displays the percentage of CPU idle time occupied by the total CPU time.

1. If the value of %iowait is too high, it means that the hard disk has an I/O bottleneck

2. If the value of %idle is high but the system response is slow, it is possible that the CPU is waiting to allocate memory, and the memory capacity should be increased.

3. If the value of %idle continues to be lower than 1, the CPU processing capacity of the system is relatively low, indicating that the resource that needs to be solved most in the system is the CPU

sar 5 counts the load every 5 seconds, press ctrl + c to exit;

sar 5 3 counts every 5 seconds and ends after 3 times;

sar -u lists the CPU resource monitoring statistics of the day like sar;

sar -u -f /var/log/sa/sa09 -f View the cpu resource monitoring recorded by the binary history file;

 

2. sar -n DEV lists the network card traffic status of the day

sar -n DEV 1 10 Count once every second, and exit after 10 times;

sar -n DEV -f /var/log/sa/saxx View network traffic statistics on a specific date;

rxpck/s received packets per second

rxpck/s The number of packets sent per second

rtkB/s amount of data received per second

txkB/s The amount of data sent per second

 

3. sar -b I/O and transfer rate monitoring

sar -b 1 5

sar -b -f /var/log/sa/saxx

tps: Total I/O transfers per second to the physical device

rtps: The total amount of data read from the physical device per second

wtps: The total amount of data written to the physical device per second

bread/s: The amount of data read from the physical device per second, in blocks/s

bwrtn/s: The amount of data written to the physical device per second, in blocks/s

 

4. sar -q system load

sar -q 1 3

sar -q -f /var/log/sa/saxx

Process queue length and average load status monitoring:

runq-sz: length of the run queue (number of processes waiting to run)

plist-sz: the number of processes and threads in the process list

ldavg-1: System load average for the last minute

ldavg-5: System load average over the past 5 minutes

ldavg-15: System load average over the past 15 minutes

 

5. sar -f /var/log/sa/saxx history file

 

6. sar -o file means to store the command result in a file in binary format, where file is the file name.

sar -n DEV 1 3 -o net.txt

sar -f net.txt

 

ls / var / log / sa /

The binary file that starts with sa can only be viewed with sar -f

The beginning of sar is normal text that can be viewed with cat

 

It is suspected that there is a bottleneck in the CPU, which can be viewed with sar -u and sar -q, etc.

It is suspected that there is a bottleneck in memory, which can be viewed by sar -B, sar -r and sar -W, etc.

Suspected that there is a bottleneck in I/O, you can use sar -b, sar -u and sar -d to check

nload command:

Purpose: Used to monitor the network status and the bandwidth used by each ip in real time

1. yum install -y nload

install nload command

2. The nload command is directly input and used

The first line is the network card ip and the number of network cards;

Press the left and right keys to switch the network card;

Press q to quit

The upper part is: Incoming is the traffic entering the network card,

The second half is: Outgoing, that is, the traffic going out from this network card,

Curr: Current network card traffic

Avg: Average Traffic

Min: minimum flow

Max: maximum flow

Ttl: total traffic

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325457580&siteId=291194637