Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix(agent): preserve collector interface compatibility
[email protected]4918bca7393c
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 95a6f4abae..e278e89c34 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -1516,7 +1516,11 @@ the intentionally sparse public response.interface/block field selection, and no server-authored URI, domain, orcommand input. Missing clients, inaccessible sockets, unsupported drivers,partial statistics, or parse failures omit the inventory without failing- host telemetry. Authenticated ingest derives CPU and I/O rates only after+ host telemetry. Bounded command output is an optional collector capability+ rather than a new `SystemCollector` interface requirement, preserving+ compatibility with existing injected collectors; the production collector+ enforces the cap during execution and fallback collectors are rejected+ after the same size limit. Authenticated ingest derives CPU and I/O rates only aftertwo accepted samples and projects the domains as provider-neutral`technology=libvirt` VM resources parented to the reporting host. Itpreserves the last successful collection timestamp across a failed query sodiff --git a/internal/hostagent/agent_metrics_test.go b/internal/hostagent/agent_metrics_test.goindex 20175dd7c5..6e2cd06cbf 100644--- a/internal/hostagent/agent_metrics_test.go+++ b/internal/hostagent/agent_metrics_test.go@@ -725,3 +725,33 @@ smallfixnumber="3"t.Fatalf("Host.OSVersion = %q, want %q", report.Host.OSVersion, "7.2.2-72806 Update 3")}}++type legacyCommandOutputCollector struct {+ SystemCollector+ output string+ err error+}++func (c *legacyCommandOutputCollector) CommandCombinedOutput(+ context.Context,+ string,+ ...string,+) (string, error) {+ return c.output, c.err+}++func TestCollectCommandOutputLimitedKeepsLegacyCollectorsCompatible(t *testing.T) {+ collector := &legacyCommandOutputCollector{output: "123456"}+ output, err := collectCommandOutputLimited(+ context.Background(),+ collector,+ 4,+ "example-command",+ )+ if err == nil {+ t.Fatal("expected oversized legacy collector output to fail")+ }+ if output != "1234" {+ t.Fatalf("bounded output = %q, want %q", output, "1234")+ }+}diff --git a/internal/hostagent/libvirt.go b/internal/hostagent/libvirt.goindex 1be97c4551..c961590730 100644--- a/internal/hostagent/libvirt.go+++ b/internal/hostagent/libvirt.go@@ -39,6 +39,32 @@ var libvirtStatsArgs = []string{"--block",}+type limitedCommandOutputCollector interface {+ CommandCombinedOutputLimited(+ ctx context.Context,+ maxBytes int,+ name string,+ arg ...string,+ ) (string, error)+}++func collectCommandOutputLimited(+ ctx context.Context,+ collector SystemCollector,+ maxBytes int,+ name string,+ arg ...string,+) (string, error) {+ if limited, ok := collector.(limitedCommandOutputCollector); ok {+ return limited.CommandCombinedOutputLimited(ctx, maxBytes, name, arg...)+ }+ output, err := collector.CommandCombinedOutput(ctx, name, arg...)+ if len(output) > maxBytes {+ return output[:maxBytes], fmt.Errorf("command output exceeds %d bytes", maxBytes)+ }+ return output, err+}+// collectLibvirtInventory auto-detects a local read-only libvirt connection.// It is deliberately best-effort: hosts without virsh, socket access, or a// compatible driver continue reporting normal host telemetry.@@ -58,8 +84,9 @@ func (a *Agent) collectLibvirtInventory(ctx context.Context) *agentshost.LibvirtqueryCtx, cancel := context.WithTimeout(ctx, libvirtQueryTimeout)defer cancel()- listOutput, err := a.collector.CommandCombinedOutputLimited(+ listOutput, err := collectCommandOutputLimited(queryCtx,+ a.collector,libvirtMaxListOutputBytes,path,"--readonly",@@ -88,8 +115,9 @@ func (a *Agent) collectLibvirtInventory(ctx context.Context) *agentshost.Libvirtargs := make([]string, 0, len(libvirtStatsArgs)+len(names))args = append(args, libvirtStatsArgs...)args = append(args, names...)- statsOutput, err := a.collector.CommandCombinedOutputLimited(+ statsOutput, err := collectCommandOutputLimited(queryCtx,+ a.collector,libvirtMaxStatsOutputBytes,path,args...,diff --git a/internal/hostagent/sysinfo.go b/internal/hostagent/sysinfo.goindex 80cf4f0b99..b90827a592 100644--- a/internal/hostagent/sysinfo.go+++ b/internal/hostagent/sysinfo.go@@ -41,7 +41,6 @@ type SystemCollector interface {Chmod(name string, mode os.FileMode) errorWriteFile(filename string, data []byte, perm os.FileMode) errorCommandCombinedOutput(ctx context.Context, name string, arg ...string) (string, error)- CommandCombinedOutputLimited(ctx context.Context, maxBytes int, name string, arg ...string) (string, error)LookPath(file string) (string, error)}