10.3. Classes and Functions¶
nw2functions.alert()returns list of instances of the class
Alert. You can ignore them in your normal Python rules script but it can be useful to check their fields in unit tests. See Examples of Unit Tests for some examples. Here we provide description of the attributes and functions of objects of this class.
List of strings: names of the notification streams this alert is configured with
Name of this alert
The name of the device taken from the input monitorign variable
Device id taken from the input monitoring variable
Component name (or interface name) from the input monitoring variable
Component index (or interface ifIndex) from the input monitoring variable
Input monitoring variable value that triggered the alert. Note that if the call to
nw2functions.alert()specifies non-zero time interval and percentage, then this field is filled with the value of the last matching observation in the input variable time series.
Alert description with all macros expanded.
A dictionary that provides additional details for the alert, with all macros expanded. More information is provided in the description of function
Tags copied from the input monitoring variable instance that triggered the alert (set of strings)
The triplet (handle) of the alert monitoring variable. This is composed from the alert name, device id and component index.
The triplet (handle) of the input monitoring variable that triggered the alert. Note that this only makes sence and is filled with a non-empty string if the alert is configured to fan-out, in which case the call to
nw2functions.alert()creates separate Alert object for each matching instance of the input monitoring variable. However if the call to
nw2functions.alert()used temporary variable as input, this field is going to be blank.
This field is always blank in the non-fan out alerts.
The time stamp (ms) of the moment when this alert changed its state from “Cleared” to “Active”
The same time, converted to string, taking into account time zone configured in the main configuration file.
(boolean), true if the alert is active right now
(boolean), true if the alert matches any silence(s) that exist in the system. Alert can be active and silenced at the same time
The id of the silence matching this alert (only if field silenced has value true)
the time stamp (ms) when alert was updated last time