4 This is a brief howto for using the lttng-tools Python module.
6 By default, the Python bindings are not installed.
7 If you wish the Python bindings, you can configure with the
8 --enable-python-bindings option during the installation procedure:
10 $ ./configure --enable-python-bindings
12 The Python module is automatically generated using SWIG, therefore the
13 swig2.0 package on Debian/Ubuntu is requied.
15 Once installed, the Python module can be used by importing it in Python.
16 In the Python interpreter:
23 Quick example using Python to trace with LTTng.
29 2) Import the lttng module
35 >>> lttng.create("session-name", "path/to/trace")
37 4) Create a handle for the tracing session and domain
39 >>> domain = lttng.Domain()
40 >>> domain.type = lttng.DOMAIN_KERNEL *
41 >>> handle = lttng.Handle("session-name", domain)
43 * This line is somewhat useless since domain.type is set to 0
44 by default, the corresponding value of lttng.DOMAIN_KERNEL
46 5) Enable all Kernel events
48 >>> event = lttng.Event()
49 >>> event.type = lttng.EVENT_TRACEPOINT *
50 >>> event.loglevel_type = lttng.EVENT_LOGLEVEL_ALL *
51 >>> lttng.enable_event(handle, event, None)
53 * These two lines are somewhat useless since event.type
54 and event.loglevel_type are by default set to 0, the
55 corresponding value of lttng.EVENT_TRACEPOINT and
56 lttng.EVENT_LOGLEVEL_ALL
60 >>> lttng.start("session-name")
64 >>> lttng.stop("session-name")
66 7) Destroy the tracing session
68 >>> lttng.destroy("session-name")
70 For an example script with more details, see extras/bindings/swig/python/tests/example.py