diff --git a/hbd/server/main.py b/hbd/server/main.py index 4ed1230..42f5f20 100644 --- a/hbd/server/main.py +++ b/hbd/server/main.py @@ -475,6 +475,7 @@ def run(config, config_path=None): if config.get("debug", 0) > 0: log_level = logging.DEBUG logging.basicConfig(level=log_level) + logging.getLogger("aiohttp.access").setLevel(logging.DEBUG) load_pickled_hosts(config, hbdclass) notify_mod.initlog(logfile=config.get("logfile", "messages.log")) diff --git a/hbd/server/threshold.py b/hbd/server/threshold.py index ed6dad2..1a2511d 100644 --- a/hbd/server/threshold.py +++ b/hbd/server/threshold.py @@ -1043,7 +1043,10 @@ class ThresholdChecker: # Format operator symbol op_symbol = threshold.operator.value - + + # Short metric label: strip the plugin-name prefix for readability + short_path = metric_path.partition(".")[2] or metric_path + # 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 @@ -1065,25 +1068,25 @@ class ThresholdChecker: if new_level == AlertLevel.OK: lvl = "RECOVER" - message = f"{metric_path} = {display_value} ({old_level.name} -> OK)" + message = f"{short_path} = {display_value} ({old_level.name} -> OK)" elif new_level == AlertLevel.WARNING: lvl = "WARNING" if has_display: - message = f"{metric_path} = {display_value} {_fmt()}" + message = f"{short_path} = {display_value} {_fmt()}" else: - message = f"{metric_path} = {display_value}" + message = f"{short_path} = {display_value}" elif new_level == AlertLevel.CRITICAL: lvl = "CRITICAL" if has_display: - message = f"{metric_path} = {display_value} {_fmt()}" + message = f"{short_path} = {display_value} {_fmt()}" else: - message = f"{metric_path} = {display_value}" + message = f"{short_path} = {display_value}" else: lvl = "UNKNOWN" if has_display: - message = f"{metric_path} = {display_value} {_fmt()}" + message = f"{short_path} = {display_value} {_fmt()}" else: - message = f"{metric_path} = {display_value}" + message = f"{short_path} = {display_value}" # Formatted threshold info stored on AlertState for the UI formatted_threshold_msg = _fmt() if has_display and new_level != AlertLevel.OK else None @@ -1157,6 +1160,9 @@ class ThresholdChecker: Returns: Formatted display string """ + if not display_format: + display_format = "(threshold: {op_symbol} {threshold_value})" if threshold_value is not None else "" + # Build format context with standard variables format_context = { 'value': value, @@ -1338,7 +1344,8 @@ class ThresholdChecker: # Format operator symbol op_symbol = threshold.operator.value - + short_path = metric_path.partition(".")[2] or metric_path + # Time to re-notify if threshold_value is not None: # Use display format string @@ -1351,9 +1358,9 @@ class ThresholdChecker: check_name=check_name, metric_name=metric_name, ) - message = f"REMINDER ({alert_state.level.name}): {host_name} - {metric_path} = {value} {threshold_info}, ongoing for {int(now - alert_state.since)}s" + message = f"REMINDER ({alert_state.level.name}): {host_name} - {short_path} = {value} {threshold_info}, ongoing for {int(now - alert_state.since)}s" else: - message = f"REMINDER ({alert_state.level.name}): {host_name} - {metric_path} = {value} (ongoing for {int(now - alert_state.since)}s)" + message = f"REMINDER ({alert_state.level.name}): {host_name} - {short_path} = {value} (ongoing for {int(now - alert_state.since)}s)" from . import hbdclass host = hbdclass.Host.hosts.get(host_name) diff --git a/hbd/server/udp.py b/hbd/server/udp.py index b5ad5ad..1a1fa1f 100644 --- a/hbd/server/udp.py +++ b/hbd/server/udp.py @@ -336,8 +336,7 @@ def handle_datagram(msg: dict, addr, transport, ctx: dict): # Apply user-access settings from config access = config_mod.get_host_access(cfg, uname) host.apply_access(access["owner"], access["managers"], access["monitors"]) - if verbose: - print(("XX: New host, num now %s" % (len(hbdcls.Host.hosts)))) + logger.info("New host signed on: %s (dyn=%s, access=%s)", uname, host.dyn, access) newh = True else: host = hbdcls.Host.hosts[uname]