Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

fix(agents,ai): host URL field, AI Docker routing, Proxmox registration logging (#1197, #1210, #1267)

rcourtman7efcec3120b1
diff --git a/frontend-modern/src/components/Settings/UnifiedAgents.tsx b/frontend-modern/src/components/Settings/UnifiedAgents.tsx
index dae800de74..60a29f13d7 100644
--- a/frontend-modern/src/components/Settings/UnifiedAgents.tsx
+++ b/frontend-modern/src/components/Settings/UnifiedAgents.tsx
@@ -1,4 +1,4 @@
-import { Component, createSignal, Show, For, onMount, createEffect, createMemo } from 'solid-js';
+import { Component, createSignal, Show, For, onMount, createEffect, createMemo, untrack } from 'solid-js';
import { useNavigate } from '@solidjs/router';
import { useWebSocket } from '@/App';
import { Card } from '@/components/shared/Card';
@@ -9,6 +9,7 @@ import { ProxmoxIcon } from '@/components/icons/ProxmoxIcon';
import { formatRelativeTime, formatAbsoluteTime } from '@/utils/format';
import { MonitoringAPI } from '@/api/monitoring';
import { AgentProfilesAPI, type AgentProfile, type AgentProfileAssignment } from '@/api/agentProfiles';
+import { HostMetadataAPI } from '@/api/hostMetadata';
import { SecurityAPI } from '@/api/security';
import { notificationStore } from '@/stores/notifications';
import type { SecurityStatus } from '@/types/config';
@@ -172,6 +173,8 @@ export const UnifiedAgents: Component = () => {
const [pendingCommandConfig, setPendingCommandConfig] = createSignal<Record<string, { enabled: boolean; timestamp: number }>>({});
const [pendingScopeUpdates, setPendingScopeUpdates] = createSignal<Record<string, boolean>>({});
const [expandedRowKey, setExpandedRowKey] = createSignal<string | null>(null);
+ const [hostCustomUrl, setHostCustomUrl] = createSignal('');
+ const [hostCustomUrlSaving, setHostCustomUrlSaving] = createSignal(false);
const [filterType, setFilterType] = createSignal<'all' | UnifiedAgentType>('all');
const [filterStatus, setFilterStatus] = createSignal<'all' | UnifiedAgentStatus>('all');
const [filterScope, setFilterScope] = createSignal<'all' | Exclude<ScopeCategory, 'na'>>('all');
@@ -541,6 +544,23 @@ export const UnifiedAgents: Component = () => {
setExpandedRowKey(prev => (prev === rowKey ? null : rowKey));
};
+ const saveHostUrl = async (hostId: string) => {
+ if (hostCustomUrlSaving()) return;
+ setHostCustomUrlSaving(true);
+ const trimmed = hostCustomUrl().trim();
+
+ try {
+ await HostMetadataAPI.updateMetadata(hostId, { customUrl: trimmed });
+ setHostCustomUrl(trimmed);
+ notificationStore.success('Custom URL saved');
+ } catch (err) {
+ logger.error('Failed to save host metadata', err);
+ notificationStore.error('Failed to save custom URL');
+ } finally {
+ setHostCustomUrlSaving(false);
+ }
+ };
+
const legacyAgents = createMemo(() => allHosts().filter(h => h.isLegacy));
const hasLegacyAgents = createMemo(() => legacyAgents().length > 0);
@@ -671,6 +691,33 @@ export const UnifiedAgents: Component = () => {
return rows;
});
+ createEffect(() => {
+ const key = expandedRowKey();
+ if (!key) {
+ setHostCustomUrl('');
+ return;
+ }
+
+ const row = untrack(() => unifiedRows().find(r => r.rowKey === key));
+ if (!row || row.status !== 'active' || !row.types.includes('host')) {
+ setHostCustomUrl('');
+ return;
+ }
+
+ const currentKey = key;
+ void (async () => {
+ try {
+ const metadata = await HostMetadataAPI.getMetadata(row.id);
+ if (expandedRowKey() !== currentKey) return;
+ setHostCustomUrl(metadata.customUrl || '');
+ } catch (err) {
+ logger.error('Failed to load host metadata', err);
+ if (expandedRowKey() !== currentKey) return;
+ setHostCustomUrl('');
+ }
+ })();
+ });
+
const filteredRows = createMemo(() => {
const query = filterSearch().trim().toLowerCase();
return unifiedRows().filter(row => {
@@ -1608,6 +1655,38 @@ export const UnifiedAgents: Component = () => {
Linked node ID: <span class="font-mono text-gray-700 dark:text-gray-200">{row.linkedNodeId}</span>
</div>
</Show>
+ <Show when={row.status === 'active' && row.types.includes('host')}>
+ <div class="rounded-lg border border-gray-200 bg-white px-4 py-3 dark:border-gray-700 dark:bg-gray-900/30">
+ <label class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1.5">
+ Custom URL
+ </label>
+ <div class="flex gap-2">
+ <input
+ type="text"
+ value={hostCustomUrl()}
+ onInput={(event) => setHostCustomUrl(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' && !hostCustomUrlSaving()) {
+ void saveHostUrl(row.id);
+ }
+ }}
+ placeholder="https://host.example.com"
+ class="flex-1 rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-100 dark:focus:border-blue-400 dark:focus:ring-blue-800"
+ />
+ <button
+ type="button"
+ onClick={() => void saveHostUrl(row.id)}
+ disabled={hostCustomUrlSaving()}
+ class="inline-flex items-center justify-center rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-60"
+ >
+ {hostCustomUrlSaving() ? 'Saving…' : 'Save'}
+ </button>
+ </div>
+ <p class="mt-1.5 text-xs text-gray-500 dark:text-gray-400">
+ Optional override used when Pulse links to this host (leave blank to use the default).
+ </p>
+ </div>
+ </Show>
<Show when={row.status === 'active' && row.lastSeen}>
<div class="text-xs text-gray-500 dark:text-gray-400">
Last seen {formatRelativeTime(row.lastSeen)} ({formatAbsoluteTime(row.lastSeen)})
diff --git a/internal/ai/tools/tools_query.go b/internal/ai/tools/tools_query.go
index 0a039ebb5f..353dd11320 100644
--- a/internal/ai/tools/tools_query.go
+++ b/internal/ai/tools/tools_query.go
@@ -2152,6 +2152,27 @@ func (e *PulseToolExecutor) executeListInfrastructure(_ context.Context, args ma
connectedAgentHostnames[agent.Hostname] = true
}
}
+ // Also mark Docker hosts reachable if they are VMs/containers whose Proxmox
+ // node has a connected agent (mirrors resolveDockerHostRoutingFull routing).
+ for _, host := range state.DockerHosts {
+ if connectedAgentHostnames[host.Hostname] {
+ continue // already marked reachable
+ }
+ for _, vm := range state.VMs {
+ if vm.Name == host.Hostname && connectedAgentHostnames[vm.Node] {
+ connectedAgentHostnames[host.Hostname] = true
+ break
+ }
+ }
+ if !connectedAgentHostnames[host.Hostname] {
+ for _, ct := range state.Containers {
+ if ct.Name == host.Hostname && connectedAgentHostnames[ct.Node] {
+ connectedAgentHostnames[host.Hostname] = true
+ break
+ }
+ }
+ }
+ }
response := InfrastructureResponse{
Total: TotalCounts{
@@ -2364,6 +2385,27 @@ func (e *PulseToolExecutor) executeGetTopology(_ context.Context, args map[strin
connectedAgentHostnames[agent.Hostname] = true
}
}
+ // Also mark Docker hosts reachable if they are VMs/containers whose Proxmox
+ // node has a connected agent (mirrors resolveDockerHostRoutingFull routing).
+ for _, host := range state.DockerHosts {
+ if connectedAgentHostnames[host.Hostname] {
+ continue // already marked reachable
+ }
+ for _, vm := range state.VMs {
+ if vm.Name == host.Hostname && connectedAgentHostnames[vm.Node] {
+ connectedAgentHostnames[host.Hostname] = true
+ break
+ }
+ }
+ if !connectedAgentHostnames[host.Hostname] {
+ for _, ct := range state.Containers {
+ if ct.Name == host.Hostname && connectedAgentHostnames[ct.Node] {
+ connectedAgentHostnames[host.Hostname] = true
+ break
+ }
+ }
+ }
+ }
// Check if control is enabled
controlEnabled := e.controlLevel != ControlLevelReadOnly && e.controlLevel != ""
diff --git a/internal/hostagent/proxmox_setup.go b/internal/hostagent/proxmox_setup.go
index eded8b4493..30adf0b3e7 100644
--- a/internal/hostagent/proxmox_setup.go
+++ b/internal/hostagent/proxmox_setup.go
@@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "io"
"net"
"net/http"
"net/url"
@@ -169,7 +170,7 @@ func (p *ProxmoxSetup) Run(ctx context.Context) (*ProxmoxSetupResult, error) {
// Register with Pulse
registered := false
if err := p.registerWithPulse(ctx, ptype, hostURL, tokenID, tokenValue); err != nil {
- p.logger.Warn().Err(err).Msg("Failed to register with Pulse (node may already exist)")
+ p.logger.Warn().Err(err).Msg("Failed to register Proxmox node with Pulse; if the node does not appear, delete /var/lib/pulse-agent/proxmox-pve-registered (or proxmox-pbs-registered) to force re-registration")
} else {
registered = true
p.markAsRegistered()
@@ -252,7 +253,7 @@ func (p *ProxmoxSetup) runForType(ctx context.Context, ptype string) (*ProxmoxSe
// Register with Pulse
registered := false
if err := p.registerWithPulse(ctx, ptype, hostURL, tokenID, tokenValue); err != nil {
- p.logger.Warn().Err(err).Str("type", ptype).Msg("Failed to register with Pulse (node may already exist)")
+ p.logger.Warn().Err(err).Str("type", ptype).Msg("Failed to register Proxmox node with Pulse; if the node does not appear, delete /var/lib/pulse-agent/proxmox-pve-registered (or proxmox-pbs-registered) to force re-registration")
} else {
registered = true
p.markTypeAsRegistered(ptype)
@@ -670,7 +671,8 @@ func (p *ProxmoxSetup) registerWithPulse(ctx context.Context, ptype, hostURL, to
defer resp.Body.Close()
if resp.StatusCode >= 400 {
- return fmt.Errorf("auto-register returned %d", resp.StatusCode)
+ bodyBytes, _ := io.ReadAll(io.LimitReader(resp.Body, 512))
+ return fmt.Errorf("auto-register returned HTTP %d: %s", resp.StatusCode, strings.TrimSpace(string(bodyBytes)))
}
return nil