系统诊断

  1. 系统启动异常诊断 - dmesg

  2. 查看系统活动信息 - sar

    1. [root ~]# sar -u -r 5 10
    2. Linux 3.10.0-957.10.1.el7.x86_64 (izwz97tbgo9lkabnat2lo8z) 06/02/2019 _x86_64_ (2 CPU)
    3. 06:48:30 PM CPU %user %nice %system %iowait %steal %idle
    4. 06:48:35 PM all 0.10 0.00 0.10 0.00 0.00 99.80
    5. 06:48:30 PM kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty
    6. 06:48:35 PM 1772012 2108392 54.33 102816 1634528 784940 20.23 793328 1164704 0
    • -A - 显示所有设备(CPU、内存、磁盘)的运行状况。
    • -u - 显示所有CPU的负载情况。
    • -d - 显示所有磁盘的使用情况。
    • -r - 显示内存的使用情况。
    • -n - 显示网络运行状态。
  3. 查看内存使用情况 - free

    1. [root ~]# free
    2. total used free shared buff/cache available
    3. Mem: 1016168 323924 190452 356 501792 531800
    4. Swap: 0 0 0
  4. 虚拟内存统计 - vmstat

    1. [root ~]# vmstat
    2. procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
    3. r b swpd free buff cache si so bi bo in cs us sy id wa st
    4. 2 0 0 204020 79036 667532 0 0 5 18 101 58 1 0 99 0 0
  5. CPU信息统计 - mpstat

    1. [root ~]# mpstat
    2. Linux 3.10.0-957.5.1.el7.x86_64 (iZ8vba0s66jjlfmo601w4xZ) 05/30/2019 _x86_64_ (1 CPU)
    3. 01:51:54 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
    4. 01:51:54 AM all 0.71 0.00 0.17 0.04 0.00 0.00 0.00 0.00 0.00 99.07
  6. 查看进程使用内存状况 - pmap

    1. [root ~]# ps
    2. PID TTY TIME CMD
    3. 4581 pts/0 00:00:00 bash
    4. 5664 pts/0 00:00:00 ps
    5. [root ~]# pmap 4581
    6. 4581: -bash
    7. 0000000000400000 884K r-x-- bash
    8. 00000000006dc000 4K r---- bash
    9. 00000000006dd000 36K rw--- bash
    10. 00000000006e6000 24K rw--- [ anon ]
    11. 0000000001de0000 400K rw--- [ anon ]
    12. 00007f82fe805000 48K r-x-- libnss_files-2.17.so
    13. 00007f82fe811000 2044K ----- libnss_files-2.17.so
    14. ...
  7. 报告设备CPU和I/O统计信息 - iostat

    1. [root ~]# iostat
    2. Linux 3.10.0-693.11.1.el7.x86_64 (iZwz97tbgo9lkabnat2lo8Z) 06/26/2018 _x86_64_ (1 CPU)
    3. avg-cpu: %user %nice %system %iowait %steal %idle
    4. 0.79 0.00 0.20 0.04 0.00 98.97
    5. Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
    6. vda 0.85 6.78 21.32 2106565 6623024
    7. vdb 0.00 0.01 0.00 2088 0
  8. 显示所有PCI设备 - lspci

    1. [root ~]# lspci
    2. 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
    3. 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
    4. 00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
    5. 00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
    6. 00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
    7. 00:02.0 VGA compatible controller: Cirrus Logic GD 5446
    8. 00:03.0 Ethernet controller: Red Hat, Inc. Virtio network device
    9. 00:04.0 Communication controller: Red Hat, Inc. Virtio console
    10. 00:05.0 SCSI storage controller: Red Hat, Inc. Virtio block device
    11. 00:06.0 SCSI storage controller: Red Hat, Inc. Virtio block device
    12. 00:07.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon
  9. 显示进程间通信设施的状态 - ipcs

    1. [root ~]# ipcs
    2. ------ Message Queues --------
    3. key msqid owner perms used-bytes messages
    4. ------ Shared Memory Segments --------
    5. key shmid owner perms bytes nattch status
    6. ------ Semaphore Arrays --------
    7. key semid owner perms nsems