1. 程式人生 > >10.1 使用w查看系統負載 10.2 vmstat命令 10.3 top命令 10.4 sar命令 10.5 nload命令

10.1 使用w查看系統負載 10.2 vmstat命令 10.3 top命令 10.4 sar命令 10.5 nload命令

僵屍進程 line 一行 uptime rtp ica blog lis png

技術分享圖片

[root@lizhipeng01 ~]# w
17:43:46 up 6 min, 1 user, load average: 0.00, 0.04, 0.05 負載,1分鐘,5分鐘,15分鐘;單位時間內使用CPU活動的進程有幾個
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.5.1 17:38 2.00s 0.04s 0.01s w
[root@lizhipeng01 ~]# date
2018年 01月 21日 星期日 17:43:53 CST

[root@lizhipeng01 ~]# cat /proc/cpuinfo
processor : 0 1顆邏輯CPU,最大是8,也就是數字為7
vendor_id : GenuineIntel
cpu family : 6
model : 94
model name : Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz
stepping : 3
microcode : 0x74
cpu MHz : 2303.998
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 : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf 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 ida arat epb xsaveopt pln pts dtherm fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap
bogomips : 4607.99
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:

[root@lizhipeng01 ~]# uptime 第一行結果和w結果一樣
17:54:47 up 17 min, 1 user, load average: 0.01, 0.02, 0.05
[root@lizhipeng01 ~]# w
17:54:56 up 17 min, 1 user, load average: 0.01, 0.02, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.5.1 17:38 0.00s 0.04s 0.00s w

[root@lizhipeng01 ~]# 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 737316 764 139500 0 0 82 8 40 80 0 1 98 1 0
[root@lizhipeng01 ~]# vmstat 1 1表示每一秒顯示一次
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 737500 764 139516 0 0 80 8 40 79 0 1 98 1 0
0 0 0 737484 764 139516 0 0 0 0 19 23 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 16 12 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 17 15 0 1 99 0 0
0 0 0 737484 764 139516 0 0 0 0 18 16 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 20 25 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 16 13 0 0 100 0 0

[root@lizhipeng01 ~]# vmstat 1 5 每一秒顯示一次,顯示5次
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st r表示多少個進程處於run的狀態,b block阻塞,swpd數字一直不變沒有問題,如果一直變,表明內不夠用,內存與其一直在頻繁的交換數據
2 0 0 737500 764 139516 0 0 75 8 38 75 0 1 98 1 0 bi從磁盤裏讀,bo寫入磁盤,us用戶占用cpu的百分比
0 0 0 737484 764 139516 0 0 0 0 20 27 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 18 11 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 14 17 0 0 100 0 0
0 0 0 737484 764 139516 0 0 0 0 18 13 0 1 99 0 0
[root@lizhipeng01 ~]#

top - 18:17:22 up 39 min, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 346 total, 2 running, 344 sleeping, 0 stopped, 0 zombie zombiez僵屍進程
%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 st偷走的cpu
KiB Mem : 1003160 total, 735896 free, 126072 used, 141192 buff/cache 內存情況
KiB Swap: 2097148 total, 2097148 free, 0 used. 728840 avail Mem

技術分享圖片

按數字1,來回切換cpu,M按內存使用排序,P按CPU使用排序,q退出來 top -c能夠顯示到具體的進程,全局的路徑

技術分享圖片

top -bn1 靜態顯示,適合寫腳本

技術分享圖片

[root@lizhipeng01 ~]# sar
-bash: sar: 未找到命令
[root@lizhipeng01 ~]# yum install -y sysstat

[root@lizhipeng01 ~]# sar
無法打開 /var/log/sa/sa21: 沒有那個文件或目錄

技術分享圖片

數據包rxpck幾千正常,上萬就不正常了

[root@lizhipeng01 ~]# sar 不再報錯
Linux 3.10.0-229.el7.x86_64 (lizhipeng01) 2018年01月21日 _x86_64_ (1 CPU)
[root@lizhipeng01 ~]# ls /var/log/sa/
sa21

[root@lizhipeng01 ~]# sar -n DEV -f /var/log/sa/sa21
Linux 3.10.0-229.el7.x86_64 (lizhipeng01) 2018年01月21日 _x86_64_ (1 CPU)

[root@lizhipeng01 ~]# sar -q
Linux 3.10.0-229.el7.x86_64 (lizhipeng01) 2018年01月21日 _x86_64_ (1 CPU)

18時40分01秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
18時50分01秒 1 363 0.00 0.01 0.05 0
平均時間: 1 363 0.00 0.01 0.05 0

[root@lizhipeng01 ~]# sar -b
Linux 3.10.0-229.el7.x86_64 (lizhipeng01) 2018年01月21日 _x86_64_ (1 CPU)

18時40分01秒 tps rtps wtps bread/s bwrtn/s
18時50分01秒 0.05 0.00 0.05 0.00 0.47
平均時間: 0.05 0.00 0.05 0.00 0.47

[root@lizhipeng01 ~]# nload
-bash: nload: 未找到命令
[root@lizhipeng01 ~]# yum install nload

技術分享圖片

->

技術分享圖片

10.1 使用w查看系統負載 10.2 vmstat命令 10.3 top命令 10.4 sar命令 10.5 nload命令