Commit | Line | Data |
---|---|---|
5e0cbfb0 PP |
1 | --- |
2 | id: lttng-live | |
86384750 | 3 | since: 2.4 |
5e0cbfb0 PP |
4 | --- |
5 | ||
6 | We have seen how trace files may be produced by LTTng out of generated | |
7 | application and Linux kernel events. We have seen that those trace files | |
8 | may be either recorded locally by consumer daemons or remotely using | |
9 | a relay daemon. And we have seen that the maximum size and count of | |
10 | trace files is configurable for each channel. With all those features, | |
11 | it's still not possible to read a trace file as it is being written | |
12 | because it could be incomplete and appear corrupted to the viewer. | |
13 | There is a way to view events as they arrive, however: using | |
14 | _LTTng live_. | |
15 | ||
16 | LTTng live is implemented, in LTTng, solely on the relay daemon side. | |
17 | As trace data is sent over the network to a relay daemon by a (possibly | |
47bfcb75 PP |
18 | remote) consumer daemon, a _tee_ is created: trace data is recorded to |
19 | trace files _as well as_ being transmitted to a connected live viewer: | |
5e0cbfb0 | 20 | |
5703c9f3 | 21 | <figure class="img img-100"> |
b2c331ac | 22 | <img src="/images/docs26/lttng-live.png" alt="LTTng live"> |
d9a0e8b1 PP |
23 | <figcaption> |
24 | The relay daemon creates a <em>tee</em>, forwarding the trace data | |
25 | to both trace files and a live viewer. | |
26 | </figcaption> | |
5703c9f3 | 27 | </figure> |
5e0cbfb0 PP |
28 | |
29 | In order to use this feature, a tracing session must created in live | |
30 | mode on the target system: | |
31 | ||
32 | <pre class="term"> | |
33 | lttng create --live | |
34 | </pre> | |
35 | ||
47bfcb75 PP |
36 | An optional parameter may be passed to `--live` to set the period |
37 | (in microseconds) between flushes to the network | |
38 | (1 second is the default). With: | |
5e0cbfb0 PP |
39 | |
40 | <pre class="term"> | |
41 | lttng create --live 100000 | |
42 | </pre> | |
43 | ||
47bfcb75 | 44 | the daemons flush their data every 100 ms. |
5e0cbfb0 PP |
45 | |
46 | If no network output is specified to the `create` command, a local | |
47bfcb75 | 47 | relay daemon is spawned. In this very common case, viewing a live |
5e0cbfb0 PP |
48 | trace is easy: enable events and start tracing as usual, then use |
49 | `lttng view` to start the default live viewer: | |
50 | ||
51 | <pre class="term"> | |
52 | lttng view | |
53 | </pre> | |
54 | ||
47bfcb75 | 55 | The correct arguments are passed to the live viewer so that it |
5e0cbfb0 PP |
56 | may connect to the local relay daemon and start reading live events. |
57 | ||
58 | You may also wish to use a live viewer not running on the target | |
59 | system. In this case, you should specify a network output when using | |
60 | the `create` command (`--set-url` or `--ctrl-url`/`--data-url` options). | |
61 | A distant LTTng relay daemon should also be started to receive control | |
62 | and trace data. By default, `lttng-relayd` listens on 127.0.0.1:5344 | |
63 | for an LTTng live connection. Otherwise, the desired URL may be | |
64 | specified using its `--live-port` option. | |
65 | ||
66 | The | |
1bf7ee86 | 67 | <a href="http://diamon.org/babeltrace" class="ext">`babeltrace`</a> |
5e0cbfb0 PP |
68 | viewer supports LTTng live as one of its input formats. `babeltrace` is |
69 | the default viewer when using `lttng view`. To use it manually, first | |
70 | list active tracing sessions by doing the following (assuming the relay | |
71 | daemon to connect to runs on the same host): | |
72 | ||
73 | <pre class="term"> | |
b80ba306 | 74 | babeltrace --input-format lttng-live net://localhost |
5e0cbfb0 PP |
75 | </pre> |
76 | ||
77 | Then, choose a tracing session and start viewing events as they arrive | |
4d46e8c0 | 78 | using LTTng live: |
5e0cbfb0 PP |
79 | |
80 | <pre class="term"> | |
b80ba306 | 81 | babeltrace --input-format lttng-live net://localhost/host/hostname/my-session |
5e0cbfb0 | 82 | </pre> |