目录
知识点1:系统性能监控?
1.1 cpu性能:top命令、uptime命令、w命令
1.1.1? ?什么是load average?
1.1.2? 让top命令按内存使用率来显示进程信息(默认是根据cpu使用率来排序的)
?1.2? 内存 :top命令,free命令
使用top命令来查看内存使用情况
1.2.1? buffer 和 cache的区别
?1.2.2? 什么是交换分区 swap(swappiness)?
查看交换分区:
修改交换分区大小
临时修改:
永久修改交换分区大小(进入 /etc/sysctl.conf文件)
free命令查看内存使用情况
1.3? 磁盘 df -Th,fdisk,iostat
df -Th :查看磁盘使用情况
fdisk -l :查看磁盘分区
iostat:查看磁盘读写的速度
sar :收集、报告或保存系统活动信息。?
1.4 :端口:netstat,ss,lsof,nc
查看自己机器上面使用了哪些端口
查看别人机器上面有哪些端口开放?
nmap:查看整个网段有哪些IP地址是启用的以及开启哪些端口
fping -g 192.168.44.0/24 :查看哪些IP地址没有启用
1.5 网络流量:dstat ,glances
dstat --top-cpu --top-mem --top-io? :查看cpu,内存,io读写,最高的进程
dstat 输出csv文件保存
?glances:一个跨平台的系统监控工具
1.6? 进程:top命令,ps aux命令,jobs命令,fg命令
top命令效果图
?将top命令显示的信息保存到文件里面? top -n 1 >top.txt
jobs命令:查看当前终端有哪些进程在后台运行
fg (foreground)将某个命令从后台调到前台运行
ps aux命令
top命令和ps aux命令区别?
查看消耗cpu最多的前10个进程
查看消耗内存最多的1前10个进程
知识点1:系统性能监控?
1.1 cpu性能:top命令、uptime命令、w命令
?
?
########################################################################################??
1.1.1? ?什么是load average?
查看一下uptime的使用手册,关于load average的解释是这样的
System load averages is the average number of processes that are either in a runnable or ?uninterruptable ?state.??
?A ?process ?in ?a?runnable state is either using the CPU or waiting to use the CPU. ?A process in uninterruptable state is waiting for some I/O access, eg waiting fordisk.
系统平均负载是处于可运行状态和不可中断状态的平均进程数,它反映了cpu在过去的1分钟,5分钟,15分钟的一个繁忙程度,平均负载情况,
?结合三个时间的load average,来分析
1分钟Load>1,5分钟Load<1,15分钟Load<1:短期内繁忙,中长期空闲,初步判断是一个“抖动”,或者是“拥塞前兆” 1分钟Load>1,5分钟Load>1,15分钟Load<1:短期内繁忙,中期内紧张,很可能是一个“拥塞的开始” 1分钟Load>1,5分钟Load>1,15分钟Load>1:短、中、长期都繁忙,系统“正在拥塞” 1分钟Load<1,5分钟Load>1,15分钟Load>1:短期内空闲,中、长期繁忙,不用紧张,系统“拥塞正在好转”
查看cpu信息
[root@docker1 ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 126
model name : Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
stepping : 5
microcode : 0xb0
cpu MHz : 1190.402
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 27
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 arat avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips : 2380.80
clflush size : 64
cache_alignment : 64
address sizes : 45 bits physical, 48 bits virtual
power management:
########################################################################################??
1.1.2? 让top命令按内存使用率来显示进程信息(默认是根据cpu使用率来排序的)
进入top后按M来按内存使用多少来显示
########################################################################################??
?1.2? 内存 :top命令,free命令
使用top命令来查看内存使用情况
top命令会以kb为单位,total显示内存总共有多大,free剩余没有使用的有多少,used已经使用的内存大小,以及buffer和cache的内存大小
avail Mem其实指的是 free 剩余没有使用的空间,以及buff和cache里面没有使用的空间,例如:buff里面的数据已经写到了磁盘,那么buff就空出来了一些空间
1.2.1? buffer 和 cache的区别
buffer和cache都是内存中的一块区域 1.Buffer的核心作用是用来缓冲,缓和冲击。着重于写操作。Buffer是对原始磁盘块的临时存储,也就是用来缓存磁盘的数据,buffer通常不会特别大(20MB 左右)。所以内核就可以把分散的写的操作集中起来,统一优化磁盘的写入。 2.Cache的核心作用是加快取用的速度(与memory相关)。着重于读操作。Cache 是从磁盘读取文件的页缓存,也就是用来缓存从文件读取的数据。这样,下次访问这些文件数据时,就可以直接从内存中快速获取,而不需要再次访问缓慢的磁盘。
总结:buffer是加速数据写入磁盘,cache是用来加速数据从磁盘里面读取的
########################################################################################??
?1.2.2? 什么是交换分区 swap(swappiness)?
交换分区就是在物理内存使用完之后,从磁盘划出一块区域来作为虚拟内存使用
查看交换分区:
[root@docker1 ~]# cat /proc/sys/vm/swappiness
30
?含义:在物理内存只剩下 30%的时候使用交换分区
修改交换分区大小
临时修改:
[root@docker1 ~]# echo 0 >/proc/sys/vm/swappiness
[root@docker1 ~]# cat /proc/sys/vm/swappiness
0
永久修改交换分区大小(进入 /etc/sysctl.conf文件)
sysctl -p :让内核读取sysctl.conf文件
[root@docker1 ~]# vim /etc/sysctl.conf
[root@docker1 ~]# sysctl -p
vm.swappiness = 0
free命令查看内存使用情况
-m :以M的形式显示
-h:以human人类可以读懂的形式显示
[root@docker1 ~]# free
total used free shared buff/cache available
Mem: 995672 529184 98968 35352 367520 280832
Swap: 2097148 5896 2091252
[root@docker1 ~]# free -m
total used free shared buff/cache available
Mem: 972 516 96 34 358 274
Swap: 2047 5 2042
[root@docker1 ~]# free -h
total used free shared buff/cache available
Mem: 972M 516M 96M 34M 358M 274M
Swap: 2.0G 5.8M 2.0G
[root@docker1 ~]#
########################################################################################??
1.3? 磁盘 df -Th,fdisk,iostat
df -Th :查看磁盘使用情况
[root@docker1 ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 475M 0 475M 0% /dev
tmpfs tmpfs 487M 0 487M 0% /dev/shm
tmpfs tmpfs 487M 8.0M 479M 2% /run
tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 17G 8.0G 9.1G 47% /
/dev/sda1 xfs 1014M 138M 877M 14% /boot
tmpfs tmpfs 98M 0 98M 0% /run/user/0
overlay overlay 17G 8.0G 9.1G 47% /var/lib/docker/overlay2/94cb041475d250f0b96b873af048a475d5702774b38ce49ff84d2a5d7f281d34/merged
overlay overlay 17G 8.0G 9.1G 47% /var/lib/docker/overlay2/d860e9489d67bfdab062cff7fcf910bcf46d2ac8ecbe9270a82142029363d5df/merged
fdisk -l :查看磁盘分区
[root@docker1 ~]# fdisk -l
磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000ca43d
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
磁盘 /dev/mapper/centos-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
iostat:查看磁盘读写的速度
[root@docker1 ~]# iostat
Linux 3.10.0-1160.el7.x86_64 (docker1) 2022年09月06日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.31 0.00 0.42 0.01 0.00 99.26
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 2.19 63.97 16.50 962347 248230
scd0 0.00 0.07 0.00 1028 0
dm-0 2.06 63.08 15.88 948901 238814
dm-1 0.15 0.24 0.49 3664 7352
-x :显示很多参数 ,显示扩展的统计信息
[root@docker1 ~]# iostat -x
Linux 3.10.0-1160.el7.x86_64 (docker1) 2022年09月06日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.31 0.00 0.42 0.01 0.00 99.26
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.15 1.50 0.70 63.96 16.68 73.14 0.00 0.61 0.67 0.47 0.29 0.06
scd0 0.00 0.00 0.00 0.00 0.07 0.00 114.22 0.00 2.11 2.11 0.00 1.67 0.00
dm-0 0.00 0.00 1.34 0.73 63.07 16.06 76.12 0.00 0.66 0.73 0.52 0.30 0.06
dm-1 0.00 0.00 0.03 0.12 0.24 0.49 9.62 0.00 0.73 0.28 0.83 0.07 0.00
iostat -x 1 2 :每隔1秒统计一次输出出来
[root@docker1 ~]# iostat -x 1 2
Linux 3.10.0-1160.el7.x86_64 (docker1) 2022年09月06日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.31 0.00 0.41 0.01 0.00 99.27
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.15 1.45 0.69 61.73 16.22 72.96 0.00 0.61 0.67 0.47 0.29 0.06
scd0 0.00 0.00 0.00 0.00 0.07 0.00 114.22 0.00 2.11 2.11 0.00 1.67 0.00
dm-0 0.00 0.00 1.30 0.72 60.86 15.62 75.90 0.00 0.66 0.74 0.52 0.30 0.06
dm-1 0.00 0.00 0.03 0.12 0.24 0.47 9.61 0.00 0.73 0.30 0.83 0.08 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
0.00 0.00 0.00 0.00 0.00 100.00
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
scd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
[root@docker1 ~]#
sar :收集、报告或保存系统活动信息。?
[root@docker1 ~]# sar -d 1 2
Linux 3.10.0-1160.el7.x86_64 (docker1) 2022年09月06日 _x86_64_ (1 CPU)
16时49分04秒 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
16时49分05秒 dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分05秒 dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分05秒 dev253-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分05秒 dev253-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分05秒 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
16时49分06秒 dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分06秒 dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分06秒 dev253-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
16时49分06秒 dev253-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
平均时间: dev8-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: dev253-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: dev253-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
[root@docker1 ~]#
[root@docker1 ~]# sar -b
Linux 3.10.0-1160.el7.x86_64 (docker1) 2022年09月06日 _x86_64_ (1 CPU)
16时40分01秒 tps rtps wtps bread/s bwrtn/s
16时50分01秒 0.23 0.07 0.15 3.45 1.87
平均时间: 0.23 0.07 0.15 3.45 1.87
[root@docker1 ~]#
########################################################################################?
1.4 :端口:netstat,ss,lsof,nc
查看自己机器上面使用了哪些端口
[root@docker1 ~]# netstat -anplut
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 675/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2358/docker-proxy
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1042/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1191/master
tcp 0 0 192.168.44.201:45506 202.202.1.140:80 TIME_WAIT -
tcp 0 0 192.168.44.201:45508 202.202.1.140:80 TIME_WAIT -
tcp 0 0 192.168.44.201:22 192.168.44.1:58394 ESTABLISHED 3017/sshd: root@pts
tcp 0 0 192.168.44.201:22 192.168.44.1:55063 ESTABLISHED 3367/sshd: root@pts
tcp6 0 0 :::111 :::* LISTEN 675/rpcbind
tcp6 0 0 :::80 :::* LISTEN 2365/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 1042/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1191/master
udp 0 0 0.0.0.0:111 0.0.0.0:* 675/rpcbind
udp 0 0 127.0.0.1:323 0.0.0.0:* 687/chronyd
udp 0 0 0.0.0.0:848 0.0.0.0:* 675/rpcbind
udp6 0 0 :::111 :::* 675/rpcbind
udp6 0 0 ::1:323 :::* 687/chronyd
udp6 0 0 :::848 :::* 675/rpcbind
[root@docker1 ~]# ss -anplut
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:111 *:* users:(("rpcbind",pid=675,fd=6))
udp UNCONN 0 0 127.0.0.1:323 *:* users:(("chronyd",pid=687,fd=5))
udp UNCONN 0 0 *:848 *:* users:(("rpcbind",pid=675,fd=7))
udp UNCONN 0 0 [::]:111 [::]:* users:(("rpcbind",pid=675,fd=9))
udp UNCONN 0 0 [::1]:323 [::]:* users:(("chronyd",pid=687,fd=6))
udp UNCONN 0 0 [::]:848 [::]:* users:(("rpcbind",pid=675,fd=10))
tcp LISTEN 0 128 *:111 *:* users:(("rpcbind",pid=675,fd=8))
tcp LISTEN 0 128 *:80 *:* users:(("docker-proxy",pid=2358,fd=4))
tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=1042,fd=3))
tcp LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=1191,fd=13))
tcp LISTEN 0 128 [::]:111 [::]:* users:(("rpcbind",pid=675,fd=11))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("docker-proxy",pid=2365,fd=4))
tcp LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1042,fd=4))
tcp LISTEN 0 100 [::1]:25 [::]:* users:(("master",pid=1191,fd=14))
[root@docker1 ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 2358 root 4u IPv4 43862 0t0 TCP *:http (LISTEN)
docker-pr 2365 root 4u IPv6 43903 0t0 TCP *:http (LISTEN)
查看别人机器上面有哪些端口开放?
查看别人机器上面有哪些端口开放
nc -z 114.114.114.114 53
-z 选项:不发送数据包
53 :查看53号端口是否开放
echo $? 查看返回值,如果返回值为0则端口是开放的,非0则没有开放
-w选项:只等待1秒钟
[root@docker1 ~]# nc -z 114.114.114.114 53
[root@docker1 ~]# echo $?
0
[root@docker1 ~]# nc -z 114.114.114.114 80
[root@docker1 ~]# echo $?
1
[root@docker1 ~]# nc -z -w 1 114.114.114.114 22
[root@docker1 ~]# echo $?
1
nmap:查看整个网段有哪些IP地址是启用的以及开启哪些端口
[root@docker1 ~]# nmap 192.168.44.0/24
Starting Nmap 6.40 ( http://nmap.org ) at 2022-09-06 17:00 CST
Nmap scan report for 192.168.44.1
Host is up (0.00076s latency).
Not shown: 999 filtered ports
PORT STATE SERVICE
9091/tcp open xmltec-xmlmail
MAC Address: 00:50:56:C0:00:08 (VMware)
Nmap scan report for 192.168.44.2
Host is up (0.00029s latency).
All 1000 scanned ports on 192.168.44.2 are closed
MAC Address: 00:50:56:EF:D1:5C (VMware)
Nmap scan report for 192.168.44.254
Host is up (-0.10s latency).
All 1000 scanned ports on 192.168.44.254 are filtered
MAC Address: 00:50:56:E0:49:C8 (VMware)
Nmap scan report for 192.168.44.201
Host is up (0.0000070s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
Nmap done: 256 IP addresses (4 hosts up) scanned in 93.27 seconds
fping -g 192.168.44.0/24 :查看哪些IP地址没有启用
^C192.168.44.1 is unreachable
192.168.44.3 is unreachable
192.168.44.4 is unreachable
192.168.44.5 is unreachable
192.168.44.6 is unreachable
192.168.44.7 is unreachable
192.168.44.8 is unreachable
192.168.44.9 is unreachable
192.168.44.10 is unreachable
192.168.44.11 is unreachable
192.168.44.12 is unreachable
192.168.44.13 is unreachable
192.168.44.14 is unreachable
192.168.44.15 is unreachable
192.168.44.16 is unreachable
192.168.44.17 is unreachable
192.168.44.18 is unreachable
192.168.44.19 is unreachable
192.168.44.20 is unreachable
192.168.44.21 is unreachable
192.168.44.22 is unreachable
192.168.44.23 is unreachable
192.168.44.24 is unreachable
192.168.44.25 is unreachable
192.168.44.26 is unreachable
192.168.44.27 is unreachable
192.168.44.28 is unreachable
192.168.44.29 is unreachable
192.168.44.30 is unreachable
192.168.44.31 is unreachable
192.168.44.32 is unreachable
192.168.44.33 is unreachable
192.168.44.34 is unreachable
192.168.44.35 is unreachable
192.168.44.36 is unreachable
192.168.44.37 is unreachable
192.168.44.38 is unreachable
192.168.44.39 is unreachable
192.168.44.40 is unreachable
192.168.44.41 is unreachable
192.168.44.42 is unreachable
192.168.44.43 is unreachable
192.168.44.44 is unreachable
192.168.44.45 is unreachable
192.168.44.46 is unreachable
192.168.44.47 is unreachable
192.168.44.48 is unreachable
192.168.44.49 is unreachable
192.168.44.50 is unreachable
192.168.44.51 is unreachable
192.168.44.52 is unreachable
192.168.44.53 is unreachable
192.168.44.54 is unreachable
192.168.44.55 is unreachable
192.168.44.56 is unreachable
192.168.44.57 is unreachable
192.168.44.58 is unreachable
192.168.44.59 is unreachable
192.168.44.60 is unreachable
192.168.44.61 is unreachable
192.168.44.62 is unreachable
192.168.44.63 is unreachable
192.168.44.64 is unreachable
192.168.44.65 is unreachable
192.168.44.66 is unreachable
192.168.44.67 is unreachable
192.168.44.68 is unreachable
192.168.44.69 is unreachable
192.168.44.70 is unreachable
192.168.44.71 is unreachable
192.168.44.72 is unreachable
192.168.44.73 is unreachable
192.168.44.74 is unreachable
192.168.44.75 is unreachable
192.168.44.76 is unreachable
192.168.44.77 is unreachable
192.168.44.78 is unreachable
192.168.44.79 is unreachable
192.168.44.80 is unreachable
192.168.44.81 is unreachable
192.168.44.82 is unreachable
192.168.44.83 is unreachable
192.168.44.84 is unreachable
192.168.44.85 is unreachable
192.168.44.86 is unreachable
192.168.44.87 is unreachable
192.168.44.88 is unreachable
192.168.44.89 is unreachable
192.168.44.90 is unreachable
192.168.44.91 is unreachable
192.168.44.92 is unreachable
192.168.44.93 is unreachable
192.168.44.94 is unreachable
192.168.44.95 is unreachable
192.168.44.96 is unreachable
192.168.44.97 is unreachable
192.168.44.98 is unreachable
192.168.44.99 is unreachable
192.168.44.100 is unreachable
192.168.44.101 is unreachable
192.168.44.102 is unreachable
192.168.44.103 is unreachable
192.168.44.104 is unreachable
192.168.44.105 is unreachable
192.168.44.106 is unreachable
192.168.44.107 is unreachable
192.168.44.108 is unreachable
192.168.44.109 is unreachable
192.168.44.110 is unreachable
192.168.44.111 is unreachable
192.168.44.112 is unreachable
192.168.44.113 is unreachable
192.168.44.114 is unreachable
192.168.44.115 is unreachable
192.168.44.116 is unreachable
192.168.44.117 is unreachable
192.168.44.118 is unreachable
192.168.44.119 is unreachable
192.168.44.120 is unreachable
192.168.44.121 is unreachable
192.168.44.122 is unreachable
192.168.44.123 is unreachable
192.168.44.124 is unreachable
192.168.44.125 is unreachable
192.168.44.126 is unreachable
192.168.44.127 is unreachable
192.168.44.128 is unreachable
192.168.44.129 is unreachable
192.168.44.130 is unreachable
192.168.44.131 is unreachable
192.168.44.132 is unreachable
192.168.44.133 is unreachable
192.168.44.134 is unreachable
192.168.44.135 is unreachable
192.168.44.136 is unreachable
192.168.44.137 is unreachable
192.168.44.138 is unreachable
192.168.44.139 is unreachable
192.168.44.140 is unreachable
192.168.44.141 is unreachable
192.168.44.142 is unreachable
192.168.44.143 is unreachable
192.168.44.144 is unreachable
192.168.44.145 is unreachable
192.168.44.146 is unreachable
192.168.44.147 is unreachable
192.168.44.148 is unreachable
192.168.44.149 is unreachable
192.168.44.150 is unreachable
192.168.44.151 is unreachable
192.168.44.152 is unreachable
192.168.44.153 is unreachable
192.168.44.154 is unreachable
192.168.44.155 is unreachable
192.168.44.156 is unreachable
192.168.44.157 is unreachable
192.168.44.158 is unreachable
192.168.44.159 is unreachable
192.168.44.160 is unreachable
192.168.44.161 is unreachable
192.168.44.162 is unreachable
192.168.44.163 is unreachable
192.168.44.164 is unreachable
192.168.44.165 is unreachable
192.168.44.166 is unreachable
192.168.44.167 is unreachable
192.168.44.168 is unreachable
192.168.44.169 is unreachable
192.168.44.170 is unreachable
192.168.44.171 is unreachable
192.168.44.172 is unreachable
192.168.44.173 is unreachable
192.168.44.174 is unreachable
192.168.44.175 is unreachable
192.168.44.176 is unreachable
192.168.44.177 is unreachable
192.168.44.178 is unreachable
192.168.44.179 is unreachable
192.168.44.180 is unreachable
192.168.44.181 is unreachable
192.168.44.182 is unreachable
192.168.44.183 is unreachable
192.168.44.184 is unreachable
192.168.44.185 is unreachable
192.168.44.186 is unreachable
192.168.44.187 is unreachable
192.168.44.188 is unreachable
192.168.44.189 is unreachable
192.168.44.190 is unreachable
192.168.44.191 is unreachable
192.168.44.192 is unreachable
192.168.44.193 is unreachable
192.168.44.194 is unreachable
192.168.44.195 is unreachable
192.168.44.196 is unreachable
192.168.44.197 is unreachable
192.168.44.198 is unreachable
192.168.44.199 is unreachable
192.168.44.200 is unreachable
192.168.44.202 is unreachable
192.168.44.203 is unreachable
192.168.44.204 is unreachable
192.168.44.205 is unreachable
192.168.44.206 is unreachable
192.168.44.207 is unreachable
192.168.44.208 is unreachable
192.168.44.209 is unreachable
192.168.44.210 is unreachable
192.168.44.211 is unreachable
192.168.44.212 is unreachable
192.168.44.213 is unreachable
192.168.44.214 is unreachable
192.168.44.215 is unreachable
192.168.44.216 is unreachable
192.168.44.217 is unreachable
192.168.44.218 is unreachable
192.168.44.219 is unreachable
192.168.44.220 is unreachable
192.168.44.221 is unreachable
192.168.44.222 is unreachable
192.168.44.223 is unreachable
192.168.44.224 is unreachable
192.168.44.225 is unreachable
192.168.44.226 is unreachable
192.168.44.227 is unreachable
192.168.44.228 is unreachable
192.168.44.229 is unreachable
192.168.44.230 is unreachable
192.168.44.231 is unreachable
192.168.44.232 is unreachable
192.168.44.233 is unreachable
192.168.44.234 is unreachable
192.168.44.235 is unreachable
192.168.44.236 is unreachable
192.168.44.237 is unreachable
192.168.44.238 is unreachable
192.168.44.239 is unreachable
192.168.44.240 is unreachable
192.168.44.241 is unreachable
192.168.44.242 is unreachable
192.168.44.243 is unreachable
192.168.44.244 is unreachable
192.168.44.245 is unreachable
192.168.44.246 is unreachable
192.168.44.247 is unreachable
192.168.44.248 is unreachable
192.168.44.249 is unreachable
192.168.44.250 is unreachable
192.168.44.251 is unreachable
192.168.44.252 is unreachable
192.168.44.253 is unreachable
192.168.44.254 is unreachable
########################################################################################?
1.5 网络流量:dstat ,glances
dstat:用于生成系统资源统计的通用工具?
dstat --top-cpu --top-mem --top-io? :查看cpu,内存,io读写,最高的进程
?
dstat 输出csv文件保存
[root@docker1 ~]# cat dstat_monitor.csv
"Dstat 0.7.2 CSV output"
"Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","docker1",,,,"User:","root"
"Cmdline:","dstat -am --output /root/dstat_monitor.csv",,,,"Date:","06 Sep 2022 18:36:24 CST"
"total cpu usage",,,,,,"dsk/total",,"net/total",,"paging",,"system",,"memory usage",,,
"usr","sys","idl","wai","hiq","siq","read","writ","recv","send","in","out","int","csw","used","buff","cach","free"
0.359,0.336,99.271,0.008,0.0,0.026,48397.530,20792.628,0.0,0.0,69.032,333.897,68.080,131.393,595779584.0,28672.0,252149760.0,171610112.0,
0.0,0.0,100.0,0.0,0.0,0.0,0.0,0.0,120.0,898.0,0.0,0.0,53.0,108.0,595775488.0,28672.0,252153856.0,171610112.0,
0.0,0.0,100.0,0.0,0.0,0.0,0.0,0.0,120.0,346.0,0.0,0.0,56.0,100.0,595775488.0,28672.0,252153856.0,171610112.0,
0.0,0.0,100.0,0.0,0.0,0.0,0.0,0.0,120.0,346.0,0.0,0.0,54.0,104.0,595775488.0,28672.0,252153856.0,171610112.0,
[root@docker1 ~]# dstat -am --output /root/dstat_monitor.csv
?glances:一个跨平台的系统监控工具
?########################################################################################?
1.6? 进程:top命令,ps aux命令,jobs命令,fg命令
top命令效果图
top命令默认1.5秒迭代更新一次
?将top命令显示的信息保存到文件里面? top -n 1 >top.txt
-n 1? :top命令迭代一次,output到top.txt文件里面
[root@docker1 ~]# top -n 1 >top.txt
[root@docker1 ~]# cat top.txt
top - 18:40:56 up 6:20, 3 users, load average: 0.00, 0.01, 0.05
Tasks: 124 total, 1 running, 123 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 995672 total, 169860 free, 521348 used, 304464 buff/cache
KiB Swap: 2097148 total, 2091508 free, 5640 used. 282780 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 128272 5712 2960 S 0.0 0.6 0:02.36 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
6 root 20 0 0 0 0 S 0.0 0.0 0:01.78 ksoftirqd/0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:01.44 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 0:00.26 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
15 root 20 0 0 0 0 S 0.0 0.0 0:00.02 khungtaskd
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
[root@docker1 ~]#
jobs命令:查看当前终端有哪些进程在后台运行
在命令后面使用 & 可以将一个进程放到后台运行
[root@docker1 ~]# vim wang.txt &
[1] 3903
[root@docker1 ~]# vim liu.txt &
[2] 3904
[1]+ 已停止 vim wang.txt
[root@docker1 ~]# vim li.txt &
[3] 3905
[2]+ 已停止 vim liu.txt
[root@docker1 ~]# jobs
[1] 已停止 vim wang.txt
[2]- 已停止 vim liu.txt
[3]+ 已停止 vim li.txt
[root@docker1 ~]# echo "hello" &
[4] 3907
[root@docker1 ~]# hello
jobs
[1] 已停止 vim wang.txt
[2]- 已停止 vim liu.txt
[3]+ 已停止 vim li.txt
[4] 完成 echo "hello"
fg (foreground)将某个命令从后台调到前台运行
[root@docker1 ~]# fg 2
vim liu.txt
ps aux命令
top命令和ps aux命令区别?
top命令会迭代显示进程信息,ps aux是显示的一瞬间的进程信息
- a:显示一个终端所有的进程
- u:显示进程的归属用户及内存使用情况
- x:显示没有关联控制终端的进程
[root@docker1 ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.5 128272 5804 ? Ss 15:29 0:02 /usr/lib/systemd/systemd --switched-roo
root 2 0.0 0.0 0 0 ? S 15:29 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< 15:29 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S 15:29 0:01 [ksoftirqd/0]
root 7 0.0 0.0 0 0 ? S 15:29 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S 15:29 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? R 15:29 0:01 [rcu_sched]
root 10 0.0 0.0 0 0 ? S< 15:29 0:00 [lru-add-drain]
root 11 0.0 0.0 0 0 ? S 15:29 0:00 [watchdog/0]
root 13 0.0 0.0 0 0 ? S 15:29 0:00 [kdevtmpfs]
root 14 0.0 0.0 0 0 ? S< 15:29 0:00 [netns]
root 15 0.0 0.0 0 0 ? S 15:29 0:00 [khungtaskd]
root 16 0.0 0.0 0 0 ? S< 15:29 0:00 [writeback]
root 17 0.0 0.0 0 0 ? S< 15:29 0:00 [kintegrityd]
root 18 0.0 0.0 0 0 ? S< 15:29 0:00 [bioset]
root 19 0.0 0.0 0 0 ? S< 15:29 0:00 [bioset]
root 20 0.0 0.0 0 0 ? S< 15:29 0:00 [bioset]
root 21 0.0 0.0 0 0 ? S< 15:29 0:00 [kblockd]
root 22 0.0 0.0 0 0 ? S< 15:29 0:00 [md]
root 23 0.0 0.0 0 0 ? S< 15:29 0:00 [edac-poller]
root 24 0.0 0.0 0 0 ? S< 15:29 0:00 [watchdogd]
root 30 0.0 0.0 0 0 ? S 15:29 0:00 [kswapd0]
root 31 0.0 0.0 0 0 ? SN 15:29 0:00 [ksmd]
root 32 0.0 0.0 0 0 ? SN 15:29 0:00 [khugepaged]
root 33 0.0 0.0 0 0 ? S< 15:29 0:00 [crypto]
查看消耗cpu最多的前10个进程
[root@docker1 ~]# ps aux |tail -n +2 |sort -k 3 -rn | head
root 678 0.1 0.4 273196 4268 ? Ssl 15:29 0:38 /usr/bin/vmtoolsd
rpc 675 0.0 0.1 69256 1004 ? Ss 15:29 0:00 /sbin/rpcbind -w
root 95 0.0 0.0 0 0 ? S 15:29 0:00 [kauditd]
root 9 0.0 0.0 0 0 ? R 15:29 0:01 [rcu_sched]
root 8 0.0 0.0 0 0 ? S 15:29 0:00 [rcu_bh]
root 730 0.0 0.7 475036 7296 ? Ssl 15:29 0:02 /usr/sbin/NetworkManager --no-daemon
root 713 0.0 0.2 96572 2348 ? Ss 15:29 0:00 login -- root
root 711 0.0 0.1 126416 1704 ? Ss 15:29 0:00 /usr/sbin/crond -n
root 7 0.0 0.0 0 0 ? S 15:29 0:00 [migration/0]
root 689 0.0 0.1 195204 1152 ? Ssl 15:29 0:00 /usr/sbin/gssproxy -D
查看消耗内存最多的1前10个进程
[root@docker1 ~]# ps aux |tail -n +2 |sort -k 4 -rn | head
polkitd 2385 0.0 7.8 1074544 77856 ? Ssl 16:33 0:10 mysqld --default-authentication-plugin=mysql_native_password
33 2585 0.0 5.9 362492 59648 ? S 16:33 0:01 apache2 -DFOREGROUND
root 1106 0.0 4.6 1341788 46676 ? Ssl 15:29 0:09 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
33 2583 0.0 4.0 308440 40372 ? S 16:33 0:01 apache2 -DFOREGROUND
33 2587 0.0 3.6 343016 36600 ? S 16:33 0:00 apache2 -DFOREGROUND
33 2681 0.0 3.5 308896 35148 ? S 16:38 0:01 apache2 -DFOREGROUND
33 2762 0.0 3.3 340740 33256 ? S 17:10 0:00 apache2 -DFOREGROUND
33 2767 0.0 3.1 308604 31236 ? S 17:10 0:00 apache2 -DFOREGROUND
root 1049 0.0 2.8 1026176 27888 ? Ssl 15:29 0:12 /usr/bin/containerd
33 2780 0.0 2.8 308552 28500 ? S 17:12 0:00 apache2 -DFOREGROUND
|