device# configure terminal
device(config)# event-handler eventHandler1
device(config-event-handler-eventHandler1)# trigger 1 raslog LOG-1001
device(config-event-handler-eventHandler1)# action python-script example.py
device(config-event-handler-eventHandler1)# description This is a sample description.
Caution
Make sure that you test Python scripts according to standard quality assurance practices before deploying them.The following example includes all of the steps.
device# configure terminal device(config)# event-handler eventHandler1 device(config-event-handler-eventHandler1)# trigger 1 raslog LOG-1001 device(config-event-handler-eventHandler1)# action python-script example.py device(config-event-handler-eventHandler1)# description This is a sample description.
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.