Event Scripts Overview


Understanding Event Scripts

Junos OS event scripts are triggered automatically by defined event policies in response to a system event and can instruct Junos OS to take immediate action. Event scripts automate network and device management and troubleshooting. Event scripts can perform functions available through the remote procedure calls (RPCs) supported by either Junos XML management protocol or the Junos Extensible Markup Language (XML) API. Event scripts are executed by the event process (eventd).

Event scripts enable you to:

  • Automatically diagnose and fix problems in the network

  • Monitor the overall status of a device.

  • Run automatically as part of an event policy that detects periodic error conditions

  • Change the configuration in response to a problem

Event scripts are based on the Junos XML management protocol and the Junos XML API, which are discussed in Junos XML Management Protocol and Junos XML API Overview. Event scripts can be written in Python, Extensible Stylesheet Language Transformations (XSLT), or Stylesheet Language Alternative syntaX (SLAX) scripting language. Event scripts use XML Path Language (XPath) to locate the operational objects to be inspected and automation script constructs to specify the actions to perform on the operational objects. The actions can change the output or execute additional commands based on the output.

Event scripts are invoked within an event policy. To use event scripts in an event policy, event scripts must be enabled at the [edit event-options event-script file] hierarchy level and must be configured under the then hierarchy for the event policy. When an event policy is triggered, the policy forwards the event details to the event scripts and executes the scripts in the order in which they are configured. These scripts contain instructions that execute operational mode commands, inspect the output automatically, and perform any necessary actions. For information about event policies, see Event Policies and Event Notifications Overview and Executing Event Scripts in an Event Policy.

You can use event scripts to generate changes to the device configuration. Because the changes are loaded before the standard validation checks are performed, they are validated for correct syntax, just like statements already present in the configuration before the script is applied. If the syntax is correct, the configuration is activated and becomes the active, operational device configuration.

Benefits of Event Scripts

Event scripts, in conjunction with event policies, provide the following benefits:

  • Improve network reliability and maximize network uptime by automatically diagnosing and fixing problems in the network

  • Shorten troubleshooting time and speed time to resolution for network issues by automating troubleshooting tasks

  • Reduce the time required for manual system monitoring and intervention

  • Enable you to ensure consistent event policies across devices, simplify deployment of event policies, and reduce the size of the configuration by embedding event policies directly within the event script