56835625b2fc24348817e766bfbb35659cabf7f0
2 # Copyright (C) 2012 Danny Serres <danny.serres@efficios.com>
4 # SPDX-License-Identifier: GPL-2.0-only
6 # This example shows basically how to use the lttng-tools python module
11 # This error will be raised is something goes wrong
12 class LTTngError(Exception):
13 def __init__(self
, value
):
17 return repr(self
.value
)
20 # Setting up the domain to use
22 dom
.type = DOMAIN_KERNEL
24 # Setting up a channel to use
26 channel
.name
= "mychan"
27 channel
.attr
.overwrite
= 0
28 channel
.attr
.subbuf_size
= 4096
29 channel
.attr
.num_subbuf
= 8
30 channel
.attr
.switch_timer_interval
= 0
31 channel
.attr
.read_timer_interval
= 200
32 channel
.attr
.output
= EVENT_SPLICE
34 # Setting up some events that will be used
36 event
.type = EVENT_TRACEPOINT
37 event
.loglevel_type
= EVENT_LOGLEVEL_ALL
39 sched_switch
= Event()
40 sched_switch
.name
= "sched_switch"
41 sched_switch
.type = EVENT_TRACEPOINT
42 sched_switch
.loglevel_type
= EVENT_LOGLEVEL_ALL
44 sched_process_exit
= Event()
45 sched_process_exit
.name
= "sched_process_exit"
46 sched_process_exit
.type = EVENT_TRACEPOINT
47 sched_process_exit
.loglevel_type
= EVENT_LOGLEVEL_ALL
49 sched_process_free
= Event()
50 sched_process_free
.name
= "sched_process_free"
51 sched_process_free
.type = EVENT_TRACEPOINT
52 sched_process_free
.loglevel_type
= EVENT_LOGLEVEL_ALL
55 # Creating a new session
56 res
= create("test", "/lttng-traces/test")
58 raise LTTngError(strerror(res
))
62 han
= Handle("test", dom
)
64 raise LTTngError("Handle not created")
66 # Enabling the kernel channel
67 res
= enable_channel(han
, channel
)
69 raise LTTngError(strerror(res
))
71 # Enabling some events in given channel
72 # To enable all events in default channel, use
73 # enable_event(han, event, None)
74 res
= enable_event(han
, sched_switch
, channel
.name
)
76 raise LTTngError(strerror(res
))
78 res
= enable_event(han
, sched_process_exit
, channel
.name
)
80 raise LTTngError(strerror(res
))
82 res
= enable_event(han
, sched_process_free
, channel
.name
)
84 raise LTTngError(strerror(res
))
87 res
= disable_event(han
, sched_switch
.name
, channel
.name
)
89 raise LTTngError(strerror(res
))
91 # Getting a list of the channels
92 l
= list_channels(han
)
94 raise LTTngError(strerror(l
))
99 raise LTTngError(strerror(res
))
104 raise LTTngError(strerror(res
))
106 # Disabling a channel
107 res
= disable_channel(han
, channel
.name
)
109 raise LTTngError(strerror(res
))
111 # Destroying the handle
114 # Destroying the session
115 res
= destroy("test")
117 raise LTTngError(strerror(res
))
This page took 0.033112 seconds and 5 git commands to generate.