Supported Platforms
Example: Configuring Event Policies to Raise SNMP Traps
Overview of Using Event Policies to Raise SNMP Traps
SNMP traps enable an agent to notify a network management system (NMS) of significant events by way of an unsolicited SNMP message. You can configure an event policy action that raises traps for events based on system log messages. If one or more of the listed events occur, the system log message for the event is converted into a trap. This enables notification of an SNMP trap-based application when an important system log message occurs. You can convert any system log message (for which there are no corresponding traps) into a trap. This is helpful if you use NMS traps rather than system log messages to monitor your network.
To configure an event policy that raises a trap on receipt of an event, include the following statements at the [edit event-options policy policy-name] hierarchy level:
The Juniper Networks enterprise-specific System Log MIB, whose object identifier is {jnxMibs 35}, provides support for this feature.
Example: Raising 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 drive, 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:
Create and name the event-policy.
[edit]user@R1# edit event-options policy raise-trap-on-ospf-nbrdownConfigure the event policy to match on the desired event, which in this example is the RPD_OSPF_NBRDOWN event.
[edit event-options policy raise-trap-on-ospf-nbrdown]user@R1# set events rpd_ospf_nbrdownConfigure the event policy action to raise an SNMP trap in response to the event.
[edit event-options policy raise-trap-on-ospf-nbrdown]user@R1# set then raise-trap(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.
[edit event-options policy raise-trap-on-ospf-nbrdown]user@R1# set then event-script ospf.xsl arguments interface {$$rpd_ospf_nbrdown.interface-name}user@R1# set then event-script ospf.xsl output-filename ospf-out destination mgmt-archivesCommit the configuration.
user@R1# commit