Interface Statistics Collection Event Subscription
Interface Name
Interface statistics collection event subscription
Application Phase
Subscription phase
API Prototype
result1_value, result2_description = ops.ifm.subscribe(tag, interface, monitor-packet, start-op, start-val, restart-op, restart-val, interval)
Description
Parameter |
Description |
Value |
---|---|---|
tag |
Indicates conditions. |
The value is a string of 1 to 12 case-insensitive characters, consists of letters, digits, and underscores (_), and starts with a letter. The value cannot be one of the following: "", None, and, or, andnot. The value cannot contain \0. |
interface |
Indicates the interface name consisting of the interface type and number. |
The value is a string of characters and must be a complete interface name (GigabitEthernet0/0/1, for example) but not an abbreviation. |
monitor-packet |
Indicates the type of a monitored packet. |
The value is of the enumerated type:
|
start-op |
Indicates the operation code for triggering execution of a monitoring policy. |
The value is of the enumerated type:
|
start-val |
Indicates the value of a monitoring object that triggers execution of a monitoring policy. |
The value is an integer that ranges from 0 to 4294967295. The unit depends on the value of monitor-packet. |
restart-op |
Indicates the operation code for turning on a trigger switch again. |
The value is of the enumerated type:
|
restart-val |
Indicates the value of a monitoring object that turns on the trigger switch again. |
The value is an integer that ranges from 0 to 4294967295. The unit depends on the value of monitor-packet. |
interval |
Indicates the sampling interval for the monitoring object data. |
The value is an integer that ranges from 20 to 4294967295, in seconds. |
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
If multiple simple events are defined using the ops.ifm.subscribe API in the subscription phase, but the simple events are not combined through the Multi-Condition Combination API, the Python script assistant cannot be configured.
Using the interface statistics collection event subscription, you can monitor statistics on sent and received packets on a specified interface. The process is as follows:
- Subscribe to this event, install the Python script, and configure the script assistant, and turn on the trigger switch immediately.
- When the number of specified packets on an interface meets conditions defined in start-op and start-val parameters, the corresponding action is triggered (first execution) and the trigger switch is turned off, but the system continues monitoring statistics collected on the interface.
- When conditions defined in restart-op and restart-val parameters are met, the trigger switch is turned on again.
- When the number of specified packets on an interface meets conditions defined in start-op and start-val parameters, the corresponding action is triggered again (second execution) and the trigger switch is turned off, but the system continues monitoring statistics collected on the interface.
- The process cycles in the specified sampling interval.
Example
Obtain the number of error packets received on GigabitEthernet0/0/1 every 60 seconds. When the number of error packets is greater than 1000, the corresponding action is triggered and the trigger switch is turned off. When the number of error packets is smaller than 50, the trigger switch is turned on again. This process cycles.
value, descri_str = ops.ifm.subscribe("err_packet", "GigabitEthernet0/0/1", "input-errors", "gt", 1000, "lt", 50, 60)