Wednesday, July 20, 2011

dmesg(1) changes for util-linux 2.20

I have re-written the dmesg(1). That's the first large change in the code in last 18 years.

New features:
  • --decode facility and level number to human readable prefixes
$ dmesg --decode
kern :info : [26443.677632] ata1.00: configured for UDMA/100
kern :info : [26443.830225] PM: resume of devices complete after 2452.856 msecs
kern :debug : [26443.830606] PM: Finishing wakeup.
kern :warn : [26443.830608] Restarting tasks ... done.
  • filter out messages according to the --facility and --level options, for example
$ dmesg --level=err,warn

$ dmesg --facility=daemon,user

$ dmesg --facility=daemon --level=debug

  • -u, --userspace to print only userspace messages

  • -k, --kernel to print only kernel messages

  • -t, --notime to skip [...] timestamps

  • -T, --ctime to print human readable timestamp in ctime()-like format. Unfortunately, this is useless on laptops if you have used suspend/resume. (The kernel does not use the standard system time as a source for printk() and it's not updated after resume.)

  • --show-delta to print time delta between printed messages
$ dmesg --show-delta
[35523.876281 < 4.016887>] usb 1-4.1: new low speed USB device using hci_hcd and address 12
[35523.968398 < 0.092117>] usb 1-4.1: New USB device found, idVendor=413c, idProduct=2003
[35523.968408 < 0.000010>] usb 1-4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[35523.968416 < 0.000008>] usb 1-4.1: Product: Dell USB Keyboard