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