| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | # |
| 5 | # SPDX-License-Identifier: MIT |
| 6 | |
| 7 | EVENT_NAME=trigger_example:my_event |
| 8 | TRIGGER_NAME=demo_trigger |
| 9 | TRIGGER_NAME_CAPTURE=demo_trigger_capture |
| 10 | |
| 11 | if ! lttng list > /dev/null 2>&1; then |
| 12 | echo "Could not connect to session daemon, are you sure it is running?" |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | echo "Registering a notification trigger named \"$TRIGGER_NAME\" for the $EVENT_NAME user-space event" |
| 17 | lttng add-trigger --name $TRIGGER_NAME \ |
| 18 | --condition event-rule-matches \ |
| 19 | --domain=user \ |
| 20 | --name=$EVENT_NAME \ |
| 21 | --action notify |
| 22 | |
| 23 | |
| 24 | echo "Registering a notification trigger named \"$TRIGGER_NAME_CAPTURE\" for the $EVENT_NAME user-space event with payload capture" |
| 25 | lttng add-trigger --name $TRIGGER_NAME_CAPTURE \ |
| 26 | --condition event-rule-matches \ |
| 27 | --domain=user \ |
| 28 | --name=$EVENT_NAME \ |
| 29 | --capture 'iteration' \ |
| 30 | --capture 'does_not_exist' \ |
| 31 | --capture '$ctx.vtid' \ |
| 32 | --capture '$ctx.procname'\ |
| 33 | --action notify |
| 34 | |
| 35 | ./notification-client $TRIGGER_NAME $TRIGGER_NAME_CAPTURE |