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:

  • start must be less than or equal to end
  • Ranges by default are exclusive. A range of 10:20 will match values that are < 10 OR >20.
  • @ means the range is inclusive. So @10:20 is valid in the case that the value is >= 10 AND <= 20.
  • If start or end is ~, this value is negative or positive inifinity, respectively. A range of ~:20 will match values that are > 20 only.
  • If start is not given, then it is assumed to be 0.
  • If end is not given, but a : exists, then end is assumed to be infinity. Example: 5: would match < 5.
in_range(value)[source]

Tests whether value is in this range.

__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:~"
class pycinga.range.RangeValueError[source]

This exception is raised when an invalid value is passed to Range. The message of this exception will contain a human readable explanation of the error.