File: lttng-add-trigger.1.txt

package info (click to toggle)
ltt-control 2.13.9-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,668 kB
  • sloc: ansic: 166,727; sh: 26,657; makefile: 2,804; python: 1,374; yacc: 692; lex: 129; java: 109; perl: 99; cpp: 27; xml: 23
file content (431 lines) | stat: -rw-r--r-- 12,575 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
lttng-add-trigger(1)
====================
:revdate: 14 June 2021


NAME
----
lttng-add-trigger - Add an LTTng trigger


SYNOPSIS
--------
[verse]
*lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *add-trigger* [option:--name='NAME'] [option:--owner-uid='UID']
      option:--condition='CONDTYPE' ['CONDARGS']
      option:--action='ACTTYPE' ['ACTARGS'] [option:--action='ACTTYPE' ['ACTARGS']]...

DESCRIPTION
-----------
The `lttng add-trigger` command creates and adds an LTTng _trigger_ to
the connected session daemon (see man:lttng-sessiond(8)).

See man:lttng-concepts(7) to learn more about LTTng triggers.

By default, the `add-trigger` command automatically assigns a name,
unique for a given session daemon and Unix user, to the added trigger.
Assign a custom name with the option:--name.

The `add-trigger` command adds a trigger for your Unix user. If your
Unix user is `root`, you may add the trigger as another user with the
option:--owner-uid option.

Specify the condition of the trigger to add with a <<cond-spec,condition
specifier>> and its actions with one or more <<action-spec,action
specifiers>>. The order of the action specifiers is significant: LTTng
attempts to execute the actions of a firing trigger in this order.

See the ``<<examples,EXAMPLES>>'' section below for usage examples.

List the triggers of your Unix user, or of all users if your
Unix user is `root`, with the man:lttng-list-triggers(1) command.

Remove a trigger with the man:lttng-remove-trigger(1) command.


[[cond-spec]]
Condition specifier
~~~~~~~~~~~~~~~~~~~
Synopsis:

[verse]
option:--condition='CONDTYPE' ['CONDARGS']

A condition specifier is the option:--condition option, which specifies
the type of condition 'CONDTYPE', followed, depending on 'CONDTYPE',
with zero or more arguments 'CONDARGS'.

The available condition types are:

[[er-matches-cond-spec]]`event-rule-matches`::
    Synopsis:
+
[verse]
option:--condition=**event-rule-matches** [nloption:--capture='CDESCR']... 'ERSPEC'
{nbsp}
+
An `event-rule-matches` condition is considered satisfied when the event
rule specified with 'ERSPEC' matches an event.
+
See man:lttng-event-rule(7) to learn how to specify an event rule
('ERSPEC' part).
+
Capture event record and context fields with one or more
nloption:--capture options (see the ``<<capture-descr,Capture
descriptor>>'' section below to learn more). When an
`event-rule-matches` condition with capture descriptors is satisfied,
the captured field values are available in the evaluation object of the
condition using the liblttng-ctl C{nbsp}API.
+
IMPORTANT: Make sure to **single-quote** 'CDESCR' when you run the
`add-trigger` command from a shell, as capture descriptors can include
characters having a special meaning for most shells.


[[capture-descr]]
Capture descriptor
~~~~~~~~~~~~~~~~~~
A capture descriptor is a textual expression which describes how to read
an event record or context field.

The argument of a nloption:--capture option, when using an
<<er-matches-cond-spec,``event rule matches'' condition specifier>>
(`event-rule-matches`), is a capture descriptor.

A capture descriptor expression is one of:

'NAME'::
    An event record field named 'NAME'.
+
The supported event record field types are:
+
--
* Integer
* Enumeration (integral value)
* Floating point number
* Static array of integers
* Dynamic array (``sequence'') of integers
* Text string
--
+
Examples: `my_field`, `target_cpu`, `ip`.

++$ctx.++__NAME__::
    A statically-known context field named 'NAME'.
+
List the available statically-known context field names with
man:lttng-add-context(1).
+
Examples: `$ctx.prio`, `$ctx.preemptible`,
`$ctx.perf:cpu:stalled-cycles-frontend`.

++$app.++__PROVIDER__++.++__NAME__::
    An application-specific context field named 'NAME' from the
    provider 'PROVIDER'.
+
See man:lttng-add-context(1) to learn more about application-specific
context fields.
+
Example: `$app.server:cur_user`.

__EXPR__++[++__INDEX__++]++::
    The element at index 'INDEX' of the array field (static or dynamic)
    identified by the expression 'EXPR'.
+
'INDEX' must be a constant, positive integral value.
+
Examples: `ip[3]`, `user_ids[15]`.

If, when an event rule matches, a given capture descriptor doesn't
identify an existing event or context field, then the captured value is
reported as being unavailable. This applies to:

* A nonexistent event record field name.
* A nonexistent statically-known context field name.
* A nonexistent application-specific context field name.
* An out-of-bounds array field index.


[[action-spec]]
Action specifier
~~~~~~~~~~~~~~~~
Synopsis:

[verse]
option:--action='ACTTYPE' ['ACTARGS']

An action specifier is the option:--action option, which specifies
the type of action 'ACTTYPE', followed, depending on 'ACTTYPE', with zero
or more arguments 'ACTARGS'.

The available action types are:

Notify::
    Synopsis:
+
[verse]
option:--action=**notify** [nloption:--rate-policy='POLICY']
{nbsp}
+
Sends a notification through the notification
mechanism of the session daemon (see man:lttng-session(8)).
+
The session daemon sends details about the condition evaluation along
with the notification.
+
As of LTTng{nbsp}{lttng_version}, you can write a C/pass:[C++] program
to receive LTTng notifications (see the liblttng-ctl C{nbsp}headers).
+
See below for the nloption:--rate-policy option.

Start a recording session::
    Synopsis:
+
[verse]
option:--action=**start-session** 'SESSION' [nloption:--rate-policy='POLICY']
{nbsp}
+
Starts the recording session named 'SESSION' like man:lttng-start(1)
would.
+
If no recording session has the name 'SESSION' when LTTng is ready to
execute the action, LTTng does nothing.
+
See below for the nloption:--rate-policy option.

Stop a recording session::
    Synopsis:
+
[verse]
option:--action=**stop-session** 'SESSION' [nloption:--rate-policy='POLICY']
{nbsp}
+
Stops the recording session named 'SESSION' like man:lttng-stop(1)
would.
+
If no recording session has the name 'SESSION' when LTTng is ready to
execute the action, LTTng does nothing.
+
See below for the nloption:--rate-policy option.

Rotate a recording session::
    Synopsis:
+
[verse]
option:--action=**rotate-session** 'SESSION' [nloption:--rate-policy='POLICY']
{nbsp}
+
Archives the current trace chunk of the recording session named
'SESSION' like man:lttng-rotate(1) would.
+
If no recording session has the name 'SESSION' when LTTng is ready to
execute the action, LTTng does nothing.
+
See below for the nloption:--rate-policy option.

Take a recording session snapshot::
    Synopsis:
+
[verse]
option:--action=**snapshot-session** 'SESSION' [nloption:--rate-policy='POLICY']
{nbsp}
+
Takes a snapshot of the recording session named 'SESSION' like
man:lttng-snapshot(1) would.
+
When the condition of the trigger is satisfied, the recording session
named 'SESSION', if any, must be a snapshot-mode recording session
(see man:lttng-create(1)).
+
If no recording session has the name 'SESSION' when LTTng is ready to
execute the action, LTTng does nothing.
+
See below for the nloption:--rate-policy option.

Common action options (as of LTTng{nbsp}{lttng_version}):

nloption:--rate-policy='POLICY'::
    Set the rate policy of the action to 'POLICY' instead of
    `every:1` (always execute).
+
A trigger which ``fires'' (its condition is satisfied) leads to an
execution request for each of its actions, in order. An execution
request of a given action{nbsp}__A__ first increments the execution
request count{nbsp}__C__ of{nbsp}__A__. An execution request can then
become an actual execution when{nbsp}__C__ satisfies the rate policy
of{nbsp}__A__.
+
'POLICY' is one of:
+
--
++once-after:++__COUNT__::
    Only execute{nbsp}__A__ when{nbsp}__C__ is equal to 'COUNT'.
+
In other words, execute{nbsp}__A__ a single time after 'COUNT' execution
requests.

++every:++__COUNT__::
    Only execute{nbsp}__A__ when{nbsp}__C__ is a multiple of 'COUNT'.
+
In other words, execute{nbsp}__A__ every 'COUNT' execution requests.
--
+
'COUNT' must be an integer greater than{nbsp}0.
+
As of LTTng{nbsp}{lttng_version}, you can use this option with any
action type, but new action types in the future may not support it.


OPTIONS
-------
Identification
~~~~~~~~~~~~~~
option:--name='NAME'::
    Set the unique name of the trigger to add to 'NAME' instead of the
    `add-trigger` command automatically assigning one.

option:--owner-uid='UID'::
    Add the trigger as the Unix user having the user ID 'UID'.
+
You may only use this option if your Unix user is `root`.


Specifier
~~~~~~~~~
option:--condition='CONDTYPE'::
    Introductory option for a condition specifier of type 'CONDTYPE'.
+
See the ``<<cond-spec,Condition specifier>>'' section above to learn
more.

option:--action='ACTTYPE'::
    Introductory option for an action specifier of type 'ACTTYPE'.
+
See the ``<<action-spec,Action specifier>>'' section above to learn
more.


include::common-lttng-cmd-help-options.txt[]


include::common-lttng-cmd-after-options.txt[]


[[examples]]
EXAMPLES
--------
.Add an ``event rule matches'' trigger of which the action is to send a notification.
====
The `event-rule-matches` trigger condition below specifies an event rule
which matches any Linux system call entry event with a name starting
with `exec`.

[role="term"]
----
$ lttng add-trigger --condition=event-rule-matches \
                    --type=syscall:entry \
                    --name='exec*' --action=notify
----
====

.Add an ``event rule matches'' trigger of which the action is to stop a recording session and then rotate it.
====
The `event-rule-matches` trigger condition below specifies an event rule
which matches any user space tracepoint event with a name starting with
`my_app:` and with a log level at least as severe as a warning.

The order of the option:--action options below is significant.

[role="term"]
----
$ lttng add-trigger --condition=event-rule-matches \
                    --type=user --name='my_app:*' \
                    --log-level=TRACE_WARNING.. \
                    --action=stop-session my-session \
                    --action=rotate-session my-session
----

See man:lttng-concepts(7) to learn more about recording sessions and
rotations.
====

.Add an ``event rule matches'' trigger with a specific name.
====
The `event-rule-matches` trigger condition below specifies an event rule
which matches events which LTTng creates from the `my-logger` Python
logger.

The added trigger is named `my-trigger`, a unique name for your Unix
user.

See the option:--name option.

[role="term"]
----
$ lttng add-trigger --name=my-trigger \
                    --condition=event-rule-matches \
                    --type=python --name=my-logger \
                    --action=snapshot-session my-session
----
====

.Add an ``event rule matches'' trigger as another Unix user.
====
The command line below adds a trigger as the `mireille` Unix user.

Your Unix user must be `root` to use the option:--owner-uid option.

The condition of the trigger specifies an event rule which matches LTTng
kernel tracepoint events with a name which starts with `sched`.

[role="term"]
----
# lttng add-trigger --owner-uid=$(id --user mireille) \
                    --condition=event-rule-matches \
                    --type=kernel --name='sched*' \
                    --action=notify
----
====

.Add an ``event rule matches'' trigger with a notification action to be executed every 10{nbsp}times.
====
The `event-rule-matches` trigger condition below specifies an event rule
which matches all user space tracepoint events.

See the nloption:--rate-policy option above.

[role="term"]
----
$ lttng add-trigger --condition=event-rule-matches \
                    --type=user --action=notify \
                    --rate-policy=every:10
----
====

.Add an ``event rule matches'' trigger with a recording session starting action to be executed a single time after 40{nbsp}times.
====
The `event-rule-matches` trigger condition below specifies an event rule
which matches any Linux system call event (entry and exit) of which the
`fd` event record field is less than{nbsp}3.

See the nloption:--rate-policy option above.

[role="term"]
----
$ lttng add-trigger --condition=event-rule-matches \
                    --type=syscall --filter='fd < 3' \
                    --action=start-session my-session \
                    --rate-policy=once-after:40
----
====


include::common-footer.txt[]


SEE ALSO
--------
man:lttng(1),
man:lttng-list-triggers(1),
man:lttng-remove-trigger(1),
man:lttng-concepts(7)