diff --git a/hbd/server/threshold.py b/hbd/server/threshold.py index 3572e19..80b9d80 100644 --- a/hbd/server/threshold.py +++ b/hbd/server/threshold.py @@ -492,7 +492,27 @@ class ThresholdChecker: raw_overrides: Dict[str, ThresholdConfig] = {} thresholds_config = config_data["thresholds"] for plugin_name, plugin_thresholds in thresholds_config.items(): - if isinstance(plugin_thresholds, dict): + if not isinstance(plugin_thresholds, dict): + continue + plugin_enabled = plugin_thresholds.get('enabled', plugin_thresholds.get('enable', True)) + if not plugin_enabled: + # raw_overrides is empty at this point so there's nothing to delete. + # Instead, inject disabled stubs for every matching effective_default so + # the merge step overwrites the inherited defaults. + for key, tc in effective_defaults.items(): + if key.startswith(f"{plugin_name}."): + raw_overrides[key] = ThresholdConfig( + metric_path=key, + warning=tc.warning, + critical=tc.critical, + operator=tc.operator.value, + enabled=False, + ) + logger.info( + "Plugin-level disable in config '%s': disabled all thresholds for %s", + config_name, plugin_name, + ) + else: self._parse_plugin_thresholds(plugin_name, plugin_thresholds, target_dict=raw_overrides) self.threshold_raw_configs[config_name] = raw_overrides @@ -570,7 +590,16 @@ class ThresholdChecker: if plugin_name == "rtt": self._parse_rtt_thresholds(thresholds, target_dict) return - + + # Plugin-level enabled: false (also accept 'enable' as a common typo) removes all + # thresholds for this plugin — e.g. memory_monitor: {enabled: false}. + plugin_enabled = thresholds.get('enabled', thresholds.get('enable', True)) + if not plugin_enabled: + for key in [k for k in target_dict if k.startswith(f"{plugin_name}.")]: + del target_dict[key] + logger.info("Plugin-level disable: removed all thresholds for %s", plugin_name) + return + for metric_name, threshold_config in thresholds.items(): if not isinstance(threshold_config, dict): continue