【四月更文打卡】Linux系统性能监控和管理【续】

655 阅读2分钟

3.vmstat命令查看虚拟内存信息

[root@centos8 ~]#vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0 351744 221400     48 310228    0    3    12    10   96  123  0  1 99  0  0
  • 分栏说明
procs
  r:可运行(正运行或等待运行)进程的个数,和核心数有关 
  b:处于不可中断睡眠态的进程个数(被阻塞的队列的长度) 
memory
  swpd: 交换内存的使用总量  
  free:空闲物理内存总量 
  buffer:用于buffer的内存总量 
  cache:用于cache的内存总量 
swap
  si:从磁盘交换进内存的数据速率(kb/s) 
  so:从内存交换至磁盘的数据速率(kb/s) 
io
  bi:从块设备读入数据到系统的速率(kb/s) 
  bo: 保存数据至块设备的速率 
system
  in: interrupts  中断速率,包括时钟 
  cs: context switch  进程切换速率 
cpu
  us:Time spent running non-kernel code 
  sy: Time spent running kernel code 
  id: Time spent idle. Linux 2.5.41前,包括IO-wait time. 
  wa: Time spent waiting for IO.  2.5.41前,包括in idle. 
  st: Time stolen from a virtual machine.  2.6.11前, unknown. 
选项
  -s: 显示内存的统计数据
[root@centos8 ~]#vmstat -s
      1601624 K total memory
      1070076 K used memory
       304720 K active memory
       355440 K inactive memory
       220684 K free memory
           48 K buffer memory
       310816 K swap cache
      3145724 K total swap
       351488 K used swap
      2794236 K free swap
        23953 non-nice user cpu ticks
          283 nice user cpu ticks
        51189 system cpu ticks
     15032629 idle cpu ticks
          450 IO-wait cpu ticks
        22150 IRQ cpu ticks
         9239 softirq cpu ticks
            0 stolen cpu ticks
      1831057 pages paged in
      1529731 pages paged out
        15528 pages swapped in
       103783 pages swapped out
     14519323 interrupts
     18668588 CPU context switches
   1572022693 boot time
       175270 forks

4.使用iostat统计CPU和设备IO信息

  • iostat # 指定刷新频率为#秒刷新一次
[root@centos8 ~]#iostat
Linux 4.18.0-80.el8.x86_64 (centos8.suosuoli)   10/26/19        _x86_64_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.16    0.00    0.55    0.00    0.00   99.29

Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
nvme0n1           1.64        48.17        40.38    1830027    1534327
scd0              0.00         0.03         0.00       1106          0

5.iftop显示带宽使用情况

                  12.5Kb            25.0Kb             37.5Kb            50.0Kb       62.5Kb
└─────────────────┴─────────────────┴──────────────────┴─────────────────┴──────────────────centos8.suosuoli                 => 172.20.1.1                       1.70Kb  1.77Kb  1.97Kb
                                 <=                                   184b    258b    299b
centos8.suosuoli                 => public1.alidns.com                284b    343b    318b
                                 <=                                   592b    690b    628b
224.0.0.251                      => 172.20.1.156                        0b      0b      0b
                                 <=                                     0b    275b    172b
172.20.255.255                   => 172.20.2.20                         0b      0b      0b
                                 <=                                     0b    187b    117b
172.20.255.255                   => 172.20.30.30                        0b      0b      0b
                                 <=                                     0b     58b     36b
255.255.255.255                  => 172.20.2.20                         0b      0b      0b


────────────────────────────────────────────────────────────────────────────────────────────TX:             cum:   4.57KB   peak:   2.81Kb              rates:   1.98Kb  2.10Kb  2.28Kb
RX:                    2.49KB           4.09Kb                        776b   1.47Kb  1.24Kb
TOTAL:                 7.06KB           6.90Kb                       2.74Kb  3.57Kb  3.53Kb