CPU 相干
w
:查看以后零碎的负载
[root@xiaojw ~]# w 14:02:34 up 272 days, 17:33, 1 user, load average: 0.00, 0.03, 0.01USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot pts/0 183.237.175.89 14:02 2.00s 0.26s 0.00s w# 14:02:34 up 272 days, 17:33, 1 user, load average: 0.00, 0.03, 0.01# 工夫 零碎运行工夫 登录用户数 均匀负载(重要!):1分钟内,5分钟内,15分钟内# 均匀负载,值越大,阐明服务器压力越大;这个值只有不超过服务器的CPU数量即可
cat /proc/cupinfo
:查看 CPU 相干的根本信息
[root@localhost ~]# cat /proc/cpuinfoprocessor : 0vendor_id : GenuineIntelcpu family : 6model : 158model name : Intel(R) Core(TM) i5-9400 CPU @ 2.90GHzstepping : 13cpu MHz : 2904.002cache size : 9216 KBphysical id : 0siblings : 1core id : 0cpu cores : 1apicid : 0initial apicid : 0fpu : yesfpu_exception : yescpuid level : 22wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single fsgsbase avx2 invpcid rdseed clflushopt flush_l1dbogomips : 5808.00clflush size : 64cache_alignment : 64address sizes : 39 bits physical, 48 bits virtualpower management:
top
:显示过程所占的系统资源
top - 07:49:20 up 5 min, 1 user, load average: 0.00, 0.01, 0.01 # 零碎负载Tasks: 93 total, 1 running, 92 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# CPU 应用状况KiB Mem : 2914272 total, 2560228 free, 222864 used, 131180 buff/cache# 内存应用状况KiB Swap: 3145724 total, 3145724 free, 0 used. 2542568 avail Mem# 替换分区应用状况 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 128012 6596 4140 S 0.0 0.2 0:00.86 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 5 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u2:0 6 root 20 0 0 0 0 S 0.0 0.0 0:00.02 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:00.25 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.00 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.00 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# 按 shift + m:依照内存应用大小排序# 按 1:列出所有核CPU的应用状态# 按 q:退出
测试零碎负载,参考命令:
{ yes > /dev/null & } && sleep 30 && ps -ef | grep yes | awk '{print $2}' | xargs kill
for i in $( seq 0 $(($(cat /proc/cpuinfo | grep processor | wc -l)-1)) );do taskset -c $i yes > /dev/null & done && sleep 30 && ps -ef | grep yes | awk '{print $2}' | xargs kill
罕用形式:
top -p 过程号
:只察看一个过程的状态
$ top -p 732top - 22:35:00 up 42 days, 11:16, 28 users, load average: 0.00, 0.01, 0.05Tasks: 0 total, 0 running, 0 sleeping, 0 stopped, 0 zombie%Cpu(s): 0.2 us, 0.5 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stKiB Mem : 3881920 total, 702676 free, 302076 used, 2877168 buff/cacheKiB Swap: 0 total, 0 free, 0 used. 1184568 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
top -p 过程号 -d 间隔时间 -n 刷新次数
- 其余:
<!---->
-b
:批处理模式top -bn1
:非动静打印系统资源的应用状况
对于内存
free
:查看内存应用情况
[root@localhost ~]# free -m total used free shared buff/cache available # 内存总大小 理论应用内存大小 闲暇内存大小 共享内存 缓冲/缓存 可应用内存Mem: 2845 211 2506 8 127 2488Swap: 3071 0 3071[root@localhost ~]# free -h # 更便于浏览 total used free shared buff/cache availableMem: 2.8G 211M 2.4G 8.5M 127M 2.4GSwap: 3.0G 0B 3.0G
对于 IO
iostat
(须要装置:yum install sysstat
)
-c
:只看 CPU-d
:只看硬盘
[root@localhost ~]# iostat 1 # 1秒刷新一次Linux 3.10.0-1160.el7.x86_64 (localhost.localdomain) 2020年12月10日 _x86_64_ (1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle 0.26 0.00 0.32 0.05 0.00 99.36Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtnsda 5.06 181.55 18.64 244793 25135dm-0 3.43 157.87 17.12 212867 23087dm-1 0.07 1.63 0.00 2204 0
iftop
:相似于top的实时流量监控工具(须要装置能力应用)