Last active
October 21, 2019 01:58
-
-
Save jason-riddle/9466005cbb584f13c42dbcd93a5eeddd to your computer and use it in GitHub Desktop.
Revisions
-
jason-riddle revised this gist
Oct 21, 2019 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,6 @@ # desired date format date_format="%Y-%m-%dT%H:%M:%SZ" # [ 3.469072] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null) # [ 3.483769] dracut: Remounting /dev/disk/by-label/\x2f with -o noatime,ro # [ 3.495019] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null) @@ -16,7 +12,7 @@ uptime=$(awk '{print $1}' /proc/uptime) # run only if timestamps are enabled if [ "Y" = "$(cat /sys/module/printk/parameters/time)" ]; then dmesg | sed "s/^\[[ ]*\?\([0-9.]*\)\] \(.*\)/\\1 \\2/" | while read timestamp message; do printf "[%s] %s\n" "$(date --date "now - $(awk '{print $1}' /proc/uptime) seconds + $timestamp seconds" +"${date_format}")" "$message" done else echo "Timestamps are disabled (/sys/module/printk/parameters/time)" -
jason-riddle created this gist
Oct 21, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #!/bin/bash # Translate dmesg timestamps to human readable format # desired date format date_format="%Y-%m-%dT%H:%M:%SZ" # uptime in seconds # 2153.54 1953.49 uptime=$(awk '{print $1}' /proc/uptime) # [ 3.469072] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null) # [ 3.483769] dracut: Remounting /dev/disk/by-label/\x2f with -o noatime,ro # [ 3.495019] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null) # [ 3.506417] dracut: Mounted root filesystem /dev/xvda1 # run only if timestamps are enabled if [ "Y" = "$(cat /sys/module/printk/parameters/time)" ]; then dmesg | sed "s/^\[[ ]*\?\([0-9.]*\)\] \(.*\)/\\1 \\2/" | while read timestamp message; do printf "[%s] %s\n" "$(date --date "now - $uptime seconds + $timestamp seconds" +"${date_format}")" "$message" done else echo "Timestamps are disabled (/sys/module/printk/parameters/time)" fi