Linux Trace Toolkit Viewer 的使用


Linux Trace Toolkit (LTT)能够从内核获得所有的执行信息。
它基于内核工具和高速中继文件系统来从内核空间拷贝信息到用户空间。

Linux Trace Toolkit Viewer (LTTV)是个可视化工具。

- 使用图形模式
$ lttv-gui
------------
- 在/usr/local/lib/lttv/plugins目录下能够看到所有的模块。
  获得相应模块的帮助使用:
  $ lttv -L /usr/local/lib/lttv/plugins -m textDump --help

 -使用LTTV 字符模式
$ lttv -L path/to/lib/plugins -m batchAnalysis -t trace1 -t trace2 ...
$  lttv -L /usr/local/lib/lttv/plugins -m  batchAnalysis -t  //????? trace1的名字??

$ lttv -L path/to/lib/plugins -m batchAnalysis -s -m textDump -s -t trace
===========?????? ==========
系统配置:
#mkdir /mnt/debugfs
#cp /etc/fstab /etc/fstab.lttng.bkp  //备份文件
#echo "debugfs    /mnt/debugfs    debugfs  rw 0 0" >> /etc/fstab
重启,或者,
# mount  /mnt/debugfs 激活 debugfs

必须加载LTT模块来控制对用户空间的跟踪。
通过执行如下的命令完成。
modprobe ltt-trace-control
modprobe ltt-marker-control
modprobe ltt-tracer
modprobe ltt-relay
modprobe ipc-trace
modprobe kernel-trace
modprobe mm-trace
modprobe net-trace
modprobe fs-trace
modprobe jbd2-trace
modprobe ext4-trace
modprobe syscall-trace
modprobe trap-trace
modprobe block-trace

#if locking tracing is wanted, uncomment the following
#如果想锁住跟踪,就执行下面的命令
#modprobe lockdep-trace

要得到完全的内核状态的信息(包括所有进程的名字),那么需要加载ltt-statedump模块。
#modprobe ltt-statedump

要在启动时自动完成上面的过程,可以
cp /etc/modules /etc/modules.bkp
echo ltt-trace-control >> /etc/modules
echo ltt-marker-control >> /etc/modules
echo ltt-tracer >> /etc/modules
echo ltt-relay >> /etc/modules
echo ipc-trace >> /etc/modules
echo kernel-trace >> /etc/modules
echo mm-trace >> /etc/modules
echo net-trace >> /etc/modules
echo fs-trace >> /etc/modules
echo jbd2-trace >> /etc/modules
echo ext4-trace >> /etc/modules
echo syscall-trace >> /etc/modules
echo trap-trace >> /etc/modules

#if locking tracing is wanted, uncomment the following
#echo lockdep-trace >> /etc/modules

用户空间的跟踪:

确保内核配置时:
<M> 或 <*> Support logging events from userspace
并且,如果ltt-userspace-event 内核模块作为模块被编译的话,
那么,要加载该模块
#modprobe ltt-userspace-event
Simple userspace tracing is available through
echo "some text to record" > /mnt/debugfs/ltt/write_event

It will appear in the trace under event :
channel : userspace
event name : event

LTTng 和 LTTV的使用

=====使用 图形化的LTTV来控制和分析跟踪:
#ttv-gui
  -点击 “tracing Control " 图标(交通灯的图标)
  - 输入 root的密码
  - 点击“start“, ”stop'...
- 使用字符模式LTTng来控制跟踪:
  开始跟踪:
   #lttctl -C -w /tmp/trace1 trace1
  停止跟踪销毁跟踪通道:
    #lttctl -D trace1
   更多的细节,查看 lttctl --help

====使用字符模式LTTV

在/usr/local/lib/lttv/plugins 下,有所有的字符和图形模式的插件。
#lttv -m textDump -t /tmp/trace
   //执行后,我的终端输出了????
    /tmp/trace: No such file or directory
   ** (process:10813): CRITICAL **: cannot open trace /tmp/trace
   /usr/local/bin/lttv: line 15: 10813 段错误               $0.real "$@"

#lttv -m textDump --help //获取帮助

=== 使用“混合”模式跟踪
创建一个跟踪通道,在普通通道上启动lttd, 开始跟踪:
# lttctl -C -w /tmp/trace2 -o channel.kernel.overwrite=1 trace2  
   Linux Trace Toolkit Trace Control 0.89-05122011
   Controlling trace : trace2
    lttctl: Creating trace
    lttctl_sendop: open /sys/kernel/debug/ltt/control/trace2/channel/kernel/overwrite failed: No such file or directory
     Set channel's overwrite mode failed
停止跟踪,在flight recorder channels,销毁跟踪通道:
# lttctl -D -w /tmp/trace2 trace2

=== Flight recorder mode

The flight recorder mode writes data into overwritten buffers for all channels, including control channels, except for the facilities tracefiles. It consists of setting all channels to "overwrite".

The following lttctl commands take a flight recorder trace :

lttctl -C -w /tmp/trace3 -o channel.all.overwrite=1 trace3
...
lttctl -D -w /tmp/trace3 trace3

相关内容