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

18 comments:

  1. Thanks for posting about this. Wow this is really sweet!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. How about a tail -f functionality, so that it can follow new kernel messages?

    ReplyDelete
  4. Landtuna, the UNIX philosophy is to do one thing and do it well. Tail -f already exists, so why duplicate that functionality in dmesg? You can always just do dmesg|tail -f

    ReplyDelete
  5. Cyde, that won't work. tail -f works by checking the file constantly (or perhaps using one of the more recent APIs to have the kernel do the checking). dmesg is a program that spits out results and quits, there's nothing for tail -f to work with.

    (In general, it never makes sense to pipe into tail -f, only to run tail -f on a file(s).)

    ReplyDelete
  6. ad dmesg -f, this is already in util-linux TODO, but it's not so simple.

    http://www.spinics.net/lists/util-linux-ng/msg04491.html

    http://www.spinics.net/lists/util-linux-ng/msg04498.html

    We will see.

    ReplyDelete
  7. @Cyde Weys then why is he adding flags that we could just grep for, hmm?

    ReplyDelete
  8. $ watch 'dmesg | tail'

    I usually resort to this... but tailing it properly would be nice.

    ReplyDelete
  9. This is great, thanks!

    ReplyDelete
  10. Thanks for the post. I liked it. Keep going I follow you.
    Vee Eee Technologies

    ReplyDelete
  11. Thanks for the information .Best one

    web design companies in vizag

    We are Best Web Designing Companies in vizag if your are looking for web designing services in visakhapatnam we are the Best website designers in vizag.

    ReplyDelete
  12. Thanks for sharing helpful article I liked it. Keep going I follow you.

    ReplyDelete