Event Manager
The Event Manager feature allows users to predefine a set of CLI commands (actions) and bind them to the down event of a specified interface. When the monitored interface status changes to down, the system automatically executes a predefined command sequence to achieve configuration rollback, fault self-healing, or automated operation and maintenance. This function can reduce manual intervention time and improve the reliability and maintainability of the network.
Explanation of Principles
Section titled “Explanation of Principles”The event manager consists of multiple user-defined applets. Each applet contains the following elements:
- Name: uniquely identifies an applet.
- Trigger point: Currently only supports interface down events, which monitor the status of a physical interface or LAG interface. When the interface status changes to ‘down’, the applet is triggered.
- Action List: A set of CLI commands executed in sequence. Each action has a priority ID (ranging from 0 to 9999.9999, integers or positive floating point numbers), with smaller IDs being executed first. When a command contains spaces, double quotation marks should be used to wrap it.
- Log switch: can enable the warning function, generate system logs when the applet is triggered for execution, and facilitate post audit.
When a down event occurs in the monitored interface, the system automatically calls the bound applet and executes the preset CLI command in ascending order of action ID to complete the automation operation.
Configuration
Section titled “Configuration”| Operation | Command | Description |
|---|---|---|
| Enter the system configuration view | configure terminal | |
| Create/Delete Applet | event manager applet String no event manager applet String | Create or remove an event management applet. < string > is an applet name. Proceed to the applet configuration view. |
| Configure action commands | action * actionid cli command String no action actionid* | Add or remove a CLI command as an action for the applet. |
| Turn on/off logs | warning enable no warning enable | Enable or disable the logging function when triggered by the applet. The default is closed. |
| Bind down event | down event applet String no down event applet | Bind the specified applet to the down event of the current interface in the interface configuration view or LAG group configuration view. When the interface status changes to ‘down’, trigger the applet. |
| View Applet Information | show event-manager-applet | Execute in the system view and display all configured event management applets, including name, action list, log switch status, and trigger point information. |
Configuration Example
Section titled “Configuration Example”Networking Requirements
When the device is initially deployed, there is already a stable configuration (such as interface Ethernet 1 in up state and BGP process 65100 running normally). Subsequently, in order to test the new network, the configuration of Ethernet 1 was modified (shutdown was performed and BGP configuration was deleted). Requirement: When the link status of monitoring interface Ethernet 3 changes to down, automatically execute a rollback command to reactivate Ethernet 1 and restore BGP configuration. Simultaneously enable logging for post audit purposes.
Configuration Steps
1. Create an Event Management Applet
Create an Applet named ‘test’ and enter the Applet Configuration View
sonic(config)# event manager applet testsonic(config-event-applet-test)#2. Configure pre configured commands (action list)
Add the CLI commands that need to be executed in order
sonic(config-event-applet-test)# action 1 cli command "interface ethernet 1"sonic(config-event-applet-test)# action 2 cli command "no shutdown"sonic(config-event-applet-test)# action 3 cli command "exit"sonic(config-event-applet-test)# action 4 cli command "router bgp 65100"sonic(config-event-applet-test)# action 5 cli command "neighbor 10.0.0.1 remote-as 65100"sonic(config-event-applet-test)# action 6 cli command "exit"3. Enable logging
Enable the warning function to generate logs when the applet is triggered.
sonic(config-event-applet-test)# warning enablesonic(config-event-applet-test)# exit4. Bind down event to interface
Enter the interface that needs to be monitored (such as Ethernet 3), and trigger the test applet when the interface goes down
sonic(config)# interface ethernet 3sonic(config-if-Ethernet3)# down event applet testsonic(config-if-Ethernet3)# exit5. Verify configuration
Use the show event-manager-applet command to view the configured event management applet and its detailed information
sonic# show event-manager-applet+--------+-----------------------------------+------------------+--------------------+| name | action | warning enable | triggering point |+========+==============================+==============+==========+==================+| test | interface ethernet 1 | enabled | Ethernet3--down || | no shutdown | | || | exit | | || | router bgp 65100 | | || | neighbor 10.0.0.1 remote-as 65100 | | || | exit | | |+--------+-----------------------------------+----------------+-----------------------+sonic# show event-manager-applet +--------+-----------------------------------+------------------+--------------------+ | name | action | warning enable | triggering point | +========+==============================+==============+==========+==================+ | test | interface ethernet 1 | enabled | Ethernet3—down | | | no shutdown | | | | | exit | | | | | router bgp 65100 | | | | | neighbor 10.0.0.1 remote-as 65100 | | | | | exit | | | +--------+-----------------------------------+----------------+-----------------------+
Explanation: When the link status of interface Ethernet 3 becomes down, the system will automatically execute commands in the order of actions 1-6 to reactivate Ethernet 1 and restore BGP configuration. At the same time, warning enable will trigger logging, and event execution records can be viewed through the logs.