From 628ae67b7def027553c287cfd71f840570469bce Mon Sep 17 00:00:00 2001 From: Damocles Date: Thu, 7 May 2026 21:36:58 +0200 Subject: [PATCH] systemd: hm-module systemd.machines option + warn on fetch failures --- nix/hm-module.nix | 20 ++++++++++++++++++++ plugin/src/systemd_service.rs | 14 +++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 51758cf..b73bdc4 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -240,6 +240,26 @@ in }; }; }; + systemd = moduleOpt "systemd" ( + (intervalOpt 15000) + // { + machines = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + example = [ + "muede-pc2" + "monitoring@server.example.com" + ]; + description = '' + SSH targets to query via `busctl --host=` for the + systemd applet's cross-machine tree. May include `localhost` / + the local hostname; duplicates are deduped at runtime. SSH + auth (keys, known_hosts, ssh config aliases) is the user's + responsibility - nova-shell only spawns busctl. + ''; + }; + } + ); statsDaemon = lib.mkOption { default = { }; description = "Configuration for the nova-stats daemon."; diff --git a/plugin/src/systemd_service.rs b/plugin/src/systemd_service.rs index 4b55cb0..1479b56 100644 --- a/plugin/src/systemd_service.rs +++ b/plugin/src/systemd_service.rs @@ -486,8 +486,12 @@ impl qobject::SystemdService { local_container_names .iter() .map(|(name, _, _)| { - fetch_via_busctl(name, &["--machine", name], false, "") - .unwrap_or_else(|(k, r)| MachineJson::errored(name.clone(), k, r, 0)) + fetch_via_busctl(name, &["--machine", name], false, "").unwrap_or_else( + |(k, r)| { + tracing::warn!(target: "nova_plugin::systemd", machine = %name, kind = k, error = %r, "local container fetch failed"); + MachineJson::errored(name.clone(), k, r, 0) + }, + ) }) .collect() } else { @@ -555,12 +559,16 @@ impl qobject::SystemdService { false, "", ) - .unwrap_or_else(|(k, r)| MachineJson::errored(cn.clone(), k, r, 0)) + .unwrap_or_else(|(k, r)| { + tracing::warn!(target: "nova_plugin::systemd", host = %target, machine = %cn, kind = k, error = %r, "remote container fetch failed"); + MachineJson::errored(cn.clone(), k, r, 0) + }) }) .collect(); m } Err((kind, reason)) => { + tracing::warn!(target: "nova_plugin::systemd", host = %target, kind = kind, error = %reason, "remote host fetch failed"); MachineJson::errored(target.clone(), kind, reason, prev_last_seen) } };