Commit | Line | Data |
---|---|---|
a942557f | 1 | lttng-add-trigger(1) |
484b2a0c | 2 | ==================== |
e9711845 | 3 | :revdate: 14 June 2021 |
a942557f SM |
4 | |
5 | ||
6 | NAME | |
7 | ---- | |
484b2a0c | 8 | lttng-add-trigger - Add an LTTng trigger |
a942557f SM |
9 | |
10 | ||
11 | SYNOPSIS | |
12 | -------- | |
a942557f | 13 | [verse] |
d938377c | 14 | *lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *add-trigger* [option:--name='NAME'] [option:--owner-uid='UID'] |
484b2a0c PP |
15 | option:--condition='CONDTYPE' ['CONDARGS'] |
16 | option:--action='ACTTYPE' ['ACTARGS'] [option:--action='ACTTYPE' ['ACTARGS']]... | |
a942557f SM |
17 | |
18 | DESCRIPTION | |
19 | ----------- | |
484b2a0c | 20 | The `lttng add-trigger` command creates and adds an LTTng _trigger_ to |
26f0c779 | 21 | the connected session daemon (see man:lttng-sessiond(8)). |
484b2a0c | 22 | |
26f0c779 | 23 | See man:lttng-concepts(7) to learn more about LTTng triggers. |
a942557f | 24 | |
26f0c779 PP |
25 | By default, the `add-trigger` command automatically assigns a name, |
26 | unique for a given session daemon and Unix user, to the added trigger. | |
27 | Assign a custom name with the option:--name. | |
a942557f | 28 | |
484b2a0c | 29 | The `add-trigger` command adds a trigger for your Unix user. If your |
26f0c779 | 30 | Unix user is `root`, you may add the trigger as another user with the |
d938377c | 31 | option:--owner-uid option. |
a942557f | 32 | |
484b2a0c PP |
33 | Specify the condition of the trigger to add with a <<cond-spec,condition |
34 | specifier>> and its actions with one or more <<action-spec,action | |
35 | specifiers>>. The order of the action specifiers is significant: LTTng | |
26f0c779 | 36 | attempts to execute the actions of a firing trigger in this order. |
a942557f | 37 | |
da39b67c | 38 | See the ``<<examples,EXAMPLES>>'' section below for usage examples. |
d65a3957 | 39 | |
26f0c779 PP |
40 | List the triggers of your Unix user, or of all users if your |
41 | Unix user is `root`, with the man:lttng-list-triggers(1) command. | |
a942557f | 42 | |
26f0c779 | 43 | Remove a trigger with the man:lttng-remove-trigger(1) command. |
a942557f | 44 | |
a942557f | 45 | |
484b2a0c PP |
46 | [[cond-spec]] |
47 | Condition specifier | |
48 | ~~~~~~~~~~~~~~~~~~~ | |
49 | Synopsis: | |
50 | ||
51 | [verse] | |
52 | option:--condition='CONDTYPE' ['CONDARGS'] | |
a942557f | 53 | |
484b2a0c PP |
54 | A condition specifier is the option:--condition option, which specifies |
55 | the type of condition 'CONDTYPE', followed, depending on 'CONDTYPE', | |
56 | with zero or more arguments 'CONDARGS'. | |
57 | ||
58 | The available condition types are: | |
59 | ||
60 | [[er-matches-cond-spec]]`event-rule-matches`:: | |
61 | Synopsis: | |
62 | + | |
63 | [verse] | |
26f0c779 | 64 | option:--condition=**event-rule-matches** [nloption:--capture='CDESCR']... 'ERSPEC' |
484b2a0c | 65 | {nbsp} |
943061bd | 66 | + |
484b2a0c PP |
67 | An `event-rule-matches` condition is considered satisfied when the event |
68 | rule specified with 'ERSPEC' matches an event. | |
69 | + | |
70 | See man:lttng-event-rule(7) to learn how to specify an event rule | |
71 | ('ERSPEC' part). | |
72 | + | |
73 | Capture event record and context fields with one or more | |
da39b67c PP |
74 | nloption:--capture options (see the ``<<capture-descr,Capture |
75 | descriptor>>'' section below to learn more). When an | |
76 | `event-rule-matches` condition with capture descriptors is satisfied, | |
77 | the captured field values are available in the evaluation object of the | |
78 | condition using the liblttng-ctl C{nbsp}API. | |
484b2a0c PP |
79 | + |
80 | IMPORTANT: Make sure to **single-quote** 'CDESCR' when you run the | |
81 | `add-trigger` command from a shell, as capture descriptors can include | |
82 | characters having a special meaning for most shells. | |
943061bd | 83 | |
a942557f | 84 | |
484b2a0c PP |
85 | [[capture-descr]] |
86 | Capture descriptor | |
87 | ~~~~~~~~~~~~~~~~~~ | |
88 | A capture descriptor is a textual expression which describes how to read | |
89 | an event record or context field. | |
a942557f | 90 | |
484b2a0c PP |
91 | The argument of a nloption:--capture option, when using an |
92 | <<er-matches-cond-spec,``event rule matches'' condition specifier>> | |
93 | (`event-rule-matches`), is a capture descriptor. | |
a942557f | 94 | |
484b2a0c | 95 | A capture descriptor expression is one of: |
a942557f | 96 | |
484b2a0c PP |
97 | 'NAME':: |
98 | An event record field named 'NAME'. | |
99 | + | |
100 | The supported event record field types are: | |
101 | + | |
102 | -- | |
103 | * Integer | |
104 | * Enumeration (integral value) | |
105 | * Floating point number | |
106 | * Static array of integers | |
107 | * Dynamic array (``sequence'') of integers | |
108 | * Text string | |
109 | -- | |
110 | + | |
111 | Examples: `my_field`, `target_cpu`, `ip`. | |
a942557f | 112 | |
484b2a0c PP |
113 | ++$ctx.++__NAME__:: |
114 | A statically-known context field named 'NAME'. | |
115 | + | |
116 | List the available statically-known context field names with | |
117 | man:lttng-add-context(1). | |
118 | + | |
119 | Examples: `$ctx.prio`, `$ctx.preemptible`, | |
120 | `$ctx.perf:cpu:stalled-cycles-frontend`. | |
121 | ||
122 | ++$app.++__PROVIDER__++.++__NAME__:: | |
123 | An application-specific context field named 'NAME' from the | |
124 | provider 'PROVIDER'. | |
125 | + | |
126 | See man:lttng-add-context(1) to learn more about application-specific | |
127 | context fields. | |
128 | + | |
129 | Example: `$app.server:cur_user`. | |
a942557f | 130 | |
484b2a0c PP |
131 | __EXPR__++[++__INDEX__++]++:: |
132 | The element at index 'INDEX' of the array field (static or dynamic) | |
133 | identified by the expression 'EXPR'. | |
134 | + | |
135 | 'INDEX' must be a constant, positive integral value. | |
136 | + | |
137 | Examples: `ip[3]`, `user_ids[15]`. | |
a942557f | 138 | |
484b2a0c PP |
139 | If, when an event rule matches, a given capture descriptor doesn't |
140 | identify an existing event or context field, then the captured value is | |
141 | reported as being unavailable. This applies to: | |
a942557f | 142 | |
484b2a0c PP |
143 | * A nonexistent event record field name. |
144 | * A nonexistent statically-known context field name. | |
145 | * A nonexistent application-specific context field name. | |
146 | * An out-of-bounds array field index. | |
943061bd | 147 | |
943061bd | 148 | |
484b2a0c PP |
149 | [[action-spec]] |
150 | Action specifier | |
151 | ~~~~~~~~~~~~~~~~ | |
152 | Synopsis: | |
943061bd | 153 | |
484b2a0c PP |
154 | [verse] |
155 | option:--action='ACTTYPE' ['ACTARGS'] | |
156 | ||
157 | An action specifier is the option:--action option, which specifies | |
158 | the type of action 'ACTTYPE', followed, depending on 'ACTTYPE', with zero | |
159 | or more arguments 'ACTARGS'. | |
160 | ||
161 | The available action types are: | |
162 | ||
163 | Notify:: | |
164 | Synopsis: | |
165 | + | |
166 | [verse] | |
26f0c779 | 167 | option:--action=**notify** [nloption:--rate-policy='POLICY'] |
484b2a0c PP |
168 | {nbsp} |
169 | + | |
170 | Sends a notification through the notification | |
a968a9e0 | 171 | mechanism of the session daemon (see man:lttng-sessiond(8)). |
484b2a0c PP |
172 | + |
173 | The session daemon sends details about the condition evaluation along | |
174 | with the notification. | |
175 | + | |
176 | As of LTTng{nbsp}{lttng_version}, you can write a C/pass:[C++] program | |
177 | to receive LTTng notifications (see the liblttng-ctl C{nbsp}headers). | |
178 | + | |
179 | See below for the nloption:--rate-policy option. | |
943061bd | 180 | |
e9711845 | 181 | Start a recording session:: |
484b2a0c PP |
182 | Synopsis: |
183 | + | |
184 | [verse] | |
26f0c779 | 185 | option:--action=**start-session** 'SESSION' [nloption:--rate-policy='POLICY'] |
484b2a0c PP |
186 | {nbsp} |
187 | + | |
e9711845 | 188 | Starts the recording session named 'SESSION' like man:lttng-start(1) |
484b2a0c PP |
189 | would. |
190 | + | |
e9711845 | 191 | If no recording session has the name 'SESSION' when LTTng is ready to |
484b2a0c PP |
192 | execute the action, LTTng does nothing. |
193 | + | |
194 | See below for the nloption:--rate-policy option. | |
943061bd | 195 | |
e9711845 | 196 | Stop a recording session:: |
484b2a0c | 197 | Synopsis: |
943061bd | 198 | + |
484b2a0c | 199 | [verse] |
26f0c779 | 200 | option:--action=**stop-session** 'SESSION' [nloption:--rate-policy='POLICY'] |
484b2a0c | 201 | {nbsp} |
943061bd | 202 | + |
e9711845 PP |
203 | Stops the recording session named 'SESSION' like man:lttng-stop(1) |
204 | would. | |
943061bd | 205 | + |
e9711845 | 206 | If no recording session has the name 'SESSION' when LTTng is ready to |
484b2a0c | 207 | execute the action, LTTng does nothing. |
943061bd | 208 | + |
484b2a0c | 209 | See below for the nloption:--rate-policy option. |
943061bd | 210 | |
e9711845 | 211 | Rotate a recording session:: |
484b2a0c PP |
212 | Synopsis: |
213 | + | |
214 | [verse] | |
26f0c779 | 215 | option:--action=**rotate-session** 'SESSION' [nloption:--rate-policy='POLICY'] |
484b2a0c | 216 | {nbsp} |
943061bd | 217 | + |
e9711845 PP |
218 | Archives the current trace chunk of the recording session named |
219 | 'SESSION' like man:lttng-rotate(1) would. | |
943061bd | 220 | + |
e9711845 | 221 | If no recording session has the name 'SESSION' when LTTng is ready to |
484b2a0c | 222 | execute the action, LTTng does nothing. |
943061bd | 223 | + |
484b2a0c | 224 | See below for the nloption:--rate-policy option. |
943061bd | 225 | |
e9711845 | 226 | Take a recording session snapshot:: |
484b2a0c | 227 | Synopsis: |
943061bd | 228 | + |
484b2a0c | 229 | [verse] |
26f0c779 | 230 | option:--action=**snapshot-session** 'SESSION' [nloption:--rate-policy='POLICY'] |
484b2a0c | 231 | {nbsp} |
943061bd | 232 | + |
e9711845 | 233 | Takes a snapshot of the recording session named 'SESSION' like |
484b2a0c PP |
234 | man:lttng-snapshot(1) would. |
235 | + | |
e9711845 PP |
236 | When the condition of the trigger is satisfied, the recording session |
237 | named 'SESSION', if any, must be a snapshot-mode recording session | |
484b2a0c PP |
238 | (see man:lttng-create(1)). |
239 | + | |
e9711845 | 240 | If no recording session has the name 'SESSION' when LTTng is ready to |
484b2a0c PP |
241 | execute the action, LTTng does nothing. |
242 | + | |
243 | See below for the nloption:--rate-policy option. | |
244 | ||
245 | Common action options (as of LTTng{nbsp}{lttng_version}): | |
246 | ||
247 | nloption:--rate-policy='POLICY':: | |
72d8cc10 PP |
248 | Set the rate policy of the action to 'POLICY' instead of |
249 | `every:1` (always execute). | |
484b2a0c PP |
250 | + |
251 | A trigger which ``fires'' (its condition is satisfied) leads to an | |
252 | execution request for each of its actions, in order. An execution | |
253 | request of a given action{nbsp}__A__ first increments the execution | |
254 | request count{nbsp}__C__ of{nbsp}__A__. An execution request can then | |
255 | become an actual execution when{nbsp}__C__ satisfies the rate policy | |
256 | of{nbsp}__A__. | |
257 | + | |
484b2a0c PP |
258 | 'POLICY' is one of: |
259 | + | |
260 | -- | |
261 | ++once-after:++__COUNT__:: | |
262 | Only execute{nbsp}__A__ when{nbsp}__C__ is equal to 'COUNT'. | |
263 | + | |
264 | In other words, execute{nbsp}__A__ a single time after 'COUNT' execution | |
265 | requests. | |
266 | ||
267 | ++every:++__COUNT__:: | |
268 | Only execute{nbsp}__A__ when{nbsp}__C__ is a multiple of 'COUNT'. | |
269 | + | |
270 | In other words, execute{nbsp}__A__ every 'COUNT' execution requests. | |
271 | -- | |
272 | + | |
72d8cc10 PP |
273 | 'COUNT' must be an integer greater than{nbsp}0. |
274 | + | |
484b2a0c PP |
275 | As of LTTng{nbsp}{lttng_version}, you can use this option with any |
276 | action type, but new action types in the future may not support it. | |
943061bd JR |
277 | |
278 | ||
a942557f SM |
279 | OPTIONS |
280 | ------- | |
484b2a0c PP |
281 | Identification |
282 | ~~~~~~~~~~~~~~ | |
283 | option:--name='NAME':: | |
284 | Set the unique name of the trigger to add to 'NAME' instead of the | |
285 | `add-trigger` command automatically assigning one. | |
286 | ||
d938377c | 287 | option:--owner-uid='UID':: |
484b2a0c PP |
288 | Add the trigger as the Unix user having the user ID 'UID'. |
289 | + | |
290 | You may only use this option if your Unix user is `root`. | |
a942557f | 291 | |
d0a70fd5 | 292 | |
484b2a0c PP |
293 | Specifier |
294 | ~~~~~~~~~ | |
295 | option:--condition='CONDTYPE':: | |
296 | Introductory option for a condition specifier of type 'CONDTYPE'. | |
a942557f | 297 | + |
da39b67c PP |
298 | See the ``<<cond-spec,Condition specifier>>'' section above to learn |
299 | more. | |
a942557f | 300 | |
484b2a0c PP |
301 | option:--action='ACTTYPE':: |
302 | Introductory option for an action specifier of type 'ACTTYPE'. | |
303 | + | |
da39b67c PP |
304 | See the ``<<action-spec,Action specifier>>'' section above to learn |
305 | more. | |
a942557f | 306 | |
a942557f | 307 | |
f5511eea | 308 | include::common-lttng-cmd-help-options.txt[] |
a942557f SM |
309 | |
310 | ||
f5511eea PP |
311 | include::common-lttng-cmd-after-options.txt[] |
312 | ||
313 | ||
473c70ca PP |
314 | [[examples]] |
315 | EXAMPLES | |
316 | -------- | |
317 | .Add an ``event rule matches'' trigger of which the action is to send a notification. | |
318 | ==== | |
319 | The `event-rule-matches` trigger condition below specifies an event rule | |
320 | which matches any Linux system call entry event with a name starting | |
321 | with `exec`. | |
322 | ||
323 | [role="term"] | |
324 | ---- | |
325 | $ lttng add-trigger --condition=event-rule-matches \ | |
a55e08e0 | 326 | --type=syscall:entry \ |
473c70ca PP |
327 | --name='exec*' --action=notify |
328 | ---- | |
329 | ==== | |
330 | ||
e9711845 | 331 | .Add an ``event rule matches'' trigger of which the action is to stop a recording session and then rotate it. |
473c70ca PP |
332 | ==== |
333 | The `event-rule-matches` trigger condition below specifies an event rule | |
334 | which matches any user space tracepoint event with a name starting with | |
335 | `my_app:` and with a log level at least as severe as a warning. | |
336 | ||
337 | The order of the option:--action options below is significant. | |
338 | ||
339 | [role="term"] | |
340 | ---- | |
341 | $ lttng add-trigger --condition=event-rule-matches \ | |
a55e08e0 | 342 | --type=user --name='my_app:*' \ |
473c70ca PP |
343 | --log-level=TRACE_WARNING.. \ |
344 | --action=stop-session my-session \ | |
345 | --action=rotate-session my-session | |
346 | ---- | |
347 | ||
e9711845 | 348 | See man:lttng-concepts(7) to learn more about recording sessions and |
473c70ca PP |
349 | rotations. |
350 | ==== | |
351 | ||
352 | .Add an ``event rule matches'' trigger with a specific name. | |
353 | ==== | |
354 | The `event-rule-matches` trigger condition below specifies an event rule | |
355 | which matches events which LTTng creates from the `my-logger` Python | |
356 | logger. | |
357 | ||
358 | The added trigger is named `my-trigger`, a unique name for your Unix | |
359 | user. | |
360 | ||
361 | See the option:--name option. | |
362 | ||
363 | [role="term"] | |
364 | ---- | |
365 | $ lttng add-trigger --name=my-trigger \ | |
366 | --condition=event-rule-matches \ | |
a55e08e0 | 367 | --type=python --name=my-logger \ |
473c70ca PP |
368 | --action=snapshot-session my-session |
369 | ---- | |
370 | ==== | |
371 | ||
372 | .Add an ``event rule matches'' trigger as another Unix user. | |
373 | ==== | |
374 | The command line below adds a trigger as the `mireille` Unix user. | |
375 | ||
376 | Your Unix user must be `root` to use the option:--owner-uid option. | |
377 | ||
378 | The condition of the trigger specifies an event rule which matches LTTng | |
379 | kernel tracepoint events with a name which starts with `sched`. | |
380 | ||
381 | [role="term"] | |
382 | ---- | |
383 | # lttng add-trigger --owner-uid=$(id --user mireille) \ | |
384 | --condition=event-rule-matches \ | |
a55e08e0 | 385 | --type=kernel --name='sched*' \ |
473c70ca PP |
386 | --action=notify |
387 | ---- | |
388 | ==== | |
389 | ||
390 | .Add an ``event rule matches'' trigger with a notification action to be executed every 10{nbsp}times. | |
391 | ==== | |
392 | The `event-rule-matches` trigger condition below specifies an event rule | |
393 | which matches all user space tracepoint events. | |
394 | ||
395 | See the nloption:--rate-policy option above. | |
396 | ||
397 | [role="term"] | |
398 | ---- | |
399 | $ lttng add-trigger --condition=event-rule-matches \ | |
a55e08e0 | 400 | --type=user --action=notify \ |
473c70ca PP |
401 | --rate-policy=every:10 |
402 | ---- | |
403 | ==== | |
404 | ||
e9711845 | 405 | .Add an ``event rule matches'' trigger with a recording session starting action to be executed a single time after 40{nbsp}times. |
473c70ca PP |
406 | ==== |
407 | The `event-rule-matches` trigger condition below specifies an event rule | |
408 | which matches any Linux system call event (entry and exit) of which the | |
409 | `fd` event record field is less than{nbsp}3. | |
410 | ||
411 | See the nloption:--rate-policy option above. | |
412 | ||
413 | [role="term"] | |
414 | ---- | |
415 | $ lttng add-trigger --condition=event-rule-matches \ | |
a55e08e0 | 416 | --type=syscall --filter='fd < 3' \ |
473c70ca PP |
417 | --action=start-session my-session \ |
418 | --rate-policy=once-after:40 | |
419 | ---- | |
420 | ==== | |
421 | ||
422 | ||
f5511eea | 423 | include::common-footer.txt[] |
a942557f SM |
424 | |
425 | ||
426 | SEE ALSO | |
427 | -------- | |
484b2a0c | 428 | man:lttng(1), |
a942557f | 429 | man:lttng-list-triggers(1), |
af1c4164 PP |
430 | man:lttng-remove-trigger(1), |
431 | man:lttng-concepts(7) |