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
10 # This error will be raised is something goes wrong
11 class LTTngError(Exception):
12 def __init__(self
, value
):
15 return repr(self
.value
)
17 #Setting up the domain to use
19 dom
.type = DOMAIN_KERNEL
21 #Setting up a channel to use
23 channel
.name
= "mychan"
24 channel
.attr
.overwrite
= 0
25 channel
.attr
.subbuf_size
= 4096
26 channel
.attr
.num_subbuf
= 8
27 channel
.attr
.switch_timer_interval
= 0
28 channel
.attr
.read_timer_interval
= 200
29 channel
.attr
.output
= EVENT_SPLICE
31 #Setting up some events that will be used
33 event
.type = EVENT_TRACEPOINT
34 event
.loglevel_type
= EVENT_LOGLEVEL_ALL
36 sched_switch
= Event()
37 sched_switch
.name
= "sched_switch"
38 sched_switch
.type = EVENT_TRACEPOINT
39 sched_switch
.loglevel_type
= EVENT_LOGLEVEL_ALL
41 sched_process_exit
= Event()
42 sched_process_exit
.name
= "sched_process_exit"
43 sched_process_exit
.type = EVENT_TRACEPOINT
44 sched_process_exit
.loglevel_type
= EVENT_LOGLEVEL_ALL
46 sched_process_free
= Event()
47 sched_process_free
.name
= "sched_process_free"
48 sched_process_free
.type = EVENT_TRACEPOINT
49 sched_process_free
.loglevel_type
= EVENT_LOGLEVEL_ALL
52 #Creating a new session
53 res
= create("test","/lttng-traces/test")
55 raise LTTngError(strerror(res
))
59 han
= Handle("test", dom
)
61 raise LTTngError("Handle not created")
63 #Enabling the kernel channel
64 res
= enable_channel(han
, channel
)
66 raise LTTngError(strerror(res
))
68 #Enabling some events in given channel
69 #To enable all events in default channel, use
70 #enable_event(han, event, None)
71 res
= enable_event(han
, sched_switch
, channel
.name
)
73 raise LTTngError(strerror(res
))
75 res
= enable_event(han
, sched_process_exit
, channel
.name
)
77 raise LTTngError(strerror(res
))
79 res
= enable_event(han
, sched_process_free
, channel
.name
)
81 raise LTTngError(strerror(res
))
84 res
= disable_event(han
, sched_switch
.name
, channel
.name
)
86 raise LTTngError(strerror(res
))
88 #Getting a list of the channels
89 l
= list_channels(han
)
91 raise LTTngError(strerror(l
))
96 raise LTTngError(strerror(res
))
101 raise LTTngError(strerror(res
))
104 res
= disable_channel(han
, channel
.name
)
106 raise LTTngError(strerror(res
))
108 #Destroying the handle
111 #Destroying the session
112 res
= destroy("test")
114 raise LTTngError(strerror(res
))
This page took 0.031031 seconds and 4 git commands to generate.