Dmesgh: Unterschied zwischen den Versionen

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: «#!/usr/bin/perl # # dmesgh: (c) 2011 by Peter_Siegrist(SystemLoesungen) <PSS@ZweierNet.ch> # This is Free Software. # # Program dmesgh is a dmesg wrapper that pr…»)
 
 
Zeile 1: Zeile 1:
 +
<syntaxhighlight lang="perl">
 +
 
#!/usr/bin/perl
 
#!/usr/bin/perl
 
#
 
#
Zeile 20: Zeile 22:
 
print "[", POSIX::strftime("%b %d %H:%M:%S", localtime($tim)), ".${dmsec}] $rest\n";
 
print "[", POSIX::strftime("%b %d %H:%M:%S", localtime($tim)), ".${dmsec}] $rest\n";
 
}
 
}
 +
 +
 +
</syntaxhighlight>

Aktuelle Version vom 10. September 2015, 01:32 Uhr

#!/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";
}