LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-07-2014, 07:57 AM   #1
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 293

Rep: Reputation: 41
Interpreting the time in dmesg data


The dmesg log has lines like this:

[97082.333768] ehci-pci 0000:00:1d.0: setting latency timer to 64

How can I determine the clock time when this message was issued?
 
Old 02-07-2014, 08:37 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
The timestamp in dmesg is in number of seconds.nanoseconds from the system start-up, therefore you should retrieve the start-up time (as returned by the uptime command or from /proc/uptime) and do some calculations. Here is a little awk program to do the trick:
Code:
BEGIN {
  "cat /proc/uptime" | getline result
  split(result,uptime)
  start = systime() - int(uptime[1])
}

$1 ~ /\[[0-9.]+\]/ {
  gsub(/\[|\]/,"",$1)
  $1 = ("[" strftime("%c",start+int($1)) "]")
}

1
or in a single (long) command line:
Code:
dmesg | awk 'BEGIN {"cat /proc/uptime" | getline result; split(result,uptime); start = systime() - int(uptime[1])} $1 ~ /\[[0-9.]+\]/ {gsub(/\[|\]/,"",$1); $1 = ("[" strftime("%c",start+int($1)) "]")}1'

Last edited by colucix; 02-07-2014 at 08:46 AM. Reason: Changed time format.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need help interpreting my filesystem benchmark data H_TeXMeX_H Linux - General 15 07-16-2013 03:46 AM
Interpreting dmesg output pwabrahams Linux - Software 2 09-02-2008 01:27 PM
Interpreting bootchart data ShodoPan Linux - General 1 09-12-2006 07:22 AM
Sending and interpreting data using http-post rj1 Programming 3 05-28-2005 02:21 AM
reading & interpreting data from /dev/gpmdata Zither Programming 1 11-02-2003 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration