From a5f31c5cb5ff0c5ce60a2e46d9aaa063f7582c22 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Fri, 10 Apr 2026 09:18:38 -0400 Subject: [PATCH] update picked data strucures --- hbd/server/main.py | 6 +++++- hbd/server/threshold.py | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hbd/server/main.py b/hbd/server/main.py index c2597f4..9f9703f 100644 --- a/hbd/server/main.py +++ b/hbd/server/main.py @@ -89,9 +89,13 @@ async def reload_configuration(config_obj, config_path, components): # Reload users users_mod.load_users(new_config) - # Re-apply host access from updated config to all known hosts + # Re-apply host attributes from updated config to all known hosts from . import config as config_mod + dyndnshosts = config_mod.get_dyndnshosts(new_config) + watchhosts = config_mod.get_watchhosts(new_config) for hostname, host in hbdclass.Host.hosts.items(): + host.dyn = hostname in dyndnshosts + host.watched = hostname in watchhosts access = config_mod.get_host_access(new_config, hostname) host.apply_access(access["owner"], access["managers"], access["monitors"]) diff --git a/hbd/server/threshold.py b/hbd/server/threshold.py index 281d468..edac926 100644 --- a/hbd/server/threshold.py +++ b/hbd/server/threshold.py @@ -120,8 +120,11 @@ class AlertState: # Helper to sanitize numeric values for JSON (handle inf/nan) def sanitize_value(val): - if isinstance(val, float) and (math.isinf(val) or math.isnan(val)): - return None + if isinstance(val, float): + if math.isinf(val): + return "overdue" + if math.isnan(val): + return None return val result = { @@ -148,6 +151,12 @@ class AlertState: return result + def __setstate__(self, state): + """Restore from pickle, backfilling fields added after the pickle was written.""" + self.__dict__.update(state) + if not hasattr(self, 'consecutive_count'): + self.consecutive_count = 0 + def acknowledge(self): """Acknowledge this alert to stop reminder notifications.""" self.acknowledged = True