How to enable time stamps for logs in 'dmesg' on Gaia and SecurePlatform
2016-03-29 09:20
1346 查看
Symptoms
Logs that are written into
Cause
Default configuration.
Solution
Table of Contents:
Background
Enable time stamps at runtime (on-the-fly)
Enable time stamps at boot time (permanently)
Time stamp conversion algorithm
For troubleshooting purposes, it can be helpful to have time stamps for logs that are written into
ring buffer.
Important Note: The time stamps are printed in "seconds since boot". The system uptime can be helpful to calculate an absolute time stamp if needed (run the '
Run this command in Expert mode:
Check whether the logs are written with time stamps:
Send a test message:
Check the
Should see an output similar to this:
The relevant command can be added to the existing Linux start-up script
As a best practice, it is recommended to create a separate start-up script
Verify that
Run the following command in Expert mode:
Should get the following output:
Create the start-up script for user-defined commands:
Add these lines into the
Assign the relevant permissions to the script file:
Reboot the machine.
Note: Time stamps will be enabled after the kernel has correctly booted up.
Check whether the logs are written with time stamps:
Should see an output similar to this:
Important Note: The time stamps are printed in "seconds since boot" (this is the way the kernel is programmed to print the time stamps, and it can not be changed to print the time stamps in a human readable format). The system uptime
can be helpful to calculate an absolute time stamp if needed (run the '
The algorithm below for converting the printed time stamps to a human readable format is demonstrated on the example given above:
Take the log's time stamp in seconds:
Divide the time stamp in seconds by 60 to get the total amount of minutes:
Divide the time stamp in minutes by 60 to get the total amount of hours:
Break the decimal number into 2 parts:
Use the time conversion charts below to convert decimal hours to minutes:
Note: For more precise conversion (down to seconds), you can use various time converters available on the Internet. Just search for 'convert decimal time' in any search engine.
Hence, we get that the log was created this amount of time since boot:
Check the current system's uptime:
To get the log's real time stamp, subtract the log's time stamp in
Time conversion chart (Decimal Hours --> Minutes)
Time conversion chart (Minutes --> Decimal Hours)
Logs that are written into
dmesgkernel ring buffer do not have timestamps.
Cause
Default configuration.
Solution
Table of Contents:
Background
Enable time stamps at runtime (on-the-fly)
Enable time stamps at boot time (permanently)
Time stamp conversion algorithm
Background
For troubleshooting purposes, it can be helpful to have time stamps for logs that are written into dmesgkernel
ring buffer.
Important Note: The time stamps are printed in "seconds since boot". The system uptime can be helpful to calculate an absolute time stamp if needed (run the '
uptime' command).
Enable time stamps at runtime (on-the-fly)
Run this command in Expert mode:[Expert@HostName]# echo 1 > /sys/module/printk/parameters/printk_time
Check whether the logs are written with time stamps:
Send a test message:
[Expert@HostName]# echo "hello world" > /dev/kmsg
Check the
dmesgkernel ring buffer:
[Expert@HostName]# dmesg | tail -n 5
Should see an output similar to this:
.............. [196149.728085] hello world
Enable time stamps at boot time (permanently)
The relevant command can be added to the existing Linux start-up script /etc/rc.d/rc.local.
As a best practice, it is recommended to create a separate start-up script
/etc/rc.d/rc.local.userto separate Linux OS initialization commands from user-defined commands.
Verify that
/etc/rc.d/rc.localstart-up script contains the call for
/etc/rc.d/rc.local.userscript:
Run the following command in Expert mode:
[Expert@HostName]# grep -C 1 'rc.local.user' /etc/rc.d/rc.local
Should get the following output:
if [ -f /etc/rc.d/rc.local.user ]; then . /etc/rc.d/rc.local.user fi
Create the start-up script for user-defined commands:
[Expert@HostName]# touch /etc/rc.d/rc.local.user
Add these lines into the
/etc/rc.d/rc.local.userscript:
#!/bin/sh # # enable time stamps in dmesg echo 1 > /sys/module/printk/parameters/printk_time
Assign the relevant permissions to the script file:
[Expert@HostName]# chmod -v u=rwx,g=rx,o=rx /etc/rc.d/rc.local.user
Reboot the machine.
Note: Time stamps will be enabled after the kernel has correctly booted up.
Check whether the logs are written with time stamps:
[Expert@HostName]# dmesg | tail -n 5
Should see an output similar to this:
.............. [196149.728085] hello world
Time stamp conversion algorithm
Important Note: The time stamps are printed in "seconds since boot" (this is the way the kernel is programmed to print the time stamps, and it can not be changed to print the time stamps in a human readable format). The system uptimecan be helpful to calculate an absolute time stamp if needed (run the '
uptime' command).
The algorithm below for converting the printed time stamps to a human readable format is demonstrated on the example given above:
[196149.728085] hello world
Take the log's time stamp in seconds:
196149.728085 seconds(round the number down/up if needed)
Divide the time stamp in seconds by 60 to get the total amount of minutes:
196150 : 60 = 3269.1667 minutes(round the number down/up if needed)
Divide the time stamp in minutes by 60 to get the total amount of hours:
3269.1667 : 60 = 54.486111666666666666666666666667 hours
Break the decimal number into 2 parts:
54.486111666666666666666666666667 hours = (54 hours) + (0.486111666666666666666666666667 decimal hours)
Use the time conversion charts below to convert decimal hours to minutes:
0.486111666666666666666666666667 decimal hours ~ 0.48 decimal hours ~ 29 minutes
Note: For more precise conversion (down to seconds), you can use various time converters available on the Internet. Just search for 'convert decimal time' in any search engine.
Hence, we get that the log was created this amount of time since boot:
196149.728085 seconds ~ 54 hours 29 minutes
Check the current system's uptime:
[Expert@HostName]# uptime
To get the log's real time stamp, subtract the log's time stamp in
dmesgkernel ring buffer from the current system's uptime.
Time conversion chart (Decimal Hours --> Minutes)
Hour/100 | Minutes | Hour/100 | Minutes | Hour/100 | Minutes | Hour/100 | Minutes | |||
0.01 | 1 | 0.26 | 16 | 0.51 | 31 | 0.76 | 46 | |||
0.02 | 1 | 0.27 | 16 | 0.52 | 31 | 0.77 | 46 | |||
0.03 | 2 | 0.28 | 17 | 0.53 | 32 | 0.78 | 47 | |||
0.04 | 2 | 0.29 | 17 | 0.54 | 32 | 0.79 | 47 | |||
0.05 | 3 | 0.30 | 18 | 0.55 | 33 | 0.80 | 48 | |||
0.06 | 4 | 0.31 | 19 | 0.56 | 34 | 0.81 | 49 | |||
0.07 | 4 | 0.32 | 19 | 0.57 | 34 | 0.82 | 49 | |||
0.08 | 5 | 0.33 | 20 | 0.58 | 35 | 0.83 | 50 | |||
0.09 | 5 | 0.34 | 20 | 0.59 | 35 | 0.84 | 50 | |||
0.10 | 6 | 0.35 | 21 | 0.60 | 36 | 0.85 | 51 | |||
0.11 | 7 | 0.36 | 22 | 0.61 | 37 | 0.86 | 52 | |||
0.12 | 7 | 0.37 | 22 | 0.62 | 37 | 0.87 | 52 | |||
0.13 | 8 | 0.38 | 23 | 0.63 | 38 | 0.88 | 53 | |||
0.14 | 8 | 0.39 | 23 | 0.64 | 38 | 0.89 | 53 | |||
0.15 | 9 | 0.40 | 24 | 0.65 | 39 | 0.90 | 54 | |||
0.16 | 10 | 0.41 | 25 | 0.66 | 40 | 0.91 | 55 | |||
0.17 | 10 | 0.42 | 25 | 0.67 | 40 | 0.92 | 55 | |||
0.18 | 11 | 0.43 | 26 | 0.68 | 41 | 0.93 | 56 | |||
0.19 | 11 | 0.44 | 26 | 0.69 | 41 | 0.94 | 56 | |||
0.20 | 12 | 0.45 | 27 | 0.70 | 42 | 0.95 | 57 | |||
0.21 | 13 | 0.46 | 28 | 0.71 | 43 | 0.96 | 58 | |||
0.22 | 13 | 0.47 | 28 | 0.72 | 43 | 0.97 | 58 | |||
0.23 | 14 | 0.48 | 29 | 0.73 | 44 | 0.98 | 59 | |||
0.24 | 14 | 0.49 | 29 | 0.74 | 44 | 0.99 | 59 | |||
0.25 | 15 | 0.50 | 30 | 0.75 | 45 | 1.00 | 60 |
Minutes | Hours/100 | Minutes | Hours/100 | Minutes | Hours/100 | Minutes | Hours/100 | |||
1 | 0.02 | 16 | 0.27 | 31 | 0.52 | 46 | 0.77 | |||
2 | 0.03 | 17 | 0.28 | 32 | 0.53 | 47 | 0.78 | |||
3 | 0.05 | 18 | 0.30 | 33 | 0.55 | 48 | 0.80 | |||
4 | 0.07 | 19 | 0.32 | 34 | 0.57 | 49 | 0.82 | |||
5 | 0.08 | 20 | 0.33 | 35 | 0.58 | 50 | 0.84 | |||
6 | 0.10 | 21 | 0.35 | 36 | 0.60 | 51 | 0.85 | |||
7 | 0.12 | 22 | 0.37 | 37 | 0.62 | 52 | 0.87 | |||
8 | 0.13 | 23 | 0.38 | 38 | 0.63 | 53 | 0.89 | |||
9 | 0.15 | 24 | 0.40 | 39 | 0.65 | 54 | 0.90 | |||
10 | 0.17 | 25 | 0.42 | 40 | 0.67 | 55 | 0.92 | |||
11 | 0.18 | 26 | 0.43 | 41 | 0.68 | 56 | 0.94 | |||
12 | 0.20 | 27 | 0.45 | 42 | 0.70 | 57 | 0.95 | |||
13 | 0.22 | 28 | 0.47 | 43 | 0.72 | 58 | 0.97 | |||
14 | 0.23 | 29 | 0.48 | 44 | 0.73 | 59 | 0.99 | |||
15 | 0.25 | 30 | 0.50 | 45 | 0.75 | 60 | 1.00 |
相关文章推荐
- 设计模式 ( 十二 ) 职责链模式(Chain of Responsibility)(对象行为)
- C++中placement new操作符(经典) http://blog.csdn.net/zhangxinrun/article/details/5940019
- Failure[INSTALL_FAILED_INSUFFICIENT_STORAGE]调试问题
- django种表单post出现CSRF verification failed( CSRF验证失败 ) 的两种解决方式
- Code Forces 652C Foe Pairs
- Code Forces 652C Foe Pairs
- 关于 error: LNK1123: failure during conversion to COFF: file invalid or corrupt 错误的解决
- strong weak assign retain
- 绑定服务 aidl 的应用
- openstack ice版availability zones host aggregates 实战详解
- Relay log read failure: Could not parse relay log
- 并发之notify、wait笔记
- flash跨域策略文件crossdomain.xml配置详解
- Aizu 0525(Osenbei 穷竭搜索)
- Rails--render partial时传递参数
- 板载RAID
- AI-->从新建文档开始说起,串联相关色彩知识
- 如何判断盒子的containing block
- PipeMapRed.waitOutputThreads(): subprocess failed with code N
- 跨域策略文件--crossdomain.xml