1. 程式人生 > >[CentOS 7系列]監控系統狀態

[CentOS 7系列]監控系統狀態

監控

1、w/uptime 查看系統負載

[[email protected] ~]# w                ##分別為1分鐘,5分鐘,15分鐘的負載
 17:35:58 up  5:30,  1 user,  load average: 0.00, 0.01, 0.05 
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    gateway          17:32    6.00s  0.26s  0.12s w
[[email protected] ~]# uptime
 17:36:02 up  5:30,  1 user,  load average: 0.00, 0.01, 0.05


2、/proc/cpuinfo 查看cpu核數

[[email protected] ~]# cat /proc/cpuinfo
processor       : 0                        ##表示只有1個邏輯cpu
vendor_id       : GenuineIntel
cpu family      : 6
model           : 58
model name      : Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
stepping        : 9
microcode       : 0x1b
cpu MHz         : 2593.839
cache size      : 3072 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
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 rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt xsave avx f16c rdrand hypervisor lahf_lm ida arat epb pln pts dtherm fsgsbase smep xsaveopt
bogomips        : 5188.23
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:


3、vmstat 監控系統狀態

[[email protected] ~]# 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 749284    876 150960    0    0     6     1   15   18  0  0 100  0  0
 [[email protected]
/* */ ~]# vmstat 1 5 ##1秒顯示1次,一共顯示5次 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 749284 876 150960 0 0 6 1 15 18 0 0 100 0 0 0 0 0 749268 876 150960 0 0 0 0 20 23 0 0 100 0 0 0 0 0 749268 876 150960 0 0 0 0 16 14 0 1 99 0 0 0 0 0 749268 876 150960 0 0 0 0 22 25 0 0 100 0 0 0 0 0 749268 876 150960 0 0 0 0 19 14 0 0 100 0 0

▎參數解讀:

r run,運行中的進程數

b block,卡死狀態

swpd swap中的進程數(影響si,so)

si 有多少kb的數據從swap進入內存中

so 有多少kb的數據從內存中進入swap中

bi 從磁盤出來進入內存,讀

bo 從內存出來進入磁盤,寫

us 用戶占用資源百分比(us + sy + id =100)

wa wait,等待cpu的進程百分比

4、top 查看進程使用資源情況

[[email protected] ~]# top  ##動態顯示,3秒1次
top - 17:57:23 up  5:51,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  82 total,   2 running,  80 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1008392 total,   748360 free,   107540 used,   152492 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   735044 avail Mem
                           #RES表示物理內存大小#
  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    3 root      20   0       0      0      0 S  0.3  0.0   0:00.07 ksoftirqd/0
   21 root      20   0       0      0      0 S  0.3  0.0   0:17.59 kworker/0:1
    1 root      20   0  128092   6708   3952 S  0.0  0.7   0:01.87 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    ......
[[email protected] ~]# top -c    ##顯示詳細的進程信息
top - 17:59:12 up  5:53,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  83 total,   1 running,  82 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 :  1008392 total,   748164 free,   107680 used,   152548 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   734864 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
   21 root      20   0       0      0      0 S  0.3  0.0   0:17.73 [kworker/0:1]
 2619 root      20   0  157604   2204   1608 R  0.3  0.2   0:00.01 top -c
   ......
[[email protected] ~]# top -bn1   ##靜態顯示
top - 18:00:22 up  5:54,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  83 total,   1 running,  82 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.1 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1008392 total,   748316 free,   107528 used,   152548 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   735016 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0  128092   6708   3952 S  0.0  0.7   0:01.87 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    3 root      20   0       0      0      0 S  0.0  0.0   0:00.07 ksoftirqd/0
    6 root      20   0       0      0      0 S  0.0  0.0   0:00.36 kworker/u128:0
    ......

q退出,1顯示所有核cpu。

默認按cpu排序,M按內存使用排序,P按cpu使用排序。


5、sar 系統活動情況

[[email protected] ~]# yum install -y sysstat
......
已安裝:
  sysstat.x86_64 0:10.1.5-11.el7

作為依賴被安裝:
  lm_sensors-libs.x86_64 0:3.4.0-4.20160601gitf9185e5.el7

完畢!
[[email protected] ~]# sar -n DEV    ##網卡流量
Linux 3.10.0-514.el7.x86_64 (server01)  2017年07月10日  _x86_64_        (1 CPU)

18時10分02秒  IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
18時20分01秒     lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
18時20分01秒  ens33      0.18      0.11      0.02      0.01      0.00      0.00      0.00
平均時間:        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均時間:     ens33      0.18      0.11      0.02      0.01      0.00      0.00      0.00

23時01分06秒       LINUX RESTART
[[email protected] ~]# sar -n DEV 1 3  ##每隔1秒顯示一次,一共顯示3次
Linux 3.10.0-514.el7.x86_64 (server01)  2017年07月10日  _x86_64_        (1 CPU)

23時06分46秒  IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
23時06分47秒     lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
23時06分47秒  ens33      1.01      1.01      0.06      0.18      0.00      0.00      0.00

23時06分47秒  IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
23時06分48秒     lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
23時06分48秒  ens33      1.01      1.01      0.06      0.40      0.00      0.00      0.00

23時06分48秒  IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
23時06分49秒     lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
23時06分49秒  ens33      1.00      1.00      0.06      0.40      0.00      0.00      0.00

平均時間:    IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
平均時間:        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均時間:     ens33      1.01      1.01      0.06      0.33      0.00      0.00      0.00
[[email protected] ~]# sar -q     ##系統負載
Linux 3.10.0-514.el7.x86_64 (server01)  2017年07月10日  _x86_64_        (1 CPU)

18時10分02秒   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
18時20分01秒         1       100      0.00      0.01      0.05         0
平均時間:         1       100      0.00      0.01      0.05         0

23時01分06秒       LINUX RESTART
[[email protected] ~]# sar -b     ##磁盤讀寫
Linux 3.10.0-514.el7.x86_64 (server01)  2017年07月10日  _x86_64_        (1 CPU)

18時10分02秒       tps      rtps      wtps   bread/s   bwrtn/s
18時20分01秒      0.07      0.00      0.07      0.00      0.86
平均時間:      0.07      0.00      0.07      0.00      0.86

23時01分06秒       LINUX RESTART
[[email protected] ~]# sar -f /var/log/sa/sa10   ##歷史文件,每10分鐘保存一次
Linux 3.10.0-514.el7.x86_64 (server01)  2017年07月10日  _x86_64_        (1 CPU)

18時10分02秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
18時20分01秒     all      0.01      0.00      0.09      0.00      0.00     99.90
平均時間:     all      0.01      0.00      0.09      0.00      0.00     99.90

23時01分06秒       LINUX RESTART
[[email protected] ~]#


6、nload 實時網絡流量

[[email protected] ~]# yum install -y nload
已安裝:
  nload.x86_64 0:0.7.4-4.el7

完畢!
[[email protected] ~]# nload      ##通過左右方向鍵切換網卡
Device ens33 [192.168.137.100] (1/2):
=================================================================
Incoming:
......
Outgoing:
 #############################################     Curr: 78.50 MBit/s
 #############################################     Avg: 16.47 MBit/s
 #############################################     Min: 4.13 kBit/s
 #############################################     Max: 98.17 MBit/s
 #############################################     Ttl: 318.58 MByte


本文出自 “亂碼時代” 博客,請務必保留此出處http://juispan.blog.51cto.com/943137/1946141

[CentOS 7系列]監控系統狀態