Triggers¶
The trigger feature allows the launching of commands in response to an event. This event can be either an alarm reaching a given severity level, the value of a pushed state leaf meeting certain conditions, or periodic.
Trigger on alarm¶
Both system and user alarms can be used in a trigger.
vsr running config# / system trigger event TRIGGER-NAME on-alarm alarm ALARM-NAME severity-level SEVERITY-LEVEL
When the ALARM-NAME alarm reaches the SEVERITY-LEVEL severity level, the specified commands are applied to the system. The commands key allows you to specify multiple commands for execution within a multi-line string.
Example¶
Let’s start by creating an alarm that is raised when an ICMP tracker named ICMP-TRACKER goes down:
vsr running config# / vrf main interface loopback lo1 ipv4 address 1.1.1.1/24
vsr running config# / tracker icmp ICMP-TRACKER address 1.1.1.1 vrf main
vsr running config# / system alarm alarm-inventory alarm-type user-alarm icmp-tracker-down description "Alarm raising when the ICMP tracker ICPM-TRACKER goes down."
vsr running config# / system alarm alarm-inventory alarm-type user-alarm icmp-tracker-down resource "/tracker/icmp[name='ICMP-TRACKER']/state"
vsr running config# / system alarm alarm-inventory alarm-type user-alarm icmp-tracker-down severity-level-trigger critical text "Tracker ICMP-TRACKER {value}, alarm {name}"
vsr running config# / system alarm alarm-inventory alarm-type user-alarm icmp-tracker-down severity-level-trigger critical equal down
vsr running config# / system alarm alarm-inventory alarm-type user-alarm icmp-tracker-down severity-level-trigger cleared text "Tracker ICMP-TRACKER {value}"
vsr running config# commit
In this enhanced scenario, we have an ICMP tracker named ICMP-TRACKER which is monitored for its operational status. Initially, when this ICMP tracker goes down, it raises an alarm. Now, we will add a trigger. When the alarm reaches the critical state, it will be activated. It will set the MTU (Maximum Transmission Unit) configuration from a physical interface named eth1 to 1500:
vsr running config# / system trigger event trigger-icmp-tracker-down on-alarm alarm icmp-tracker-down severity-level critical
vsr running config# / system trigger event trigger-icmp-tracker-down log true
vsr running config# / system trigger event trigger-icmp-tracker-down commands """
vsr running config# edit running
vsr running config# / vrf main interface physical eth1 mtu 1500
vsr running config# / vrf main interface physical eth1 port pci-b0s3
vsr running config# commit
vsr running config# show state / vrf main interface physical eth1 mtu"""
vsr running config# commit
Here the associated state:
vsr running config# show state / system trigger
trigger
enabled true
event trigger-icmp-tracker-down
enabled true
log true
commands "
edit running
/ vrf main interface physical eth1 mtu 1500
/ vrf main interface physical eth1 port pci-b0s3
commit
show state / vrf main interface physical eth1 mtu"
on-alarm
alarm icmp-tracker-down
severity-level critical
..
..
..
Then, disable the interface to trigger the alarm and the event:
vsr running config# / vrf main interface loopback lo1 enabled false
vsr running config# commit
Finally, let’s go check the logs of our event:
vsr running config# show log service trigger
Mar 22 13:45:35 ubuntu2204 systemd[1]: Started Trigger Command Logger Service for trigger/icmp/tracker/down.
Mar 22 13:45:36 ubuntu2204 trigger@trigger/icmp/tracker/down[16406]: Configuration committed.
Mar 22 13:45:36 ubuntu2204 trigger@trigger/icmp/tracker/down[16406]: mtu 1500
Mar 22 13:45:36 ubuntu2204 systemd[1]: trigger@trigger-icmp-tracker-down.service: Deactivated successfully.
The same configuration can be made using this NETCONF XML configuration:
vsr running config# show config xml absolute / system trigger event trigger-icmp-tracker-down
<config xmlns="urn:6wind:vrouter">
<system xmlns="urn:6wind:vrouter/system">
<trigger xmlns="urn:6wind:vrouter/trigger">
<event>
<name>trigger-icmp-tracker-down</name>
<enabled>true</enabled>
<log>true</log>
<commands>
edit running
/ vrf main interface physical eth1 mtu 1500
/ vrf main interface physical eth1 port pci-b0s3
commit
show state / vrf main interface physical eth1 mtu</commands>
<on-alarm>
<alarm>icmp-tracker-down</alarm>
<severity-level>critical</severity-level>
</on-alarm>
</event>
</trigger>
</system>
</config>
Trigger periodically¶
It is possible to configure a trigger in a manner similar to a crontab with the following configuration:
vsr running config# / system trigger event TRIGGER-NAME on-cron cron "0 * * * *"
Note
The cron time format is a string of five fields separated by spaces, representing a schedule for executing tasks in a Unix-like system. Each field can have different values, defining when a cron job will run. The format is as follows:
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31)
│ │ │ ┌───────────── month (1 - 12 or Jan, Feb, Mar, Apr, ...)
│ │ │ │ ┌───────────── day of the week (0 - 6 or Sun, Mon, Tue, Wed, ...)
│ │ │ │ │
* * * * *
Example¶
Here is how to generate a troubleshooting report every day at midnight:
vsr running config# / system trigger event midnight-report on-cron cron "0 * * * *"
vsr running config# / system trigger event midnight-report commands """
vsr running config# cmd troubleshooting-report new
vsr running config# """
Here the associated state:
vsr running config# show state / system trigger
trigger
enabled true
event midnight-report
enabled true
log false
commands "
cmd troubleshooting-report new
"
on-cron
cron "0 * * * *"
..
..
..
The same configuration can be made using this NETCONF XML configuration:
vsr running config# show config xml absolute / system trigger event midnight-report
<config xmlns="urn:6wind:vrouter">
<system xmlns="urn:6wind:vrouter/system">
<trigger xmlns="urn:6wind:vrouter/trigger">
<event>
<name>midnight-report</name>
<enabled>true</enabled>
<log>false</log>
<commands>
cmd troubleshooting-report new
</commands>
<on-cron>
<cron>0 * * * *</cron>
</on-cron>
</event>
</trigger>
</system>
</config>
Trigger on resource¶
A pushed leaf can be used in a trigger.
Here is an example of the configuration:
vsr running config# / system trigger event test on-resource resource MY-XPATH OPERATION VALUE
Note
The resource must correspond to a pushed leaf; otherwise, it will never be taken into account.
Example¶
In this example, we’re going to replicate the setup used for the alarm, but this time we will directly implement a trigger without an associated alarm. This approach will help to understand the similarities in configurations:
vsr running config# / system trigger event trigger-icmp-tracker-down on-resource resource "/tracker/icmp[name='ICMP-TRACKER']/state" equal down
vsr running config# / system trigger event trigger-icmp-tracker-down log true
vsr running config# / system trigger event trigger-icmp-tracker-down commands """
vsr running config# edit running
vsr running config# / vrf main interface physical eth1 mtu 1500
vsr running config# commit
vsr running config# """
Here the associated state:
vsr running config# show state / system trigger
trigger
enabled true
event trigger-icmp-tracker-down
enabled true
log true
commands "
edit running
/ vrf main interface physical eth1 mtu 1500
commit
"
on-resource
resource "/tracker/icmp[name='ICMP-TRACKER']/state"
equal down
..
..
..
The same configuration can be made using this NETCONF XML configuration:
vsr running config# show config xml absolute / system trigger event trigger-icmp-tracker-down
<config xmlns="urn:6wind:vrouter">
<system xmlns="urn:6wind:vrouter/system">
<trigger xmlns="urn:6wind:vrouter/trigger">
<event>
<name>trigger-icmp-tracker-down</name>
<enabled>true</enabled>
<log>true</log>
<commands>
edit running
/ vrf main interface physical eth1 mtu 1500
commit
</commands>
<on-resource>
<resource>/tracker/icmp[name='ICMP-TRACKER']/state</resource>
<equal>down</equal>
</on-resource>
</event>
</trigger>
</system>
</config>
See also
The command reference for details.