Dmesgh

Aus SiWiki
Wechseln zu: Navigation, Suche
#!/usr/bin/perl
#
# dmesgh: (c) 2011 by Peter_Siegrist(SystemLoesungen) <PSS@ZweierNet.ch>
# This is Free Software.
#
# Program dmesgh is a dmesg wrapper that prints out the dmesg timestamp (uptime) in a human readable form :)
# usage: dmesgh
#
 
use POSIX qw(strftime);
 
my $t0 = time() - int((split(' ', `cat /proc/uptime`))[0]);
 
foreach ( `dmesg` ) {
	chomp;
	next if $_ !~ /^\[\s*(\d+)\.(\d+)\s*\]\s+(.*)/;
	my $tim = $t0 + $1;
	my $dmsec = substr($2,0,3);
	my $rest = $3;
	print "[", POSIX::strftime("%b %d %H:%M:%S", localtime($tim)), ".${dmsec}] $rest\n";
}