解码来自wtmp的所有logging

根据手册页http://linux.die.net/man/5/wtmp的Linux日志/var/log/wtmp为许多系统事件存储“utmp”事件,比如login到它(LOGIN_PROCESS ut_type ),改变运行级别(RUN_LVL ut_type )等。

还有last实用程序,它分析wtmp并打印login到系统中的人员以及何时重新启动。

有没有工具来显示wtmp日志中的其他logging?

将信息写入wtmp日志的过程是什么?

你应该看看审计日志。

尝试使用ausearch ,它提供了什么utmp和更多。

wtmp文件有几个简单的perlparsing器,比如“Brocade Blue”的wtmp.pl

http://brocadeblue.blogspot.com/2012/10/perl-script-to-parse-wtmp-logs.html

wtmp.pl完整源代码, wtmp.pl了一些小错别字:

 #!/usr/bin/perl @type = ( "Empty", "Run Lvl", "Boot", "New Time", "Old Time", "Init", "Login", "Normal", "Term", "Account" ); $recs = ""; while (<>) { $recs .= $_; } foreach ( split( /(.{384})/s, $recs ) ) { next if length($_) == 0 ; my ( $type, $pid, $line, $inittab, $user, $host, $t1, $t2, $t3, $t4, $t5 ) = $_ =~ /(.{4})(.{4})(.{32})(.{4})(.{32})(.{256})(.{4})(.{4})(.{4})(.{4})(.{4})/s; if ( defined $line && $line =~ /\w/ ) { ##FILTER $line =~ s/\x00+//g; $host =~ s/\x00+//g; $user =~ s/\x00+//g; printf( "%s %-8s %-12s %10s %-45s \n", scalar( gmtime( unpack( "I4", $t3 ) ) ), $type[ unpack( "I4", $type ) ], $user, $line, $host ); } } printf "\n" 

该脚本可能无法在64位机器上运行。 (.{4})的“384”和长行应该在64位环境中修复。

PS:查看真正的所有logging,禁用expression式中标有“ ##FILTER ”的if