LTTng: (Linux Trace Toolkit Next Generation),它是用于跟踪 Linux 内核、应用程序以及库的系统软件包。LTTng 主要由内核模块和动态链接库(用于应用程序和动态链接库的跟踪)组成。它由一个会话守护进程控制,该守护进程接受来自命令行接口的命令。babeltrace 项目允许将追踪信息翻译成用户可读的日志,并提供一个读追踪库,即 libbabletrace。


LTTng 不仅使用了 Linux 内核中的追踪点(tracepoint)手段,而且使用了其他各种信息来源,比如kprobes 和 Perf(Linux 中的性能监检测工具)。这对于调试大范围内的bug 是非常有用的,否则这种调试工作将极具挑战性。比如,包括并行系统和实时系统中的性能问题。另外,用户自己定制的工具也可以加入到其中。LTTng 的设计目标是将性能影响最小化,而且在没有跟踪的情况下,对系统的影响应该几乎为零。

 
<span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">(1)安装</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">Lttng</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">:</span>

<span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">&nbsp;使用的是</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">CentOS</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">,所以按照</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">RHEL</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">的</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">文档</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">,使用</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">yum</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">方式安装:</span>




##


##
Red Hat Enterprise Linux 7

</div>

###
Installing using Yum

<div style="color: rgb(128, 128, 128); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: 200; background-color: rgb(255, 255, 255);">
    <div style="background-color: inherit;">
        <span style="text-align: left; color: rgb(0, 0, 0); font-family: Arial; font-size: 18px; font-style: normal; font-weight: normal; background-color: rgb(255, 255, 255);">Add the official EfficiOS RHEL7 package repository to your system.</span>

        <pre style="color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; font-style: normal; background-color: rgb(245, 245, 245);">

wget -P /etc/yum.repos.d/ https://packages.efficios.com/repo.files/EfficiOS-RHEL7-x86-64.repo
Import our package signing key.

<pre style="color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; font-style: normal; background-color: rgb(245, 245, 245);">

rpmkeys –import https://packages.efficios.com/rhel/repo.key
And update yum's package database.

<pre style="color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; font-style: normal; background-color: rgb(245, 245, 245);">

yum updateinfo




(2)接下来安装lttng软件包:
<span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">yum -y&nbsp;<span style="background-color: inherit;"><span style="background-color: inherit;">install</span> lttng-ust </span><span style="background-color: inherit;">kmod-lttng-modules <span style="background-color: inherit;"><span style="background-color: inherit;">lttng-modules-debuginfo</span></span></span><span style="background-color: inherit;"><span style="background-color: inherit;"><span style="background-color: inherit;">lttng-tools-debuginfo </span></span><span style="background-color: inherit;"><span style="background-color: inherit;">lttng-ust-debuginfo </span></span></span></span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">babeltrace </span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">babeltrace</span><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">-devel <span style="background-color: inherit;"><span style="background-color: inherit;">babeltrace-debuginfo <span style="background-color: inherit;">userspace-rcu-debuginfo&nbsp;</span></span></span></span>


# lttng -V
<div style="background-color: inherit;">
    lttng&nbsp;(LTTng&nbsp;Trace&nbsp;Control)&nbsp;2.8.1&nbsp;-&nbsp;Isseki&nbsp;Nicho
</div>
&nbsp;

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    <font color="#91170a" face="Helvetica Neue, Helvetica, Arial, sans-serif" style="background-color: inherit;">如果要用python脚本,需要安装<span style="text-align: left; color: rgb(145, 23, 10); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; background-color: rgb(255, 255, 255);">python3环境</span></font>
</div>

<div style="background-color: inherit;">
    <font color="#91170a" face="Helvetica Neue, Helvetica, Arial, sans-serif" style="background-color: inherit;">在</font><span style="line-height: 1.5; background-color: inherit;">&nbsp;yum&nbsp;-y&nbsp;install&nbsp;python33-lttngust&nbsp;python33-lttng&nbsp;python33-babeltrace</span>
</div>

<div style="background-color: inherit;">
    <pre style="font-family: Monaco, Consolas, Courier, &quot;Lucida Console&quot;, monospace; font-style: normal; background-color: inherit;">

 

<span style="background-color: inherit;"><span style="background-color: inherit;">测试一下:</span></span>

###
Tracing the Linux kernel

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

lttng <span style="font-size: 18px; background-color: transparent;"><span style="font-size: 18px; background-color: transparent;">create</span> my-<span style="font-size: 18px; background-color: transparent;">session</span></span>

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

<span style="font-size: 18px; background-color: transparent;"><span style="color: rgb(26, 26, 26); font-family: &quot;Open Sans&quot;, Frutiger, &quot;Frutiger Linotype&quot;, Univers, Calibri, &quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, &quot;Myriad Pro&quot;, Myriad, &quot;DejaVu Sans Condensed&quot;, &quot;Liberation Sans&quot;, &quot;Nimbus Sans L&quot;, Tahoma, Geneva, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: normal; background-color: rgb(253, 253, 253);">Let&#39;s now enable <span style="color: rgb(26, 26, 26); font-family: &quot;Open Sans&quot;, Frutiger, &quot;Frutiger Linotype&quot;, Univers, Calibri, &quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, &quot;Myriad Pro&quot;, Myriad, &quot;DejaVu Sans Condensed&quot;, &quot;Liberation Sans&quot;, &quot;Nimbus Sans L&quot;, Tahoma, Geneva, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: normal; background-color: rgb(253, 253, 253);">all available kernel events</span> for this session:</span> lttng enable-<span style="font-size: 18px; background-color: transparent;">event </span><span style="font-size: 18px; background-color: transparent;">--kernel --all</span></span>

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

参考手册:#man lttng-enable-event

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

<span style="font-size: 18px; background-color: transparent;"><span style="color: rgb(26, 26, 26); font-family: &quot;Open Sans&quot;, Frutiger, &quot;Frutiger Linotype&quot;, Univers, Calibri, &quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, &quot;Myriad Pro&quot;, Myriad, &quot;DejaVu Sans Condensed&quot;, &quot;Liberation Sans&quot;, &quot;Nimbus Sans L&quot;, Tahoma, Geneva, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: normal; background-color: rgb(253, 253, 253);">Start tracing:</span> lttng <span style="font-size: 18px; background-color: transparent;">start</span></span>

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

<span style="font-size: 18px; background-color: transparent;"><span style="color: rgb(26, 26, 26); font-family: &quot;Open Sans&quot;, Frutiger, &quot;Frutiger Linotype&quot;, Univers, Calibri, &quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, &quot;Myriad Pro&quot;, Myriad, &quot;DejaVu Sans Condensed&quot;, &quot;Liberation Sans&quot;, &quot;Nimbus Sans L&quot;, Tahoma, Geneva, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: normal; background-color: rgb(253, 253, 253);">done tracing:</span> lttng <span style="font-size: 18px; background-color: transparent;">stop</span> lttng destroy </span>

    <span style="background-color: inherit;"><span style="background-color: inherit;">接着执行`ls`命令:</span></span>

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

[root<span style="font-size: 18px; background-color: transparent;">@CentOS</span> ~]<span style="font-size: 18px; background-color: transparent;"># ls</span> anaconda-ks.cfg lttng-traces

<pre style="color: rgb(168, 38, 38); font-family: Monaco, Consolas, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 1.12rem; font-style: normal; font-weight: normal; background-color: inherit;">

cd/root/lttng-traces/my-session-20161009-111913/kernel

    <span style="background-color: inherit;"><span style="background-color: inherit;">可以看到抓的`trace`都在`lttng-traces`这个文件夹里。</span></span>

    &nbsp;

<div style="background-color: inherit;">
    <span style="font-size: 26px; background-color: inherit;"><span style="background-color: inherit;">&nbsp;解读&nbsp;</span><span style="background-color: inherit;">lttng-traces文件</span></span>
</div>

<div style="background-color: inherit;">
    <div style="color: rgb(34, 34, 34); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);">
        **Analyzing gathered data**
    </div>

<div style="color: rgb(34, 34, 34); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);">
    Usually a tracing session generates a huge amount of data, which makes it unreadable by humans. So LTTng project provides some visualizing tools to easy analysis of traced data, as follows:&nbsp;
</div>

<div style="color: rgb(34, 34, 34); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);">
  • Babeltrace

    *   It is a library and command-line tool able to read and convert trace data stored in different formats (including CTF).
    
  • LTTV Viewer

    *   It is a graphical visualizer (GTK+) able to make analysis of trace data produced by LTT, but it currently doesn&#39;t support CTF.
    
  • Eclipse LTTng

    *   The Eclipse LTTng is a set of plug-ins able to visualize LTTng gathered data. Currently it is maintained by a pretty active community.
        </div>
    </div>
    
    <div style="background-color: inherit;">
        &nbsp;
    </div>
    
    <div style="background-color: inherit;">
        <span style="background-color: inherit;">用<span style="background-color: inherit;">babeltrace命令</span></span>
    </div>
    
    <div style="background-color: inherit;">
        &nbsp;
    </div>
    
    <div style="background-color: inherit;">
        <div style="background-color: inherit;">
            #babeltrace&nbsp;/root/lttng-traces/my-session-20161009-111913/kernel/&nbsp;<span style="text-align: left; color: rgb(204, 51, 204); font-family: Helvetica, &quot;Microsoft Yahei&quot;, verdana; font-size: 18px; font-style: normal; font-weight: normal; background-color: rgb(255, 255, 255);"><span style="background-color: inherit;">&nbsp;</span></span><span style="line-height: 1.5; background-color: inherit;">&gt; /tmp/trace.txt</span>
        </div>
    </div>
    



#########################