Configuring an event-handler profile

Use this procedure to create an event-handler profile, define one or more triggers for it, and specify a Python script that runs upon one or more trigger events.

Procedure

  1. Enter configure terminal to access global configuration mode.
    device# configure terminal
  2. Enter the event-handler command.
    device(config)# event-handler eventHandler1
  3. For each trigger that you need for a profile, enter the trigger command.
    device(config-event-handler-eventHandler1)# trigger 1 raslog LOG-1001
    The trigger event is RASlog message #LOG-1001.
  4. Enter the action python-script command to specify a Python script that runs when the event-handler is triggered.
    device(config-event-handler-eventHandler1)# action python-script example.py
  5. To add an event-handler-profile description, enter description, followed by the description text.
    device(config-event-handler-eventHandler1)# description This is a sample description.

Results

Caution

Caution

Make sure that you test Python scripts according to standard quality assurance practices before deploying them.

Example

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.

Example

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.