Combined Event Trigger
Interface Name
Combined event trigger
Application Phase
Subscription phase
API Prototype
result1_value, result2_description = ops.trigger(occurs=1, period=30, delay=0, suppress=0)
Description
Parameter |
Description |
Value |
---|---|---|
occurs |
Indicates the number of times an event meets trigger conditions. |
The value is an integer that ranges from 1 to 2147483647. The default value is 1. |
period |
Indicates the detection period. If the Multi-Condition Combination API contains the operator and or andnot or the occurs parameter of ops.trigger is larger than 1, the specified detection period takes effect. |
The value is an integer that ranges from 1 to 2147483647, in seconds. The default value is 30 seconds. |
delay |
Indicates the delay in executing the action in the execution phase. After a Python script meets its subscription conditions, the execution action will be triggered after a specified delay. The script will be executed immediately for the first time without any delay. |
The value is an integer that ranges from 0 to 2147483647, in seconds. The default value is 0 seconds. |
suppress |
Indicates the number of times execution of the action in the execution phase is suppressed within a detection period. |
The value is an integer that ranges from 0 to 2147483647. The default value is 0, indicating no suppression. The value n indicates that the execution task is not executed after being executed n times, and only statistics are collected. |
Return Value
The result1_value and result2_description in the API prototype indicate return values.
The result1_value is the first return value, 0 indicates success, and 1 indicates failure.
The result2_description is the second return value, indicating the failure cause. It is returned only when the first return value is 1.
Usage Description
The values of delay and suppress cannot be non-zero at the same time.
After multiple simple events are combined into a complex event through the Multi-Condition Combination API, the corresponding action is triggered if the complex event is matched once in 30 seconds.
When you need to trigger the corresponding action after the complex event is matched multiple times, use the ops.trigger API.
For example, when a complex event (e1 and e2) is defined in the Multi-Condition Combination API and you need to trigger the corresponding action within the 20-second detection period after the complex event is matched twice, use the following statement:
value, descri_str = ops.trigger(occurs=2, period=20, delay=0, suppress=0)
Assume that e1 occurs at 0s and e2 occurs at 5s, the complex event (e1 and e2) is matched for the first time. If e1 occurs again at 10s and e2 occurs again at 15s, the complex event (e1 and e2) is matched for the second time. The complex event is matched within the 20-second detection period and the value of occurs is equal to 2, so the corresponding action is triggered.
Example
When you run the arp learning multicast disable or arp broadcast disable command twice in 1 hour, the corresponding action is triggered.
value1, descri_str1 = ops.cli.subscribe("cli1", "arp learning multicast disable", enter=True, sync=True, sync_wait=60) value2, descri_str2 = ops.cli.subscribe("cli2", "arp broadcast disable", enter=True, sync=True, sync_wait=60) value3, descri_str3 = ops.correlate("cli1 and cli2") value4, descri_str4 = ops.trigger(occurs=2, period=3600, delay=0, suppress=0)