diff --git a/hbd/client/config.py b/hbd/client/config.py index 9b85fc7..2b1d242 100644 --- a/hbd/client/config.py +++ b/hbd/client/config.py @@ -15,12 +15,15 @@ CLIENT_DEFAULTS = { # Network settings "hb_port": 50003, # Port where hbd servers listen "interval": 10, # Heartbeat interval in seconds - + + # Host identity + "owner": None, # Optional username to set as this host's owner on the server + # Runtime flags "foreground": False, "verbose": False, "debug": 0, - + # Plugin configuration "plugins": {}, # Per-plugin configuration "thresholds": {}, # Threshold configuration for monitoring diff --git a/hbd/client/plugin.py b/hbd/client/plugin.py index 1dcd04c..1cce13a 100644 --- a/hbd/client/plugin.py +++ b/hbd/client/plugin.py @@ -364,7 +364,10 @@ class PluginLoader: # Instantiate plugin with config — check plugins subdict first, # then top-level keys (e.g. nagios_runner: ... at root of config). - plugin_instance_config = plugins_subconfig.get(obj.name) or raw_config.get(obj.name, {}) + plugin_instance_config = dict(plugins_subconfig.get(obj.name) or raw_config.get(obj.name) or {}) + # Propagate top-level owner so os_info (and any future plugin) can report it. + if "owner" in raw_config and "owner" not in plugin_instance_config: + plugin_instance_config["owner"] = raw_config["owner"] plugin = obj(config=plugin_instance_config) # Initialize plugin diff --git a/hbd/client/plugins/os_info.py b/hbd/client/plugins/os_info.py index be5c8b2..c5f3570 100644 --- a/hbd/client/plugins/os_info.py +++ b/hbd/client/plugins/os_info.py @@ -62,6 +62,8 @@ class OSInfoPlugin(InfoPlugin): "hbc_version": hbc_version, "hbc_type": "full", } + if self.config.get("owner"): + data["owner"] = self.config["owner"] # Add Linux-specific distribution info if platform.system() == "Linux": diff --git a/hbd/server/templates/live.html b/hbd/server/templates/live.html index a5fb356..d9fc0ea 100644 --- a/hbd/server/templates/live.html +++ b/hbd/server/templates/live.html @@ -474,7 +474,10 @@ } else if (state.type == "message") { var msgs = document.getElementById("messages"); var msg = state.data; - var ts_str = new Date(msg.ts * 1000).toLocaleString(); + var _d = new Date(msg.ts * 1000); + function _p(n) { return n < 10 ? '0' + n : '' + n; } + var ts_str = _d.getFullYear() + '-' + _p(_d.getMonth()+1) + '-' + _p(_d.getDate()) + + ' ' + _p(_d.getHours()) + ':' + _p(_d.getMinutes()) + ':' + _p(_d.getSeconds()); var lvl = (msg.level || "INFO").toLowerCase(); var html = '