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