Event Manager
7 min
\<font color="#1d50a2">introduction\</font> 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 \<font color="#1d50a2">explanation of principles\</font> 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 \<font color="#1d50a2">configuration\</font> 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 \<actionid>is the priority id (0 9999 9999), the smaller the number, the earlier it will be executed; \<string>is a command string, double quotation marks are required when containing spaces 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 \<font color="#1d50a2">configuration example\</font> \<font color="#1d50a2">networking requirements\</font> 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 \<font color="#1d50a2">configuration steps\</font> 1\ create an event management applet create an applet named 'test' and enter the applet configuration view sonic(config)# event manager applet test sonic(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 enable sonic(config event applet test)# exit 4\ 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 3 sonic(config if ethernet3)# down event applet test sonic(config if ethernet3)# exit 5\ 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
