1 #This example shows basically how to use the lttng-tools python module
5 # This error will be raised is something goes wrong
6 class LTTngError(Exception):
7 def __init__(self
, value
):
10 return repr(self
.value
)
12 #Setting up the domain to use
14 dom
.type = DOMAIN_KERNEL
16 #Setting up a channel to use
18 channel
.name
= "mychan"
19 channel
.attr
.overwrite
= 0
20 channel
.attr
.subbuf_size
= 4096
21 channel
.attr
.num_subbuf
= 8
22 channel
.attr
.switch_timer_interval
= 0
23 channel
.attr
.read_timer_interval
= 200
24 channel
.attr
.output
= EVENT_SPLICE
26 #Setting up some events that will be used
28 event
.type = EVENT_TRACEPOINT
29 event
.loglevel_type
= EVENT_LOGLEVEL_ALL
31 sched_switch
= Event()
32 sched_switch
.name
= "sched_switch"
33 sched_switch
.type = EVENT_TRACEPOINT
34 sched_switch
.loglevel_type
= EVENT_LOGLEVEL_ALL
36 sched_process_exit
= Event()
37 sched_process_exit
.name
= "sched_process_exit"
38 sched_process_exit
.type = EVENT_TRACEPOINT
39 sched_process_exit
.loglevel_type
= EVENT_LOGLEVEL_ALL
41 sched_process_free
= Event()
42 sched_process_free
.name
= "sched_process_free"
43 sched_process_free
.type = EVENT_TRACEPOINT
44 sched_process_free
.loglevel_type
= EVENT_LOGLEVEL_ALL
47 #Creating a new session
48 res
= create("test","/lttng-traces/test")
50 raise LTTngError(strerror(res
))
54 han
= Handle("test", dom
)
56 raise LTTngError("Handle not created")
58 #Enabling the kernel channel
59 res
= enable_channel(han
, channel
)
61 raise LTTngError(strerror(res
))
63 #Enabling some events in given channel
64 #To enable all events in default channel, use
65 #enable_event(han, event, None)
66 res
= enable_event(han
, sched_switch
, channel
.name
)
68 raise LTTngError(strerror(res
))
70 res
= enable_event(han
, sched_process_exit
, channel
.name
)
72 raise LTTngError(strerror(res
))
74 res
= enable_event(han
, sched_process_free
, channel
.name
)
76 raise LTTngError(strerror(res
))
79 res
= disable_event(han
, sched_switch
.name
, channel
.name
)
81 raise LTTngError(strerror(res
))
83 #Getting a list of the channels
84 l
= list_channels(han
)
86 raise LTTngError(strerror(l
))
91 raise LTTngError(strerror(res
))
96 raise LTTngError(strerror(res
))
99 res
= disable_channel(han
, channel
.name
)
101 raise LTTngError(strerror(res
))
103 #Destroying the handle
106 #Destroying the session
107 res
= destroy("test")
109 raise LTTngError(strerror(res
))
This page took 0.032052 seconds and 4 git commands to generate.