trigger
Defines event-handler triggers. When the trigger-condition occurs, a Python script is run.
Syntax
trigger
trigger-id
raslog
raslog-id
[
pattern
posix-ext-regex
]
trigger
trigger-id
raslog
raslog-id
[
pattern
trigger-pattern
]
no trigger
[
trigger-id
]
Command Default
No trigger is defined.
Parameters
- trigger-id
- Specifies an ID number for the trigger. Valid values are 1 through 100, and must be unique per event-handler profile.
- raslog
raslog-id
- Specifies a RASlog message ID as the trigger. String can be 1 through 32 characters long.
- pattern
posix-ext-regex
- Specifies a POSIX extended regular expression to search within the specified RASlog message ID.
- pattern
trigger-pattern
- Specifies a sequence of strings with included regular expressions to search within the specified RASlog message ID. Contains alphabets, digits and all characters supported in regex. String can be 1 through 128 characters long.
Modes
Event-handler configuration mode
Usage Guidelines
You can create from 1 through 100 triggers per profile.
You can also define one trigger as part of the
event-handler command.
To delete one or all triggers, use the
no form of this command, as follows:
- To delete all triggers, enter
no trigger.
- To delete a specific trigger, enter
no trigger
trigger-id
Note
You cannot delete the last remaining trigger from an activated event-handler profile.
You can modify an existing trigger without deleting it and then re-creating it.
If the event-handler for which you are modifying triggers is active on the device, the changes take effect with no need to de-activate and re-activate the event-handler.
A Python event-handler script runs only if all of the following occur:
- Using the
copy command, copy the Python file to the
flash:// location on the device.
- Using the
event-handler command, create an event-handler profile.
- In configuration mode for that profile:
- Using the
trigger command, create one or more triggers.
- Using the
action command, specify the Python script that will be triggered.
- Using the
event-handler activate command, activate an instance of the event handler.
- The trigger event occurs.
Examples
The following example defines triggers in two event handlers.
device# configure terminal
device(config)# event-handler eventHandler2
device(config-event-handler-eventHandler2)# trigger 1 raslog NSM-1001
device(config-event-handler-eventHandler2)# trigger 2 raslog NSM-1003
The following example defines a trigger that uses POSIX extended REGEX to search for a match within a specified RASlog message ID.
device# configure terminal
device(config-event-handler-eventHandler1)# event-handler eventHandler2
device(config-event-handler-eventHandler2)# trigger 1 raslog NSM-1003 pattern Interface Ethernet 1/[1-9] is link down
RASlog message NSM-1003 includes "interface
interface-name is link down", indicating that an interface is offline because the link is down. The REGEX searches within such a message for an interface from 1/1 through 1/9.