OcNOS DC : System Management Guide : Fault Management System Configuration : Event Manager
Event Manager
Overview
The event manager feature facilitates the automatic execution of a particular action item based on the event (operator log messages) that occurred in a device. This feature is configured by command line interface (CLI) and NetConf.
The following are the three parameters in the event manager feature:
Event: It is a trigger where event manager functionality starts. Once the syslog message with the details mentioned in the event occurs, an action is triggered. Some sample events are as follows:
IFMGR_IF_DOWN
IFMGR_IF_UP
STP_SET_PORT_STATE
STP_IPC_COMMUNICATION_FAIL
Action: Once an event has occurred, an action is triggered if there is a match of the event ID in the database. An action is executed by the execution of a Python script consisting of executable OcNOS commands and configurations.
The sample action script is as follows:
import sys,os,time
import subprocess
 
#MACROS#
########
TIME = 1
 
#VARIABLES#
##############
cmd_db_lock = "cmlsh -e 'configure terminal force "+str(TIME)+"'"
cli_commands ="cmlsh -e 'configure terminal' -e 'interface xe11' -e 'shutdown' -e 'commit' -e'end'"
 
if __name__ == '__main__':
#if name == 'main':
#Force user out of config mode after X seconds
os.system (cmd_db_lock)
#Wait X seconds before running clis
time.sleep(TIME)
 
os.system(cli_commands)
Policy: It maps the action with an event.
Feature Characteristics
The feature creates a database of event IDs and the corresponding actions as configured through CLI. When an event occurs, the event is matched in the database with the existing event ID, severity, and log pattern. If the event matches with the existing event in the database, it triggers a corresponding action automatically. If there is no match with the database, then no action is taken.
Configurable parameters for an event are event ID, severity, and log pattern, which are matched with the incoming log. In order to be unique, the recommendation is to have all these parameters configured for an event. Configuring the event ID is mandatory, while severity and pattern are optional. No manual configuration of severity applies the default severity of all (0-6).
Duplicate event configuration with the same value for event ID, severity, and log pattern as an existing event with a new event name is not allowed and displays an error.
The feature facilitates the configuration of one action for multiple events.
Place the action script file in the path /usr/local/etc. A warning message is displayed if the script file is not in the path, but the configuration is accepted.
The execution count or the trigger count per policy is stored and maintained. When a policy is cleared, the event and the action associated with the policy get cleared. When an action is associated with multiple policies, the action associated with the cleared policy is removed, and the same action associated with other policies remains.
This feature consumes a certain amount of CPU performance because it matches the logs recorded by the system with every configured event. Hence, a maximum number of 50 events, actions, and policies is configurable.
The command line shell (cmlsh) uses a locking mechanism. Follow the recommendation when a user or script file gets into the configure mode:
Disable the event manager feature while executing manual configuration in the system. This prevents the Python script from interfering with the manual configuration. After executing the manual configuration, enable the event manager feature.
There is a possibility of multiple Python scripts executing simultaneously. In order to sequence the configure mode execution, the Python script has the logic to wait for 45 seconds in the configure mode. This prevents the Python script from exiting without executing the commands if another script is still in configure mode.
If the script fails to execute, the event manager does not record such failures.
Validation checks:
When the feature is neither enabled nor disabled, the event, action, or policy configuration displays an error.
The event manager displays an error if an event is edited when associated with a policy.
The event manager exercises priority-based selection of policies for any incoming logs. When there are more actions associated with the same event with different event IDs, severity levels, and pattern, the priority sequence is as follows:
1. Matches the incoming log against a policy that has an event configured with all the parameters, which are event ID, severity, and pattern string.
2. Matches the incoming log against a policy that has an event configured with only event ID and severity. 
3. Matches the incoming log against a policy that has an event configured only with the event ID.  
Example 1:
For the following configuration, when actual log “2020 Jan 03 08:46:56.455 : MH2 : NSM : CRITI : [IFMGR_IF_UP_2]: Interface xe3 changed state to up“ is received, event-manager execute action a2 (file2) than action a1 as this configuration matches the best.
#event-manager event e1 IFMGR_IF_UP severity 2
#event-manager event e2 IFMGR_IF_UP severity 2 pattern “Interface xe3”
#event-manager action a1 script file1
#event-manager action a2 script file2
#event-manager policy p1 event e1 action a1
#event-manager policy p2 event e2 action a2
Example 2:
For the following configuration, when actual log “2020 Jan 03 08:46:56.455 : MH2 : NSM : CRITI : [IFMGR_IF_UP_2]: Interface xe3 changed state to up“ is received, event-manager executes either action a1 (file1) or action a2 based on whichever gets hit first during database search. The recommendation is not to mix the same event configuration with a pattern and without a pattern for the same event ID.
#event-manager event e1 IFMGR_IF_UP severity 2 pattern “Interface ”
#event-manager event e2 IFMGR_IF_UP severity 2 pattern “Interface xe3”
#event-manager action a1 script file1
#event-manager action a2 script file2
#event-manager policy p1 event e1 action a1
#event-manager policy p2 event e2 action a2
The solution supports the validation of event-id against configurable event-ids. It displays an error if the entered event-id is not supported.
Benefits
The event manager feature allows the execution of an automatic action when a failure or any other priority error occurs.
Configuration
This section shows the configuration of the Event Manager feature.
Configuring Event Manager
Follow the steps to configure the Event Manager feature.
1. Configure the command event-manager enable to enable event-manager functionality in the device.
(config)#event-manager enable
2. Follow the steps to configure an event or an action.:
To create an event, define the event name ( E1), type (syslog), event ID (IFMGR_IF_UP), and optional parameters of severity (0) and pattern (“xe5”).
(config)#event-manager event E1 type syslog IFMGR_IF_UP severity 0 pattern "xe5"
To create an action, save the python script in the /usr/local/etc path and define the action name (A1), the type (script) and the type value (ifup.py).
(config)#event-manager action A1 type script ifup.py
3. To map an event to an action, create a policy, specify the policy name (P1), and map the event name (E1) with the action name (A1).
(config)#event-manager policy P1 event E1 action A1
 
Running configurations
The running configuration is as follows:
!
event-manager enable
event-manager action A1 type script ifdown.py
event-manager event E1 type syslog IFMGR_IF_DOWN pattern "xe5"
event-manager policy P1 event E1 action A1
!
Validation
Validate the show output after configuration as shown below.
#show event-manager event all
 
Events configured : 1
 
Event Name Type Type Value Trigger Cnt Status Policy-Mapped
===================================================================================================
E1 syslog IFMGR_IF_U 0 Active P1
 
 
#show event-manager action all
 
Actions configured : 1
 
Action Name Type Type Value Trigger Cnt Policy-Count Status
=======================================================================================================
A1 script ifup.py 0 1 Active
 
#show event-manager policy all
 
Policies configured : 1
 
Policy Name Trigger Cnt Event Action Last Exec Status Last Exec Time
===============================================================================================================
P1 0 E1 A1 Not-Run -
 
****************************************************************************************************************************************
Event Manager Commands
The Event Manager feature introduces the following configuration and show commands.
clear event-manager statistics
Use this command to clear all the policies or a specific policy.
Note: The clear policy removes the action associated with this policy, but the same action associated with other policies remain.
Command Syntax
clear event-manager statistics (policy NAME|all|)
Parameters
 
Default
None
Command Mode
Configure mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration shows how to clear all the policies:
OcNOS#configure terminal
OcNOS(config)#clear event-manager statistics all
OcNOS(config)#commit
OcNOS(config)#exit
 
event-manager
Use this command to enable or disable the event manager feature. The event manager intercepts the incoming logs for the configured event when the event and action are mapped to a policy.
Use the no command to remove all the event manager configurations.
Command Syntax
event-manager (enable|disable)
no event-manager
Parameters
 
Default
None
Command Mode
Configure mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration shows how to enable the event manager:
OcNOS#configure terminal
OcNOS(config)#event-manager enable
OcNOS(config)#commit
OcNOS(config)#exit
The below configuration shows how to disable the event manager:
OcNOS#configure terminal
OcNOS(config)#event-manager disable
OcNOS(config)#commit
OcNOS(config)#exit
 
event-manager action
Use this command to create an action, configure an action name, and associate a Python script.
Use no command to remove an action.
Note: Configuration of an existing action with new parameters overwrites the old configured parameters.
Command Syntax
event-manager action NAME type script SCRIPT
no event-manager action NAME
Parameters
 
Default
None
Command Mode
Configure mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration shows how to configure an action:
OcNOS#configure terminal
OcNOS(config)#event-manager action A1 type script ifup.py
OcNOS(config)#commit
OcNOS(config)#exit
 
event-manager event
Use this command to configure an event with the event name and event ID, along with the options to configure the severity and the pattern.
Use no form of the command to remove an event or remove the parameters from an event.
Note: Configuration of an event with a different event name but the same event ID, severity, and pattern is not supported, and an error is displayed.
Note: Configuration of an existing event with new parameters overwrites the old configured parameters.
Command Syntax
event-manager event NAME type syslog EVENT-ID (severity <0-5>|all|) (pattern "PATTERN"|)
no event-manager event NAME (severity|pattern|)
Parameters
 
Default
None
Command Mode
Configure mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration shows how to configure an event:
OcNOS#configure terminal
(config)#event-manager event E1 type syslog IFMGR_IF_UP severity 0 pattern "xe5"
OcNOS(config)#commit
OcNOS(config)#exit
 
event-manager policy
Use this command to map an event to an action.
Use no command to remove a policy.
Note: Configuration of an existing policy with a new event and action overwrites the old configured mapping of the event with the action.
Command Syntax
event-manager policy NAME event NAME action NAME
no event-manager policy NAME
Parameters
 
Default
None
Command Mode
Configure mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration shows how to configure a policy:
OcNOS#configure terminal
OcNOS(config)#event-manager policy P1 event E1 action A1
OcNOS(config)#commit
OcNOS(config)#exit
 
show event-manager action
Use this command to display the action name, the action type, the Python script name, the number of times the script runs, the number of associated policies, and the status.
Command Syntax
show event-manager action (NAME|all|)
Parameters
 
Default
None
Command Mode
Exec mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration displays all the actions configured:
#show event-manager action all
 
Actions configured : 1
 
Action Name Type Type Value Trigger Cnt Policy-Count Status
=======================================================================================================
A1 script ifup.py 0 1 Active
 
 
Table P‑2-26 explains the show command output fields.
Table 2-26: show event-manager action
Field
Description
Action Name
Displays the name of the configured action or actions.
Type
Displays the type of the action or actions.
Type Value
Displays the name of the Python script.
Trigger Cnt
Displays the number of time the action runs the script.
Policy-Count
Displays the number of policies associated with the action.
Status
Displays if the action is active or not. The action remains inactive if not mapped with a policy.
 
show event-manager event
Use this command to display the event name, the event type, the event ID, the number of times the event was triggered, the event status, and the associated policy.
Command Syntax
show event-manager event (NAME|all|)
Parameters
 
Default
None
Command Mode
Exec mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration displays all the event configured:
OcNOS#show event-manager event all
 
Events configured : 1
 
Event Name Type Type Value Trigger Cnt Status Policy-Mapped
===================================================================================================
E1 syslog IFMGR_IF_U 0 Active P1
 
Table P‑2-27 explains the show command output fields.
Table 2-27: show event-manager event output fields
Field
Description
Event Name
Displays the name of the configure event or events.
Type
Displays the type of the event or events.
Type Value
Displays the event IDs.
Trigger Cnt
Displays the number of time the event is matched with the incoming log and triggered an action.
Status
Displays if the event is active or not. The event remains inactive if not mapped with a policy.
Policy-Mapped
Displays the policy name associated with the event.
 
show event-manager policy
Use this command to display the policy name, number of times the event triggers the action, the event name, the action name, the status of the last action triggered, and the time of last action triggered.
Command Syntax
show event-manager policy (NAME|all|)
Parameters
 
Default
None
Command Mode
Exec mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The below configuration displays all the event configured:
#show event-manager policy all
 
Policies configured : 1
 
Policy Name Trigger Cnt Event Action Last Exec Status Last Exec Time
===============================================================================================================
P1 0 E1 A1 Not-Run -
 
Table P‑2-28 explains the show command output fields.
Table 2-28: show event-manager policy
Field
Description
Policy Name
Displays the name of the configured policy or policies.
Trigger Cnt
Displays the number of time the action runs the script.
Event
Displays the name of the associated event.
Action
Displays the name of the associated action.
Last Exec Status
Status of the last action triggered.
Last Exec Time
Time of the last action triggered.
 
show event-manager system-event-ids
Use this command to display all the event IDs.
Command Syntax
show event-manager system-event-ids (all| SUBSTRING)
Parameters
 
Default
None
Command Mode
Exec mode
Applicability
Introduced in OcNOS version 6.5.1.
Examples
The command below displays all the event IDs supported in OcNOS.
OcNOS#show event-manager system-event-ids all
 
IFMGR_IF_DOWN IFMGR_IF_UP
STP_SET_PORT_STATE STP_IPC_COMMUNICATION_FAIL
STP_ROOTGUARD_PORT_BLOCK STP_BPDUGUARD_PORT_BLOCK
MCEC_CONF_MISMATCH BGP_VPLS_CREATE_ERR
BGP_VPLS_SAME_VE_ID_ERR BGP_VPLS_MTU_MISMATCH_ERR
:::::
:::::
The command below displays all the event IDs configured with substring “OSPF” supported in OcNOS.
OcNOS#show event-manager system-event-ids ospf
OSPF_OPR_INIT_FAILED OSPF_OPR_GRACEFUL_RESTART_FAILED
OSPF_OPR_MEM_EXHAUST OSPF_OPR_DUPLICATE_ROUTER_ID
OSPF_OPR_SELF_ORIGINATED_LSA_RECVD OSPF_OPR_IFMGR_FAIL
OSPF_OPR_SESSION_DOWN OSPF_OPR_TERMINATE
OSPF_OPR_SOCK_FAIL OSPF_OPR_SPF_EMPTY_RLSA
OSPF_OPR_INACTIVITY_TIMER_EXPIRED OSPF_OPR_LOWER_LEVEL_DOWN
OSPF_OPR_BFD_SESSION_DOWN OSPF_OPR_LSDB_OVERFOW
:::
:::
Glossary
The following provides definitions for key terms or abbreviations and their meanings used throughout this document:
 
Key Terms/Acronym
Description
Python script
This is a script file containing a sequence of code that executes an action when an event is triggered. This is a text file with “.py” extension.