终端交互日志工具 TILT
TILT (Terminal Interaction Logging Tool),终端交互日志工具
1、安装 gcc和make
yum install make gcc -y
2、安装tilt还需要创建tilt用户:
useradd tilt
passwd tilt
3、下载并解压源码,
wget http://nchc.dl.sourceforge.net/project/tilt/tilt/tilt-0.1.1.tgz/tilt-0.1.1.tgz
tar xf tilt-0.1.1.tgz
cd tilt-0.1.1
修改配置文件
vim tilt-0.1.1/src/tilt.c
#define LOGPATH “/var/log/tilt”,将路径修改为自己需要的目录,并保证目录存在,且对tilt用户
具有可写权限。修改源代码中的日志路径:
4、编译安装tilt
mkdir /opt/tilt
chmod 755 /opt/tilt
./configure --prefix=/opt/tilt
make && make install
5、修改
vim /etc/modprobe.conf
alias ssh /opt/tilt/bin/ssh
alias telnet /opt/tilt/bin/telnet
5、测试
登录以后,执行某些命令(如ls、ifconfig等)以后,在自定义的日志目录下会产生当前日期的目录,目录下就是刚才操作的日志文件,但是日志文件还不能直接查看,需要用tilt自带的dumplog命令来查看。
6、查看日志
cd /var/log/tilt/
日志文件按照日期保存
dumplog /var/log/tilt/2014-06-12/B-root-2014-06-2-16\:29\:42--opt-tilt-bin-ssh\ root\@1.1.1.1
查看详细日志
# ./dumplog -h
Usage: ./dumplog [OPTION]... [FILE]...
Dump logs generated by TILT in a human readable form
-s Print in real time equivalent to -m1
-m NUM Print NUM times faster than real time
-h Print with human readable time stamps at the beginning of
each new line this overrides -t
-t Print time stamps as seconds since 1970-01-01 00:00:00 UTC
at the beginning of each new line
-r attempt to resize the terminal to the recorded size
-S, --start start dump at time offset
-E, --end end dump at time offset
-e, --grep only print lines that match the regexp
-i, ignore case in regexp
-p, attempt to remove backspaces from each line in regexp match
-c, attempt to remove backspaces from each line and cisco line wraps in regexp match
-H, print each match with filename
-?, --help display this help and exit