目录

一、命令介绍

二、 基本用法

1、语法结构

2、选项

3、支持的日志设施:

4、支持的日志级别(优先级):

四、基本用法

1. 查看内核消息:

2. 实时查看内核消息:

3. 清空内核消息:

五、 高级用法

1. 过滤消息:

2. 查看消息级别:

4、特别提醒

六、dmesg主要的应用场景

1. 系统启动和初始化阶段的问题诊断:

2. 硬件相关问题的调试:

3. 内核错误和警告的查看:

4. 动态观察系统事件:

5. 清除内核消息缓冲区:

6. 系统性能分析和调优:

七、系统运维中的应用和实例

1. 查看系统启动时的内核信息,包括诊断硬件和驱动相关信息

2. 实时监控系统事件:

3. 过滤特定消息:

4. 设置日志级别:

5. 清除内核消息缓冲区:


一、命令介绍

        dmesg命令 在Linux系统中用于显示或控制内核环形缓冲区的内容。`dmesg`命令允许用户查看或操作内核消息,这些消息通常记录了系统启动过程、硬件检测、驱动加载、系统错误等关键信息。

       在linux系统的命令行中输入:man dmesg,可以看到dmesg的详细解释,如下图示:

二、 基本用法

1、语法结构

        语法结构:

                dmesg [选项]

2、选项

选项如下:

 -C, --clear                 清除内核环形缓冲区(ring butter)

 -c, --read-clear            读取并清除所有消息

 -D, --console-off           禁止向终端打印消息

 -d, --show-delta            显示打印消息之间的时间差

 -e, --reltime               以易读格式显示本地时间和时间差

 -E, --console-on            启用向终端打印消息

 -F, --file <文件>           用 文件 代替内核日志缓冲区

 -f, --facility <列表>       将输出限制为定义的设施

 -H, --human                 易读格式输出

 -k, --kernel                显示内核消息

 -L, --color                 显示彩色消息

 -l, --level <列表>          限制输出级别

 -n, --console-level <级别>  设置打印到终端的消息级别

 -P, --nopager               不将输出通过管道传递给分页程序

 -r, --raw                   打印原生消息缓冲区

 -S, --syslog                强制使用 syslog(2) 而非 /dev/kmsg

 -s, --buffer-size <大小>    查询内核环形缓冲区所用的缓冲区大小

 -T, --ctime                 显示易读的时间戳(如果您使用了

                                SUSPEND/RESUME 则可能不准)

 -t, --notime                不打印消息时间戳

 -u, --userspace             显示用户空间消息

 -w, --follow                等待新消息

 -x, --decode                将设施和级别解码为可读的字符串

 -h, --help     显示此帮助并退出

 -V, --version  输出版本信息并退出

3、支持的日志设施:

    kern     -  内核消息

    user     -  随机的用户级消息

    mail     -  邮件系统

  daemon -  系统守护进程

    auth     -  安全/认证消息

  syslog    -  syslogd 内部生成的消息

     lpr       -  行打印机子系统

    news    -  网络新闻子系统

4、支持的日志级别(优先级):

   emerg -  系统无法使用

   alert    -  操作必须立即执行

    crit     -  紧急条件

     err    -  错误条件

    warn  -  警告条件

  notice  -  正常但重要的条件

    info    -  信息

   debug -  调试级别的消息

四、基本用法

1. 查看内核消息:

        dmesg

        这个命令将显示内核环形缓冲区中的所有消息。

2. 实时查看内核消息:

        dmesg -w

        使用`-w`选项,你可以实时查看新的内核消息。这对于观察系统动态或调试问题非常有用。

3. 清空内核消息:

        dmesg --clear

        或者简写为:

        dmesg -c

        这将清空内核环形缓冲区,删除所有当前的消息。

五、 高级用法

        `dmesg`是Linux系统管理员和开发者在诊断系统问题、调试硬件或驱动程序时经常使用的工具。它提供了对系统内部状态的直接访问,特别是一些高级用法,有助于快速识别和解决问题。

1. 过滤消息:

        使用`grep`命令结合`dmesg`可以过滤出特定的消息。例如,如果你想查找与某个驱动相关的消息,可以这样做:      dmesg | grep "driver_name"

       输入命令:

dmesg | grep "/dev/mapper/cl-root"

        在centos中,实际效果如下所示:

[root@localhost ~]#
[root@localhost ~]# dmesg | grep "/dev/mapper/cl-root"
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.102.1.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet LANG=zh_CN.UTF-8
[    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.102.1.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet LANG=zh_CN.UTF-8
[root@localhost ~]#

2. 查看消息级别:

        内核消息有不同的级别,如`alert`、`crit`、`err`、`warning`、`notice`、`info`、`debug`等。你可以使用`dmesg`的`--level`选项来查看特定级别的消息。例如:

        dmesg --level=notice

        这将只显示“notice”级别的消息。

        在centos中,实际效果如下所示:

[root@localhost ~]# dmesg --level=notice
[    0.000000] Linux version 3.10.0-1160.102.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Oct 17 15:42:21 UTC 2023
[    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.102.1.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet LANG=zh_CN.UTF-8
[    0.319427] ACPI: [Firmware Bug]: BIOS _OSI(Linux) query ignored
[    0.700735] SCSI subsystem initialized
[    0.727864] amd_nb: Cannot enumerate AMD northbridges
[    1.065534] Initialise system trusted keyring
[    1.066207] type=2000 audit(1708495201.842:1): initialized
[    1.090506] VFS: Disk quotas dquot_6.5.2
[    1.091355] Key type big_key registered
[    1.093256] Key type asymmetric registered
[    1.093258] Asymmetric key parser 'x509' registered
[    1.130925] Loading compiled-in X.509 certificates
[    1.130969] Loaded X.509 cert 'CentOS Linux kpatch signing key: ea0413152cde1d98ebdca3fe6f0230904c9ef717'
[    1.130985] Loaded X.509 cert 'CentOS Linux Driver update signing key: 7f421ee0ab69461574bb358861dbe77762a4201b'
[    1.131824] Loaded X.509 cert 'CentOS Linux kernel signing key: 567c0a8506c7c300f066035cea63e5bafde23fda'
[    1.134608] Key type trusted registered
[    1.136921] Key type encrypted registered
[    1.165486] random: systemd: uninitialized urandom read (16 bytes read)
[    1.165979] random: systemd: uninitialized urandom read (16 bytes read)
[    1.165993] random: systemd: uninitialized urandom read (16 bytes read)
[    1.212392] random: systemd: uninitialized urandom read (16 bytes read)
[    1.212438] random: systemd: uninitialized urandom read (16 bytes read)
[    1.212523] random: systemd: uninitialized urandom read (16 bytes read)
[    1.212637] random: systemd: uninitialized urandom read (16 bytes read)
[    1.213821] random: systemd: uninitialized urandom read (16 bytes read)
[    1.214074] random: systemd: uninitialized urandom read (16 bytes read)
[    1.214787] random: systemd: uninitialized urandom read (16 bytes read)
[    1.568170] scsi 0:0:0:0: Direct-Access     VMware   Virtual disk     2.0  PQ: 0 ANSI: 6
[    1.612281] sd 0:0:0:0: [sda] 125829120 512-byte logical blocks: (64.4 GB/60.0 GiB)
[    1.612461] sd 0:0:0:0: [sda] Write Protect is off
[    1.612491] sd 0:0:0:0: [sda] Cache data unavailable
[    1.622367] sd 0:0:0:0: [sda] Attached SCSI disk
[    2.248727] scsi 4:0:0:0: CD-ROM            NECVMWar VMware SATA CD01 1.00 PQ: 0 ANSI: 5
[    2.285142] random: fast init done
[    3.132740] random: crng init done
[    3.619827] XFS (dm-0): Mounting V5 Filesystem
[    3.970774] XFS (dm-0): Starting recovery (logdev: internal)
[    4.072068] XFS (dm-0): Ending recovery (logdev: internal)
[    5.625963] type=1404 audit(1708495206.966:2): selinux=0 auid=4294967295 ses=4294967295
[   11.447088] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   11.447168] sr 4:0:0:0: Attached scsi generic sg1 type 5
[   12.284860] XFS (sda1): Mounting V5 Filesystem
[   13.099012] XFS (sda1): Starting recovery (logdev: internal)
[   13.216610] XFS (sda1): Ending recovery (logdev: internal)
[   13.666750] XFS (dm-2): Mounting V5 Filesystem
[   14.178238] XFS (dm-2): Starting recovery (logdev: internal)
[   14.268067] XFS (dm-2): Ending recovery (logdev: internal)
[   14.905263] type=1305 audit(1708495216.245:3): audit_pid=771 old=0 auid=4294967295 ses=4294967295 res=1
[root@localhost ~]#

4、特别提醒

(1) `dmesg`命令显示的消息通常是内核产生的,因此它们通常与底层硬件和系统状态有关。

(2) 由于内核消息是循环存储的,所以旧的消息可能会被新的消息覆盖。因此,如果你正在调查某个问题,最好尽快使用`dmesg`捕获相关信息。

(3) 实时查看内核消息(使用`-w`选项)可能会产生大量的输出,特别是在系统繁忙时。确保你有足够的信息来过滤或处理这些消息。

六、dmesg主要的应用场景

        `dmesg`是一个强大的工具,具有广泛的应用,可以帮助Linux管理员和开发者深入了解系统的内部状态和事件,从而更有效地诊断和解决问题。`dmesg`命令通常在以下几种情况下被使用:

1. 系统启动和初始化阶段的问题诊断:

        在Linux系统启动过程中,内核会输出大量的信息到内核环形缓冲区,这些信息包括硬件检测、驱动加载、文件系统挂载等。如果系统启动失败或某些功能无法正常工作,管理员通常会使用`dmesg`来查看这些启动信息,以便诊断问题所在。

2. 硬件相关问题的调试:

        当硬件出现问题,如设备无法识别、驱动不兼容或硬件故障时,`dmesg`可以提供关于硬件与内核交互的详细信息。这些信息对于确定硬件问题的原因以及如何解决它们非常有帮助。

3. 内核错误和警告的查看:

        如果系统出现内核错误或警告,这些消息通常会被写入内核环形缓冲区。使用`dmesg`可以迅速查看这些错误或警告,以便管理员或开发者了解问题的性质和可能的解决方案。

4. 动态观察系统事件:

        使用`dmesg -w`选项可以实时查看内核产生的新消息。这对于观察系统动态、监控硬件状态或调试正在运行的系统问题非常有用。

5. 清除内核消息缓冲区:

        在某些情况下,管理员可能需要清除内核消息缓冲区,以便只查看最新的系统事件。这可以通过`dmesg --clear`或`dmesg -c`命令实现。

6. 系统性能分析和调优:

        虽然`dmesg`主要用于错误和警告信息的查看,但有时它也可以提供有关系统性能的信息。例如,如果某个设备或驱动导致系统性能下降,`dmesg`的输出可能包含相关的提示或警告。

七、系统运维中的应用和实例

        在Linux系统运维中,`dmesg`命令是一个非常重要的工具,主要用于问题诊断和系统调试。可以帮助运维人员深入了解系统的内部状态和事件,从而更有效地诊断和解决问题。通过结合其他命令和选项,运维人员可以更加灵活地利用`dmesg`进行系统监控和故障排查。以下是一些`dmesg`在Linux系统运维中的具体用法:

1. 查看系统启动时的内核信息,包括诊断硬件和驱动相关信息

        在系统启动过程中,内核会输出大量关于硬件检测、驱动加载、文件系统挂载等的信息,以及硬件与内核交互的详细信息。使用`dmesg`可以查看这些启动信息,帮助运维人员了解系统启动过程中的状态和可能存在的问题。

        当系统出现硬件故障或驱动不兼容等问题时,通过查看`dmesg`输出,运维人员可以了解硬件设备的状态、驱动程序的加载情况以及可能的错误或警告信息,从而进行针对性的排查和修复。

        输入命令:

dmesg

        在centos中,实际效果如下所示:

[root@localhost ~]# dmesg
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.0-1160.102.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Oct 17 15:42:21 UTC 2023
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.102.1.el7.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet LANG=zh_CN.UTF-8
[    0.000000] Disabled fast string operations
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009e7ff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009e800-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000ce000-0x00000000000cffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000dc000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bfecffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bfed0000-0x00000000bfefefff] ACPI data
[    0.000000] BIOS-e820: [mem 0x00000000bfeff000-0x00000000bfefffff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000bff00000-0x00000000bfffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f0000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec0ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffe0000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000001bfffffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.7 present.
[    0.000000] DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 12/12/2018
[    0.000000] Hypervisor detected: VMware
[    0.000000] vmware: TSC freq read from hypervisor : 2194.843 MHz
[    0.000000] vmware: Host bus clock speed read from hypervisor : 66000000 Hz
[    0.000000] vmware: using sched offset of 8031519022 ns
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] e820: last_pfn = 0x1c0000 max_arch_pfn = 0x400000000
[    0.000000] MTRR default type: uncachable
[    0.000000] MTRR fixed ranges enabled:
[    0.000000]   00000-9FFFF write-back
[    0.000000]   A0000-BFFFF uncachable
[    0.000000]   C0000-CFFFF write-protect
[    0.000000]   D0000-EFFFF uncachable
[    0.000000]   F0000-FFFFF write-protect
[    0.000000] MTRR variable ranges enabled:
[    0.000000]   0 base 00000000000 mask 7E000000000 write-back
[    0.000000]   1 base 000C0000000 mask 7FFC0000000 uncachable
[    0.000000]   2 disabled
[    0.000000]   3 disabled
[    0.000000]   4 disabled
[    0.000000]   5 disabled
[    0.000000]   6 disabled
[    0.000000]   7 disabled
[    0.000000] PAT configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- UC
[    0.000000] original variable MTRRs
[    0.000000] reg 0, base: 0GB, range: 128GB, type WB
[    0.000000] reg 1, base: 3GB, range: 1GB, type UC
[    0.000000] total RAM covered: 130048M
[    0.000000] Found optimal setting for mtrr clean up
[    0.000000]  gran_size: 64K  chunk_size: 128G        num_reg: 2      lose cover RAM: 0G
[    0.000000] New variable MTRRs

........................................
........................................

[    2.249297] ata24: SATA link down (SStatus 0 SControl 300)
[    2.249329] ata28: SATA link down (SStatus 0 SControl 300)
[    2.249360] ata22: SATA link down (SStatus 0 SControl 300)
[    2.271328] sr 4:0:0:0: [sr0] scsi3-mmc drive: 1x/1x writer dvd-ram cd/rw xa/form2 cdda tray
[    2.271331] cdrom: Uniform CD-ROM driver Revision: 3.20
[    2.271480] sr 4:0:0:0: Attached scsi CD-ROM sr0
[    2.285142] random: fast init done
[    3.132740] random: crng init done
[    3.609799] SGI XFS with ACLs, security attributes, no debug enabled
[    3.619827] XFS (dm-0): Mounting V5 Filesystem
[    3.970774] XFS (dm-0): Starting recovery (logdev: internal)
[    4.072068] XFS (dm-0): Ending recovery (logdev: internal)
[    4.579192] systemd-journald[108]: Received SIGTERM from PID 1 (systemd).
[    5.582715] SELinux:  Disabled at runtime.
[    5.582756] SELinux:  Unregistering netfilter hooks
[    5.625963] type=1404 audit(1708495206.966:2): selinux=0 auid=4294967295 ses=4294967295
[    6.119180] ip_tables: (C) 2000-2006 Netfilter Core Team
[    6.120044] systemd[1]: Inserted module 'ip_tables'
[    9.516362] systemd-journald[599]: Received request to flush runtime journal from PID 1
[   10.282285] vmw_vmci 0000:00:07.7: Found VMCI PCI device at 0x11080, irq 16
[   10.282389] vmw_vmci 0000:00:07.7: Using capabilities 0xc
[   10.282723] vmw_vmci 0000:00:07.7: irq 58 for MSI/MSI-X
[   10.282829] vmw_vmci 0000:00:07.7: irq 59 for MSI/MSI-X
[   10.283381] Guest personality initialized and is active
[   10.283461] VMCI host device registered (name=vmci, major=10, minor=58)
[   10.283463] Initialized host personality
[   10.381766] piix4_smbus 0000:00:07.3: SMBus Host Controller not enabled!
[   11.166605] input: PC Speaker as /devices/platform/pcspkr/input/input4
[   11.317414] ppdev: user-space parallel port driver
[   11.333985] cryptd: max_cpu_qlen set to 1000
[   11.447088] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   11.447168] sr 4:0:0:0: Attached scsi generic sg1 type 5
[   11.488376] AVX2 version of gcm_enc/dec engaged.
[   11.488380] AES CTR mode by8 optimization enabled
[   11.493348] alg: No test for __gcm-aes-aesni (__driver-gcm-aes-aesni)
[   11.493427] alg: No test for __generic-gcm-aes-aesni (__driver-generic-gcm-aes-aesni)
[   11.717389] Adding 2097148k swap on /dev/mapper/cl-swap.  Priority:-2 extents:1 across:2097148k FS
[   12.284860] XFS (sda1): Mounting V5 Filesystem
[   13.099012] XFS (sda1): Starting recovery (logdev: internal)
[   13.216610] XFS (sda1): Ending recovery (logdev: internal)
[   13.666750] XFS (dm-2): Mounting V5 Filesystem
[   13.983044] floppy0: no floppy controllers found
[   14.178238] XFS (dm-2): Starting recovery (logdev: internal)
[   14.268067] XFS (dm-2): Ending recovery (logdev: internal)
[   14.905263] type=1305 audit(1708495216.245:3): audit_pid=771 old=0 auid=4294967295 ses=4294967295 res=1
[   17.128959] NET: Registered protocol family 40
[   18.272848] IPv6: ADDRCONF(NETDEV_UP): ens32: link is not ready
[   18.279243] e1000: ens32 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[   18.283627] IPv6: ADDRCONF(NETDEV_UP): ens32: link is not ready
[   18.283638] IPv6: ADDRCONF(NETDEV_CHANGE): ens32: link becomes ready
[  628.365501] hrtimer: interrupt took 14359 ns
[11864.730612] Bluetooth: Core ver 2.22
[11864.730633] NET: Registered protocol family 31
[11864.730634] Bluetooth: HCI device and connection manager initialized
[11864.730638] Bluetooth: HCI socket layer initialized
[11864.730641] Bluetooth: L2CAP socket layer initialized
[11864.730645] Bluetooth: SCO socket layer initialized
[12066.424084] device ens32 entered promiscuous mode
[12085.092027] device ens32 left promiscuous mode
[960976.742959] UDP: bad checksum. From 183.129.159.243:62483 to 192.168.1.191:20547 ulen 49
[1392605.276386] device ens32 entered promiscuous mode
[1392779.506753] device ens32 left promiscuous mode
[1394128.434830] device ens32 entered promiscuous mode
[1394261.088835] device ens32 left promiscuous mode
[1394500.689646] device ens32 entered promiscuous mode
[1394661.986082] device ens32 left promiscuous mode
[1394988.372472] device ens32 entered promiscuous mode
[1395421.611522] device ens32 left promiscuous mode
[1396211.134762] device ens32 entered promiscuous mode
[1396544.704015] device ens32 left promiscuous mode
[1400069.526901] device ens32 entered promiscuous mode
[1400354.953733] device ens32 left promiscuous mode
[1403420.170669] device ens32 entered promiscuous mode
[1403710.594769] device ens32 left promiscuous mode
[1404618.793475] device ens32 entered promiscuous mode
[1404620.724127] device ens32 left promiscuous mode
[1728675.824848] sched: RT throttling activated
[root@localhost ~]#

数量太多,用了“......................”省略了中间的部分。

2. 实时监控系统事件:

        使用`dmesg -w`选项可以实时查看内核产生的新消息。这对于运维人员观察系统动态、监控硬件状态或调试正在运行的系统问题非常有用。通过实时查看`dmesg`输出,运维人员可以及时发现并解决潜在的系统问题。

       输入命令:

dmesg -w

        在centos中,实际效果如下所示:

可以看出,输出没有停下来,继续实时输出信息。

3. 过滤特定消息:

        由于`dmesg`输出的消息量可能很大,运维人员可以使用管道和`grep`命令来过滤特定的消息。例如,可以使用`dmesg | grep "interrupt"`来只显示包含“interrupt”关键字的消息,从而快速定位错误或警告信息。

       输入命令:

dmesg | grep "interrupt"

        在centos中,实际效果如下所示:

[root@localhost ~]#
[root@localhost ~]# dmesg | grep "interrupt"
[    0.344431] ACPI: Using IOAPIC for interrupt routing
[    1.109523] pcieport 0000:00:15.0: Signaling PME through PCIe PME interrupt
[    1.109525] pci 0000:03:00.0: Signaling PME through PCIe PME interrupt
[    1.109630] pcieport 0000:00:15.1: Signaling PME through PCIe PME interrupt
[    1.109736] pcieport 0000:00:15.2: Signaling PME through PCIe PME interrupt
[    1.109843] pcieport 0000:00:15.3: Signaling PME through PCIe PME interrupt
[    1.109955] pcieport 0000:00:15.4: Signaling PME through PCIe PME interrupt
[    1.110059] pcieport 0000:00:15.5: Signaling PME through PCIe PME interrupt
[    1.110164] pcieport 0000:00:15.6: Signaling PME through PCIe PME interrupt
[    1.110268] pcieport 0000:00:15.7: Signaling PME through PCIe PME interrupt
[    1.110372] pcieport 0000:00:16.0: Signaling PME through PCIe PME interrupt
[    1.110482] pcieport 0000:00:16.1: Signaling PME through PCIe PME interrupt
[    1.110587] pcieport 0000:00:16.2: Signaling PME through PCIe PME interrupt
[    1.110692] pcieport 0000:00:16.3: Signaling PME through PCIe PME interrupt
[    1.110796] pcieport 0000:00:16.4: Signaling PME through PCIe PME interrupt
[    1.110901] pcieport 0000:00:16.5: Signaling PME through PCIe PME interrupt
[    1.111012] pcieport 0000:00:16.6: Signaling PME through PCIe PME interrupt
[    1.111117] pcieport 0000:00:16.7: Signaling PME through PCIe PME interrupt
[    1.111221] pcieport 0000:00:17.0: Signaling PME through PCIe PME interrupt
[    1.111325] pcieport 0000:00:17.1: Signaling PME through PCIe PME interrupt
[    1.111430] pcieport 0000:00:17.2: Signaling PME through PCIe PME interrupt
[    1.111535] pcieport 0000:00:17.3: Signaling PME through PCIe PME interrupt
[    1.111639] pcieport 0000:00:17.4: Signaling PME through PCIe PME interrupt
[    1.111745] pcieport 0000:00:17.5: Signaling PME through PCIe PME interrupt
[    1.111849] pcieport 0000:00:17.6: Signaling PME through PCIe PME interrupt
[    1.111959] pcieport 0000:00:17.7: Signaling PME through PCIe PME interrupt
[    1.112065] pcieport 0000:00:18.0: Signaling PME through PCIe PME interrupt
[    1.112170] pcieport 0000:00:18.1: Signaling PME through PCIe PME interrupt
[    1.112275] pcieport 0000:00:18.2: Signaling PME through PCIe PME interrupt
[    1.112382] pcieport 0000:00:18.3: Signaling PME through PCIe PME interrupt
[    1.112488] pcieport 0000:00:18.4: Signaling PME through PCIe PME interrupt
[    1.112593] pcieport 0000:00:18.5: Signaling PME through PCIe PME interrupt
[    1.112698] pcieport 0000:00:18.6: Signaling PME through PCIe PME interrupt
[    1.112805] pcieport 0000:00:18.7: Signaling PME through PCIe PME interrupt
[  628.365501] hrtimer: interrupt took 14359 ns
[root@localhost ~]# dmesg | grep "error"
[root@localhost ~]#
[root@localhost ~]#

4. 设置日志级别:

        通过指定日志级别,运维人员可以控制`dmesg`输出的信息范围。例如,使用`dmesg --level=err`将只显示错误级别的消息,这有助于聚焦关键问题并减少干扰信息。

       输入命令:

dmesg --level=err

        在centos中,实际效果如下所示:

[root@localhost ~]#
[root@localhost ~]# dmesg --level=err
[    1.612493] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   10.381766] piix4_smbus 0000:00:07.3: SMBus Host Controller not enabled!
[root@localhost ~]#
[root@localhost ~]#

5. 清除内核消息缓冲区:

        在某些情况下,运维人员可能需要清除内核消息缓冲区以释放空间或仅关注最新的系统事件。可以使用`dmesg --clear`或`dmesg -C`命令来清空内核环形缓冲区。

      输入命令:

dmesg --clear

        centos中,实际效果如下所示:

[root@localhost ~]# dmesg --clear
[root@localhost ~]# dmesg --level=err
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# dmesg
[root@localhost ~]#
[root@localhost ~]#

        可以看出,清楚以后,暂时没有任何信息了。


篇幅有限,文章正下方可以看到我的联系方式。

鼠标“点击” 下面的 “威迪斯特-就是video system 微信名片”字样,就会出现我的二维码,欢迎沟通。


Logo

更多推荐