From 9eedbafe97d502ef77e041cfff1326bf9aaab7b0 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Fri, 10 Apr 2026 09:20:28 -0400 Subject: [PATCH] Show overdue in alerts instead of null --- hbd/server/threshold.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hbd/server/threshold.py b/hbd/server/threshold.py index edac926..10969af 100644 --- a/hbd/server/threshold.py +++ b/hbd/server/threshold.py @@ -941,48 +941,50 @@ class ThresholdChecker: # Format operator symbol 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 if new_level == AlertLevel.OK: - lvl = "RECOVERED" - message = f"{metric_path} = {value} ({old_level.name} -> OK)" + lvl = "RECOVERED" + message = f"{metric_path} = {display_value} ({old_level.name} -> OK)" elif new_level == AlertLevel.WARNING: lvl = "WARNING" if threshold_value is not None: - # Use display format string threshold_info = self._format_display( threshold.display, - value=value, + value=display_value, threshold_value=threshold_value, op_symbol=op_symbol, plugin_data=plugin_data ) - message = f"{metric_path} = {value} {threshold_info}" + message = f"{metric_path} = {display_value} {threshold_info}" else: - message = f"{metric_path} = {value}" + message = f"{metric_path} = {display_value}" elif new_level == AlertLevel.CRITICAL: lvl = "CRITICAL" if threshold_value is not None: - # Use display format string threshold_info = self._format_display( threshold.display, - value=value, + value=display_value, threshold_value=threshold_value, op_symbol=op_symbol, plugin_data=plugin_data ) - message = f"{metric_path} = {value} {threshold_info}" + message = f"{metric_path} = {display_value} {threshold_info}" else: - message = f"{metric_path} = {value}" + message = f"{metric_path} = {display_value}" else: lvl = "UNKNOWN" - message = f"{metric_path} = {value}" + message = f"{metric_path} = {display_value}" # Return the formatted threshold info for storing in AlertState formatted_threshold_msg = None if threshold_value is not None and new_level != AlertLevel.OK: formatted_threshold_msg = self._format_display( threshold.display, - value=value, + value=display_value, threshold_value=threshold_value, op_symbol=op_symbol, plugin_data=plugin_data