range - Tools for Working with Icinga Ranges¶
Contains a class to represent a range that adheres to the range format defined by Icinga.
-
class
pycinga.range.Range(value)[source]¶ Initializes an Icinga range with the given value. The value should be in the Icinga range format, which is the following:
[@]start:end
Notes:
startmust be less than or equal toend- Ranges by default are exclusive. A range of
10:20will match values that are< 10 OR >20. @means the range is inclusive. So@10:20is valid in the case that the value is>= 10 AND <= 20.- If
startorendis~, this value is negative or positive inifinity, respectively. A range of~:20will match values that are> 20only. - If
startis not given, then it is assumed to be 0. - If
endis not given, but a:exists, thenendis assumed to be infinity. Example:5:would match< 5.
-
__str__()[source]¶ Turns this range object back into a valid range string which can be passed to another plugin or used for debug output. The string returned from here should generally be equivalent to the value given to the constructor, but sometimes it can be slightly different. However, it will always be functionally equivalent.
Examples:
>> str(Range("@10:20")) == "@10:20" >> str(Range("10")) == "10" >> str(Range("10:")) == "10:~"