从历史系统日志中查看原始内核消息计时

从历史系统日志中查看原始内核消息计时

默认情况下,journalctl以传统系统日志格式显示消息,包括 CLOCK_REALTIME 标记,即挂钟时间(和日历日期)。

但是,如果在日志未运行时(例如在启动或挂起/恢复过程期间)记录了内核消息,则这不会显示内核消息的准确时间戳。现在大多数内核默认启用printk.time,因此dmesg在每条日志消息前面都会显示一个时间戳。

可以journalctl显示原始内核时间戳吗?我想检查历史挂起/恢复日志消息的精确时间。

答案1

是的,是的,可以。

$ journalctl -o short-monotonic -b
[    0.000000] alan-laptop kernel: microcode: microcode updated early to revision 0x2a, date = 2018-01-18
[    0.000000] alan-laptop kernel: Linux version 4.15.14-300.fc27.x86_64 ([email protected]) (gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)) #1 SMP Thu Mar 29 16:13:44 UTC 2018
...
[    0.000000] alan-laptop kernel: x2apic: IRQ remapping doesn't support X2APIC mode
[    0.001000] alan-laptop kernel: ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.006000] alan-laptop kernel: tsc: Fast TSC calibration using PIT
[    0.007000] alan-laptop kernel: tsc: Detected 2294.717 MHz processor
[    0.007000] alan-laptop kernel: Calibrating delay loop (skipped), value calculated using timer frequency.. 4589.43 BogoMIPS (lpj=2294717)

时间戳与 完全匹配dmesg,即使对于挂起/恢复也是如此。

(我不会试图挑剔这是否意味着它们是 CLOCK_BOOTTIME 时间戳,而不是 CLOCK_MONOTONIC 时间戳;日志字段名称可能令人困惑,但这正是我想要的)。

相关内容