w command
The w command is used to display a list of users who have logged in to the system and to display the commands that the user is executing. Execute this command to know who are the users who are currently logged in to the system and the programs they are executing. Execute the w command alone to display all users. You can also specify a user name to display only the relevant information of a certain user.
vmstat command
The meaning of the vmstat command is to display the virtual memory status ("Viryual Memor Statics"), but it can report the overall operating status of the system such as processes, memory, I/O, etc.
[root@pantinglinux]# vmstat 3 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 3 0 0 76280 136468 569488 0 0 2 3 1 8 0 0 100 0 0 0 0 0 76140 136468 569520 0 0 0 0 124 285 0 0 100 0 0 0 0 0 76140 136476 569516 0 0 0 4 120 278 0 0 100 0 0 0 0 0 76140 136476 569520 0 0 0 0 103 260 0 0 100 0 0 0 0 0 76140 136476 569520 0 0 0 0 104 264 0 0 99 0 0 0 0 0 76140 136476 569520 0 0 0 0 106 262 0 0 100 0 0 0 0 0 76140 136476 569520 0 0 0 0 106 265 0 0 100 0 0
Procs (process)
r: The number of processes in the run queue, this value can also determine whether to increase the CPU. (long term greater than 1)
b: The number of processes waiting for IO.
Memory
swpd: Use virtual memory size. If the value of swpd is not 0, but the value of SI and SO is 0 for a long time, this situation will not affect the system performance.
free: Free physical memory size.
buff: The amount of memory to use as a buffer.
cache: The size of the memory used for the cache. If the value of the cache is large, it means that there are many files in the cache. If the frequently accessed files can be located in the cache, then the read IO bi of the disk will be very small.
Swap
si: The size written from the swap area to the memory per second, transferred into the memory from the disk.
so: The size of memory written to the swap area per second, transferred from memory to disk.
Note: When the memory is sufficient, the two values are both 0. If the two values are greater than 0 for a long time, the system performance will be affected, and the disk IO and CPU resources will be consumed. When some friends see that the free memory (free) is very small or close to 0, they think that the memory is not enough. They can't just look at this, but also combine si and so. If there is very little free, but si and so are also very small. (most of the time it is 0), then don't worry, the system performance will not be affected at this time.
IO (now the Linux version has a block size of 1kb)
bi: number of blocks read per second
bo: The number of blocks written per second Note: When reading and writing random disks, the larger these two values are (such as exceeding 1024k), the larger the value of CPU waiting for IO can be seen.
system
in: Interrupts per second, including clock interrupts.
cs: Context switches per second.
Note: The larger the above 2 values, the more CPU time you will see consumed by the kernel.
CPU (in percent)
us: User process execution time percentage (user time) When the value of us is relatively high, it means that the user process consumes a lot of CPU time, but if the usage exceeds 50% for a long time, then we should consider optimizing the program algorithm or accelerating it.
sy: Percentage of kernel system process execution time (system time)
When the value of sy is high, it means that the system kernel consumes a lot of CPU resources, which is not a benign performance, and we should check the reason.
wa: When the value of the IO waiting time percentage wa is high, it indicates that the IO waiting is serious, which may be caused by a large number of random accesses on the disk, or there may be a bottleneck (block operation) on the disk.
id: idle time percentage
TOP command
Options
-b: operate in batch mode;
-c: Display the complete governance command;
-d: screen refresh interval;
-I: ignore the failure process;
-s: secret mode;
-S: accumulation mode;
-i<time>: set the interval time;
-u<username>: Specify the username;
-p<process number>: specify the process;
-n<number of times>: The number of times of loop display.
top interactive command
Some interactive commands that can be used during the execution of the top command. These commands are all single-letter, and some of them may be blocked if the -s option is used on the command line.
h: Display the help screen, giving some brief command summary descriptions;
k: terminate a process;
i: Ignore idle and zombie processes, this is a switch command;
q: exit the program;
r: rearrange the priority level of a process;
S: switch to accumulation mode;
s: Change the delay time between two refreshes (unit is s), if there is a decimal, convert it to ms. If you enter a value of 0, the system will continue to refresh, and the default value is 5s;
f or F: add or remove items from the current display;
o or O: Change the order of displayed items;
l: Switch to display the average load and startup time information;
m: switch to display memory information;
t: switch to display process and CPU status information;
c: switch to display the command name and the full command line;
M: Sort by resident memory size;
P: Sort according to the percentage of CPU usage;
T: Sort by time/cumulative time;
w: Write the current settings to the ~/.toprc file.
example
top - 09:44:56 up 16 days, 21:23, 1 user, load average: 9.59, 4.75, 1.92
Tasks: 145 total, 2 running, 143 sleeping, 0 stopped, 0 zombie
Cpu (s): 99.8% us, 0.1% sy, 0.0% ni, 0.2% 0.0% wa, 0.0% hi, 0.0% si, 0.0% st
Mem: 4147888k total, 2493092k used, 1654796k 158188k buffers
Swap: 5144568k total, 56k used, 5144512k free, 2013180k cached
top - 09:44:56 [current system time],
16 days[The system has been running for 16 days],
1 user[users currently logged in]
load average: 9.59, 4.75, 1.92 [system load, the average length of the task queue]
Tasks: 145 total[total number of processes],
2 running[number of processes running],
143 sleeping[Number of processes sleeping],
0 stopped[number of processes stopped],
0 zombie[number of frozen processes],
Cpu(s): 99.8%us[% of CPU occupied by user space],
0.1%sy [CPU percentage occupied by kernel space],
0.0%ni[The percentage of CPU occupied by processes whose priority has been changed in the user process space],
0.2%id[Percentage of idle CPU], 0.0%wa[Percentage of CPU time waiting for input and output],
0.0%hi[],
0.0%st[],
Mem: 4147888k total[total physical memory],
2493092k used[total physical memory used],
1654796k free[total free memory],
158188k buffers [amount of memory used as kernel cache]
Swap: 5144568k total[total swap area],
56k used[total swap used],
5144512k free[total free swap area],
2013180k cached[total buffered swap area],
sar command
System monitoring
[root@pantinglinux]# yum install -y sysstat
sar will capture the status of the system every 10 minutes and save the log file to the directory /var/log/sa
saxx ends with a date. Keep data for 1 month.
[root@pantinglinux]# ls/var/log/sa
sa01 sa06 sa11 sa16 sa21 sa27 sar01 sar06 sar11 sar16 sar21 sar27
sa02 sa07 sa12 sa17 sa22 sa28 sar02 sar07 sar12 sar17 sar22 sar28
sa03 sa08 sa13 sa18 sa23 sa29 sar03 sar08 sar13 sar18 sar24 sar29
sa04 sa09 sa14 sa19 sa25 sa30 sar04 sar09 sar14 sar19 sar25 sar30
sa05 sa10 sa15 sa20 sa26 sa31 sar05 sar10 sar15 sar20 sar26 sar31
Check the usage of network card traffic on the 22nd:
[root @ pantinglinux] # sar -n DEV -f / var / log / sa / sa22
sar -n DEV View network card traffic
sar -n DEV 1 2 display every 1 second, display 2 times
[root @ pantinglinux] # sar -n DEV 1 2
Linux 3.10.0-693.2.2.el7.x86_64 (centos7.4) January 23, 2018_x86_64_ (1 CPU)
00时09分15秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
00:09:16 eth0 2.00 1.00 0.13 0.10 0.00 0.00 0.00
00:09:16 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
00时09分16秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
00:09:17 eth0 1.00 1.00 0.06 0.18 0.00 0.00 0.00
00:09:17 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Average time: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average time: eth0 1.50 1.00 0.10 0.14 0.00 0.00 0.00
Average time: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
IFACE two network cards eth0 and lo
rxpck/s (received package) indicates how many packets are received
txpck/s indicates the number of packets sent
A few thousand KB/S of received data packets is considered normal, and tens of thousands of KB/S may be attacked.
rxkB/s The amount of data received in KB
txkB/s The amount of data sent in KB
sar -q 1 10 View system load, display every 1 second, display 10 times
[root@pantinglinux]# sar -q 1 10
Linux 3.10.0-693.2.2.el7.x86_64 (centos7.4) January 23, 2018_x86_64_ (1 CPU)
00:40:40 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
00:40:41 0 299 0.00 0.01 0.05 0
00:40:42 0 299 0.00 0.01 0.05 0
00:40:43 0 299 0.00 0.01 0.05 0
00:40:44 0 299 0.00 0.01 0.05 0
00:40:45 0 299 0.00 0.01 0.05 0
00:40:46 0 299 0.00 0.01 0.05 0
00:40:47 0 299 0.00 0.01 0.05 0
00:40:48 0 299 0.00 0.01 0.05 0
00:40:49 0 299 0.00 0.01 0.05 0
00:40:50 0 299 0.00 0.01 0.05 0
Average time: 0 299 0.00 0.01 0.05 0
View system load on a specified date:
[root@pantinglinux]# sar -q -f/var/log/sa/sa23
Linux 3.10.0-693.2.2.el7.x86_64 (centos7.4) January 23, 2018_x86_64_ (1 CPU)
00:00:01 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
00:10:01 2 299 0.00 0.05 0.07 0
00:20:01 2 299 0.01 0.02 0.05 0
00:30:01 2 301 0.00 0.01 0.05 0
00:40:01 2 299 0.00 0.01 0.05 0
Average time: 2 300 0.00 0.02 0.06 0
View disk usage
sar -b 1 5 display 1 time per second, display 5 times
[root@pantinglinux]# sar -b 1 5
Linux 3.10.0-693.2.2.el7.x86_64 (centos7.4) January 23, 2018_x86_64_ (1 CPU)
00:44:03 tps rtps wtps bread/s bwrtn/s
00:44:04 0.00 0.00 0.00 0.00 0.00
00:44:05 0.00 0.00 0.00 0.00 0.00
00:44:06 0.00 0.00 0.00 0.00 0.00
00:44:07 0.00 0.00 0.00 0.00 0.00
00:44:08 0.00 0.00 0.00 0.00 0.00
Average time: 0.00 0.00 0.00 0.00 0.00
sa17&&sar17 difference:
ls / var / log / sa / sa17
Sa17 is a binary file, it cannot be cat, it can only be viewed with sar -n DEV -f /var/log/sa/sa17
ls /var/log/sa/sar17, sar17 can be cat
nload command
Install epel-release
[root@pantinglinux]# yum install -y epel-release
install noload
[root@pantinglinux]# yum install -y nload
[root@pantinglinux]# nload
Device eth0 [192.168.1.81] (1/2):
================================================================================================
Incoming:
Curr: 1.02 kBit/s
Avg: 2.45 kBit/s
Min: 1.02 kBit/s
Max: 7.89 kBit/s
Ttl: 31.20 MByte
Outgoing:
Curr: 8.08 kBit/s
Avg: 8.61 kBit/s
Min: 4.46 kBit/s
Max: 13.66 kBit/s
Ttl: 17.06 MByte
Two network cards, press the up and down keys to switch the network card