Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Raise an SNMP Trap in Response to an Event

This example configures an event policy to raise a trap and to execute an event script in response to an event:

Requirements

A device running Junos OS, which is configured for SNMP.

Overview

The following example configures the event policy raise-trap-on-ospf-nbrdown to trigger on the RPD_OSPF_NBRDOWN event, which indicates a terminated OSPF adjacency with a neighboring router. The event policy action raises a trap in response to the event. The device sends a notification to the SNMP manager, if one is configured under the [edit snmp] hierarchy level.

Additionally, the event policy executes the event script ospf.xsl in response to this event and provides the affected interface as an argument to the script. The $$rpd_ospf_nbrdown.interface-name argument resolves to the interface name associated with the triggering event.

The event script output is recorded in the file ospf-out, and the output file is uploaded to the destination mgmt-archives, which is configured at the [edit event-options destinations] hierarchy level. To invoke an event script in an event policy, the event script must be present in the /var/db/scripts/event directory on the hard disk, and it must be enabled in the configuration.

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them in a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

Configuring the Event Policy

Step-by-Step Procedure

To configure an event policy that raises a trap on receipt of an event and optionally executes an event script:

  1. Create and name the event-policy.

  2. Configure the event policy to match on the desired event, which in this example is the RPD_OSPF_NBRDOWN event.

  3. Configure the event policy action to raise an SNMP trap in response to the event.

  4. (Optional) Configure additional actions to take in response to the event.

    This example executes an event script and uploads the associated output file to a predefined destination.

  5. Commit the configuration.

Results