Show overdue in alerts instead of null
This commit is contained in:
+13
-11
@@ -941,48 +941,50 @@ class ThresholdChecker:
|
|||||||
# Format operator symbol
|
# Format operator symbol
|
||||||
op_symbol = threshold.operator.value
|
op_symbol = threshold.operator.value
|
||||||
|
|
||||||
|
# Use a display-friendly value (inf is the sentinel for "overdue")
|
||||||
|
import math
|
||||||
|
display_value = "overdue" if isinstance(value, float) and math.isinf(value) else value
|
||||||
|
|
||||||
# Format message
|
# Format message
|
||||||
if new_level == AlertLevel.OK:
|
if new_level == AlertLevel.OK:
|
||||||
lvl = "RECOVERED"
|
lvl = "RECOVERED"
|
||||||
message = f"{metric_path} = {value} ({old_level.name} -> OK)"
|
message = f"{metric_path} = {display_value} ({old_level.name} -> OK)"
|
||||||
elif new_level == AlertLevel.WARNING:
|
elif new_level == AlertLevel.WARNING:
|
||||||
lvl = "WARNING"
|
lvl = "WARNING"
|
||||||
if threshold_value is not None:
|
if threshold_value is not None:
|
||||||
# Use display format string
|
|
||||||
threshold_info = self._format_display(
|
threshold_info = self._format_display(
|
||||||
threshold.display,
|
threshold.display,
|
||||||
value=value,
|
value=display_value,
|
||||||
threshold_value=threshold_value,
|
threshold_value=threshold_value,
|
||||||
op_symbol=op_symbol,
|
op_symbol=op_symbol,
|
||||||
plugin_data=plugin_data
|
plugin_data=plugin_data
|
||||||
)
|
)
|
||||||
message = f"{metric_path} = {value} {threshold_info}"
|
message = f"{metric_path} = {display_value} {threshold_info}"
|
||||||
else:
|
else:
|
||||||
message = f"{metric_path} = {value}"
|
message = f"{metric_path} = {display_value}"
|
||||||
elif new_level == AlertLevel.CRITICAL:
|
elif new_level == AlertLevel.CRITICAL:
|
||||||
lvl = "CRITICAL"
|
lvl = "CRITICAL"
|
||||||
if threshold_value is not None:
|
if threshold_value is not None:
|
||||||
# Use display format string
|
|
||||||
threshold_info = self._format_display(
|
threshold_info = self._format_display(
|
||||||
threshold.display,
|
threshold.display,
|
||||||
value=value,
|
value=display_value,
|
||||||
threshold_value=threshold_value,
|
threshold_value=threshold_value,
|
||||||
op_symbol=op_symbol,
|
op_symbol=op_symbol,
|
||||||
plugin_data=plugin_data
|
plugin_data=plugin_data
|
||||||
)
|
)
|
||||||
message = f"{metric_path} = {value} {threshold_info}"
|
message = f"{metric_path} = {display_value} {threshold_info}"
|
||||||
else:
|
else:
|
||||||
message = f"{metric_path} = {value}"
|
message = f"{metric_path} = {display_value}"
|
||||||
else:
|
else:
|
||||||
lvl = "UNKNOWN"
|
lvl = "UNKNOWN"
|
||||||
message = f"{metric_path} = {value}"
|
message = f"{metric_path} = {display_value}"
|
||||||
|
|
||||||
# Return the formatted threshold info for storing in AlertState
|
# Return the formatted threshold info for storing in AlertState
|
||||||
formatted_threshold_msg = None
|
formatted_threshold_msg = None
|
||||||
if threshold_value is not None and new_level != AlertLevel.OK:
|
if threshold_value is not None and new_level != AlertLevel.OK:
|
||||||
formatted_threshold_msg = self._format_display(
|
formatted_threshold_msg = self._format_display(
|
||||||
threshold.display,
|
threshold.display,
|
||||||
value=value,
|
value=display_value,
|
||||||
threshold_value=threshold_value,
|
threshold_value=threshold_value,
|
||||||
op_symbol=op_symbol,
|
op_symbol=op_symbol,
|
||||||
plugin_data=plugin_data
|
plugin_data=plugin_data
|
||||||
|
|||||||
Reference in New Issue
Block a user