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
Add Proxmox node thermal history
rcourtman526549dea1ef
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 2ffb304c0f..fa14fa8856 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -1019,6 +1019,13 @@ The agent runtime keeps the broadcaster wired across restarts, andthe capabilities manifest declares the stream under`subscribe_events` so the surface stays self-describing.+Shared `internal/api/router.go` metrics-history reads may now expose+host-agent CPU temperature as an `agent` chart metric for Proxmox node+drawers, but lifecycle surfaces must continue treating that data as+presentation telemetry only. Temperature history is not heartbeat authority,+agent enrollment state, or freshness proof; those remain owned by the+agent-lifecycle event, token, and last-seen contracts.+`/api/agent/capabilities` is the discovery document any externalagent reads to learn what Pulse exposes. The manifest isunauthenticated and cacheable; the underlying capabilities keepdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 5688178860..57ca46a835 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -1450,6 +1450,13 @@ Proxmox host rows with workload I/O columns. These fields are a read-modelextension over existing resource telemetry; they must remain optional until thebackend transport contract explicitly guarantees them for every node source,and consumers must tolerate absence without inventing a second API shape.+The shared metrics-history API also treats `metric=temperature` as a canonical+agent/node chart metric for Proxmox node drawers. `resourceType=agent` may serve+the current host-agent CPU package temperature as a live fallback when persisted+history is still cold, while `resourceType=node` may serve the Proxmox node+temperature fallback from the same `/api/metrics-store/history` response shape.+The transport remains the existing metrics-history payload; it must not add a+Proxmox-only chart endpoint or drawer-local temperature response contract.`aicontracts.Finding` (the shape Patrol hands the investigationorchestrator) carries optional `OperatorContext` anddiff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 8ffa688cb7..add1c8b427 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -274,6 +274,13 @@ when that span already covers the requested chart window before falling backto SQLite, so long-range chart batches do not pay an unnecessary store roundtrip just because the request is larger than the old fixed in-memorythreshold.+Agent and node CPU temperature are part of that shared metrics-history family.+`internal/monitoring/monitor_agents.go` must write the primary host-agent CPU+temperature into both in-memory guest history and the persisted `agent`+metrics-store stream, while `internal/monitoring/metrics_history.go` keeps+`temperature` alongside CPU, memory, disk, and I/O for guest and node history+reads. Mock history must seed the same metric so Proxmox node drawer thermals+exercise the production contract instead of relying on a frontend-only fallback.That same monitoring owner also owns canonical unified-resource publication on`/api/state` and the websocket `state.resources` hydrate path. Monitoring mustpublish those resources from the same canonical unified snapshot thatdiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex a14370a330..3c55db9fbd 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -560,6 +560,17 @@ related series into utilization, network I/O, and disk I/O charts rather thanrepeating one chart frame per metric. Those grouped charts must still supportinline hover inspection by updating the existing legend values and showing onlythe hovered timestamp, so density does not remove point-in-time metric detail.+Proxmox node thermals follow that same drawer-only rule: temperature remains a+node-context metric, not a universal Workloads table column, and the node detail+drawer may add one compact `Thermals` history group beside utilization and I/O+only after a grouped node row is selected. Host-agent CPU temperature must be+persisted into the same metrics-store history stream as other agent metrics,+with current node temperature used only as drawer-local fallback while history+is still accumulating.+The Proxmox node drawer overview should follow the existing guest drawer+compact detail-card pattern and expose node-specific context such as platform,+kernel, hardware, raw capacity, telemetry, and thermal facts rather than+repeating the metric cells already visible in the grouped table row.The investigation enrichment path in `MaybeInvestigateFinding`adds at most one operator-state projection lookup per investigationdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 857b5e2ed6..9a17a5c9f7 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -1312,6 +1312,11 @@ history for adjacent overview or shared summary cards, it may parallelize theprovider reads, but it must not widen the shared hot path to disk read/writeor fetch-all metrics just because storage or recovery also mount nearby chartshells.+That adjacent shared chart transport may also expose host-agent or Proxmox node+CPU temperature as `metric=temperature` for node drawers. Storage and recovery+may consume the surrounding context, but they must not reinterpret that+agent/node CPU temperature history as physical-disk SMART temperature, backup+freshness, restore evidence, or a storage-owned thermal timeline.Storage and recovery still consume the shared unified-resource contract, butthey do not own the timeline store itself. The canonical resource-changediff --git a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsxindex e18e75297b..f72de9e252 100644--- a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx@@ -29,6 +29,8 @@ import {} from './guestDrawerModel';interface GuestDrawerHistoryProps {+ fallbackMetrics?: Record<string, number | null | undefined>;+ groups?: GuestDrawerHistoryGroupConfig[];range: HistoryTimeRange;target: GuestDrawerHistoryTarget | null;}@@ -129,6 +131,11 @@ const getAxisLabel = (unit: string, pct: number): string => {if (pct === 0.5) return '50%';return '0%';}+ if (unit === 'C') {+ if (pct === 0) return 'Max';+ if (pct === 0.5) return 'Mid';+ return 'Min';+ }if (pct === 0) return 'Max';if (pct === 0.5) return 'Avg';return '0';@@ -177,6 +184,32 @@ const findClosestGuestDrawerHistoryPoint = (return closest;};+const buildFallbackHistoryPoints = (value: number): AggregatedMetricPoint[] => {+ if (!Number.isFinite(value)) return [];+ const end = Date.now();+ return [+ { timestamp: end - 60_000, value, min: value, max: value },+ { timestamp: end, value, min: value, max: value },+ ];+};++const mergeFallbackHistoryMetrics = (+ metrics: Record<string, AggregatedMetricPoint[] | undefined>,+ fallbackMetrics: Record<string, number | null | undefined> | undefined,+): Record<string, AggregatedMetricPoint[] | undefined> => {+ if (!fallbackMetrics) return metrics;++ let next: Record<string, AggregatedMetricPoint[] | undefined> | null = null;+ for (const [metric, value] of Object.entries(fallbackMetrics)) {+ if (typeof value !== 'number' || !Number.isFinite(value)) continue;+ const existing = metrics[metric] ?? [];+ if (existing.length >= 2) continue;+ next ??= { ...metrics };+ next[metric] = buildFallbackHistoryPoints(value);+ }+ return next ?? metrics;+};+const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps> = (props) => {const [hoverTimestamp, setHoverTimestamp] = createSignal<number | null>(null);const series = createMemo(() =>@@ -421,6 +454,10 @@ export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) =>});const metrics = createMemo(() => historyQuery.value().metrics ?? {});+ const displayMetrics = createMemo(() =>+ mergeFallbackHistoryMetrics(metrics(), props.fallbackMetrics),+ );+ const groups = createMemo(() => props.groups ?? GUEST_DRAWER_HISTORY_GROUPS);const errorText = createMemo(() => (historyQuery.error() ? 'Failed to load history data' : ''));return (@@ -446,13 +483,13 @@ export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) =></div>}>- <div class="grid gap-3 xl:grid-cols-3">- <For each={GUEST_DRAWER_HISTORY_GROUPS}>+ <div class={`grid gap-3 ${groups().length > 3 ? 'xl:grid-cols-4' : 'xl:grid-cols-3'}`}>+ <For each={groups()}>{(group) => (<GuestDrawerHistoryGroupChartgroup={group}loading={historyQuery.loading() && !historyQuery.resolvedOnce()}- metrics={metrics()}+ metrics={displayMetrics()}range={props.range}/>)}diff --git a/frontend-modern/src/components/Workloads/NodeDrawer.test.tsx b/frontend-modern/src/components/Workloads/NodeDrawer.test.tsxnew file mode 100644index 0000000000..f901a9befe--- /dev/null+++ b/frontend-modern/src/components/Workloads/NodeDrawer.test.tsx@@ -0,0 +1,145 @@+import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import type { Node } from '@/types/api';++const chartsApiMocks = vi.hoisted(() => ({+ getMetricsHistory: vi.fn(),+}));++vi.mock('@/api/charts', async () => {+ const actual = await vi.importActual<typeof import('@/api/charts')>('@/api/charts');+ return {+ ...actual,+ ChartsAPI: {+ getMetricsHistory: chartsApiMocks.getMetricsHistory,+ },+ };+});++vi.mock('@/stores/license', () => ({+ isRangeLocked: () => false,+ loadRuntimeCapabilities: vi.fn(),+ maxHistoryDays: () => 90,+}));++import { NodeDrawer } from './NodeDrawer';++const makeHistoryPoints = (base: number) => [+ { timestamp: 1, value: base, min: base, max: base },+ { timestamp: 2, value: base + 5, min: base + 5, max: base + 5 },+ { timestamp: 3, value: base + 10, min: base + 10, max: base + 10 },+];++function makeNode(overrides: Partial<Node> = {}): Node {+ return {+ id: 'agent:pve-node-1',+ name: 'pve-node-1',+ instance: 'homelab',+ host: 'pve-node-1',+ status: 'online',+ type: 'agent',+ cpu: 0.42,+ memory: { total: 8000, used: 3200, free: 4800, usage: 40 },+ disk: { total: 10000, used: 4500, free: 5500, usage: 45 },+ networkIn: 1200,+ networkOut: 800,+ diskRead: 400,+ diskWrite: 300,+ uptime: 3600,+ loadAverage: [0.5],+ kernelVersion: '6.8.0',+ pveVersion: 'pve-manager/9.1.9',+ cpuInfo: { model: 'Ryzen', cores: 8, sockets: 1, mhz: '3200' },+ temperature: {+ cpuPackage: 62.5,+ cpuMax: 65,+ cpuMin: 40,+ cpuMaxRecord: 72,+ available: true,+ hasCPU: true,+ lastUpdate: new Date().toISOString(),+ },+ temperatureMonitoringEnabled: true,+ lastSeen: new Date().toISOString(),+ connectionHealth: 'online',+ isClusterMember: true,+ clusterName: 'homelab',+ linkedAgentId: '',+ ...overrides,+ };+}++beforeEach(() => {+ chartsApiMocks.getMetricsHistory.mockResolvedValue({+ resourceType: 'agent',+ resourceId: 'pve-node-1',+ range: '24h',+ start: 1,+ end: 3,+ metrics: {+ cpu: makeHistoryPoints(10),+ memory: makeHistoryPoints(20),+ disk: makeHistoryPoints(30),+ netin: makeHistoryPoints(1000),+ netout: makeHistoryPoints(2000),+ diskread: makeHistoryPoints(3000),+ diskwrite: makeHistoryPoints(4000),+ },+ source: 'store',+ });+});++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+});++describe('NodeDrawer', () => {+ it('shows a guest-drawer style Proxmox node overview with detailed node context', () => {+ render(() => <NodeDrawer node={makeNode()} />);++ expect(screen.getByText('Overview')).toBeInTheDocument();+ expect(screen.getByText('History')).toBeInTheDocument();+ expect(screen.getByText('System')).toBeInTheDocument();+ expect(screen.getByText('Platform')).toBeInTheDocument();+ expect(screen.getByText('Hardware')).toBeInTheDocument();+ expect(screen.getByText('Telemetry')).toBeInTheDocument();+ expect(screen.getByText('Ryzen')).toBeInTheDocument();+ expect(screen.getByText('6.8.0')).toBeInTheDocument();+ expect(screen.getByText('8')).toBeInTheDocument();+ expect(screen.getByText('PVE 9.1.9')).toBeInTheDocument();+ expect(screen.getByText('65°C')).toBeInTheDocument();+ expect(screen.getByText('Temp monitor')).toBeInTheDocument();+ });++ it('renders node-only thermal history without requiring a table temperature column', async () => {+ render(() => <NodeDrawer node={makeNode()} />);++ await fireEvent.click(screen.getByText('History'));++ await waitFor(() => {+ expect(chartsApiMocks.getMetricsHistory).toHaveBeenCalledWith(+ expect.objectContaining({+ resourceType: 'agent',+ resourceId: 'pve-node-1',+ range: '24h',+ }),+ );+ });++ const charts = screen.getAllByTestId('guest-history-group-chart');+ expect(charts).toHaveLength(4);+ expect(charts.map((chart) => chart.dataset.historyGroup)).toEqual([+ 'utilization',+ 'network',+ 'disk-io',+ 'thermals',+ ]);++ const thermalChart = charts[3];+ expect(within(thermalChart).getByText('Thermals')).toBeInTheDocument();+ expect(thermalChart).toHaveTextContent('65°C');+ expect(screen.getByTestId('guest-history-range-control')).toBeInTheDocument();+ });+});diff --git a/frontend-modern/src/components/Workloads/NodeDrawer.tsx b/frontend-modern/src/components/Workloads/NodeDrawer.tsxnew file mode 100644index 0000000000..88745928a1--- /dev/null+++ b/frontend-modern/src/components/Workloads/NodeDrawer.tsx@@ -0,0 +1,85 @@+import { Show, createMemo, createSignal, type Component } from 'solid-js';++import type { HistoryTimeRange } from '@/api/charts';+import type { Node } from '@/types/api';+import { getNodeDisplayName } from '@/utils/nodes';++import { GuestDrawerHistory, GuestDrawerHistoryRangeSelect } from './GuestDrawerHistory';+import { GUEST_DRAWER_HISTORY_DEFAULT_RANGE } from './guestDrawerModel';+import { NodeDrawerOverview } from './NodeDrawerOverview';+import {+ NODE_DRAWER_HISTORY_GROUPS,+ getNodeDrawerHistoryFallbackMetrics,+ getNodeDrawerHistoryTarget,+} from './nodeDrawerModel';++interface NodeDrawerProps {+ node: Node;+}++type NodeDrawerTab = 'overview' | 'history';++export const NodeDrawer: Component<NodeDrawerProps> = (props) => {+ const [activeTab, setActiveTab] = createSignal<NodeDrawerTab>('overview');+ const [historyRange, setHistoryRange] = createSignal<HistoryTimeRange>(+ GUEST_DRAWER_HISTORY_DEFAULT_RANGE,+ );++ const headingId = () => `node-drawer-heading-${props.node.id}`;+ const displayName = createMemo(() => getNodeDisplayName(props.node));+ const historyTarget = createMemo(() => getNodeDrawerHistoryTarget(props.node));+ const fallbackMetrics = createMemo(() => getNodeDrawerHistoryFallbackMetrics(props.node));++ return (+ <section class="space-y-3" aria-labelledby={headingId()} data-testid="node-drawer">+ <h2 id={headingId()} class="sr-only">+ {displayName()} details+ </h2>++ <div class="mb-1 flex items-center justify-between gap-3 border-b border-border px-1">+ <div class="flex items-center gap-6">+ <button+ onClick={() => setActiveTab('overview')}+ class={`pb-2 text-sm font-medium transition-colors relative ${+ activeTab() === 'overview' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'+ }`}+ >+ Overview+ {activeTab() === 'overview' && (+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />+ )}+ </button>+ <button+ onClick={() => setActiveTab('history')}+ class={`pb-2 text-sm font-medium transition-colors relative ${+ activeTab() === 'history' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'+ }`}+ >+ History+ {activeTab() === 'history' && (+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />+ )}+ </button>+ </div>+ <Show when={activeTab() === 'history'}>+ <div class="pb-1">+ <GuestDrawerHistoryRangeSelect range={historyRange()} onRangeChange={setHistoryRange} />+ </div>+ </Show>+ </div>++ <Show when={activeTab() === 'overview'}>+ <NodeDrawerOverview node={props.node} />+ </Show>++ <Show when={activeTab() === 'history'}>+ <GuestDrawerHistory+ fallbackMetrics={fallbackMetrics()}+ groups={NODE_DRAWER_HISTORY_GROUPS}+ range={historyRange()}+ target={historyTarget()}+ />+ </Show>+ </section>+ );+};diff --git a/frontend-modern/src/components/Workloads/NodeDrawerOverview.tsx b/frontend-modern/src/components/Workloads/NodeDrawerOverview.tsxnew file mode 100644index 0000000000..288771422c--- /dev/null+++ b/frontend-modern/src/components/Workloads/NodeDrawerOverview.tsx@@ -0,0 +1,306 @@+import { For, Show } from 'solid-js';++import type { Node, Temperature } from '@/types/api';+import { formatBytes, formatRelativeTime, formatSpeed, formatUptime } from '@/utils/format';+import { getNodeDisplayName } from '@/utils/nodes';+import { formatTemperature, getCpuTemperature, getTemperatureTextClass } from '@/utils/temperature';++interface NodeDrawerOverviewProps {+ node: Node;+}++interface NodeOverviewRow {+ label: string;+ value: string;+ valueClass?: string;+ title?: string;+}++const NODE_OVERVIEW_CARD_CLASS = 'rounded border border-border bg-surface p-3 shadow-sm';++const cleanText = (value: string | null | undefined): string => {+ const trimmed = (value || '').trim();+ return trimmed && trimmed.toLowerCase() !== 'unknown' ? trimmed : '';+};++const stripAgentPrefix = (value: string): string =>+ value.startsWith('agent:') ? value.slice('agent:'.length) : value;++const getNodeVersionLabel = (node: Node): string => {+ const version = cleanText(node.pveVersion);+ if (!version) return '';+ return (+ version.match(/pve-manager\/([^/\s]+)/i)?.[1] || version.match(/\d+(?:\.\d+)+/)?.[0] || version+ );+};++const formatStatus = (value: string | null | undefined): string => {+ const status = cleanText(value);+ if (!status) return '-';+ return status.charAt(0).toUpperCase() + status.slice(1);+};++const formatPercent = (value: number | null | undefined): string => {+ if (typeof value !== 'number' || !Number.isFinite(value)) return '-';+ const normalized = value <= 1 ? value * 100 : value;+ return `${Math.round(Math.max(0, normalized))}%`;+};++const getUsedPercent = (used?: number | null, total?: number | null): string => {+ if (typeof used !== 'number' || typeof total !== 'number' || total <= 0) return '-';+ return formatPercent((used / total) * 100);+};++const formatLoadAverage = (loadAverage: number[] | undefined): string => {+ const values = (loadAverage || []).filter((value) => Number.isFinite(value));+ if (values.length === 0) return '-';+ return values.map((value) => value.toFixed(2)).join(' / ');+};++const hasPositiveNumber = (value: number | null | undefined): value is number =>+ typeof value === 'number' && Number.isFinite(value) && value > 0;++const formatLastSeen = (value: string | null | undefined): NodeOverviewRow | null => {+ const lastSeen = cleanText(value);+ if (!lastSeen) return null;+ const parsed = new Date(lastSeen);+ return {+ label: 'Last seen',+ value: formatRelativeTime(lastSeen, { compact: true }) || '-',+ title: Number.isNaN(parsed.getTime()) ? lastSeen : parsed.toLocaleString(),+ };+};++const formatTemperatureMonitoring = (value: boolean | null | undefined): string => {+ if (value === true) return 'Enabled';+ if (value === false) return 'Disabled';+ return 'Inherited';+};++const pushTemperature = (+ rows: NodeOverviewRow[],+ label: string,+ value: number | null | undefined,+): void => {+ if (typeof value !== 'number' || !Number.isFinite(value)) return;+ rows.push({+ label,+ value: formatTemperature(value),+ valueClass: getTemperatureTextClass(value),+ });+};++const getThermalRows = (temperature: Temperature | undefined): NodeOverviewRow[] => {+ if (!temperature?.available) return [];++ const rows: NodeOverviewRow[] = [];+ const primary = getCpuTemperature(temperature);++ pushTemperature(rows, 'CPU current', primary);+ pushTemperature(rows, 'CPU package', temperature.cpuPackage);+ pushTemperature(rows, 'CPU low', temperature.cpuMin);+ pushTemperature(rows, 'CPU record', temperature.cpuMaxRecord);++ if (temperature.nvme?.length) {+ rows.push({+ label: 'NVMe',+ value: temperature.nvme+ .slice(0, 2)+ .map((drive) => `${drive.device} ${formatTemperature(drive.temp)}`)+ .join(' / '),+ title: temperature.nvme+ .map((drive) => `${drive.device} ${formatTemperature(drive.temp)}`)+ .join(' / '),+ });+ }++ if (temperature.gpu?.length) {+ const gpuLabels = temperature.gpu+ .map((gpu) => {+ const value = [gpu.edge, gpu.junction, gpu.mem].find(hasPositiveNumber);+ return value ? `${gpu.device} ${formatTemperature(value)}` : '';+ })+ .filter(Boolean);++ if (gpuLabels.length > 0) {+ rows.push({+ label: 'GPU',+ value: gpuLabels.slice(0, 2).join(' / '),+ title: gpuLabels.join(' / '),+ });+ }+ }++ const lastUpdate = formatLastSeen(temperature.lastUpdate);+ if (lastUpdate) rows.push({ ...lastUpdate, label: 'Updated' });++ return rows;+};++const DetailCard = (props: { title: string; rows: NodeOverviewRow[] }) => (+ <Show when={props.rows.length > 0}>+ <div class={NODE_OVERVIEW_CARD_CLASS}>+ <h3 class="mb-2 text-[11px] font-medium uppercase tracking-wide text-base-content">+ {props.title}+ </h3>+ <div class="space-y-1.5 text-[11px]">+ <For each={props.rows}>+ {(row) => (+ <div class="flex items-center justify-between gap-2 min-w-0">+ <span class="shrink-0 text-muted">{row.label}</span>+ <span+ class={`truncate text-right font-medium ${row.valueClass ?? 'text-base-content'}`}+ title={row.title ?? row.value}+ >+ {row.value}+ </span>+ </div>+ )}+ </For>+ </div>+ </div>+ </Show>+);++export function NodeDrawerOverview(props: NodeDrawerOverviewProps) {+ const displayName = () => getNodeDisplayName(props.node);+ const versionLabel = () => getNodeVersionLabel(props.node);+ const linkedAgentId = () => cleanText(props.node.linkedAgentId);+ const clusterLabel = () =>+ cleanText(props.node.clusterName) ||+ (props.node.isClusterMember ? props.node.instance || 'Member' : 'Standalone');+ const clockLabel = () => {+ const clock = cleanText(props.node.cpuInfo?.mhz);+ return clock && clock !== '0' ? clock : '';+ };+ const loadAverageLabel = () => formatLoadAverage(props.node.loadAverage);++ const systemRows = (): NodeOverviewRow[] => [+ { label: 'Name', value: displayName(), title: props.node.name },+ { label: 'Host', value: cleanText(props.node.host) || '-', title: props.node.host },+ { label: 'Status', value: formatStatus(props.node.status) },+ ...(props.node.uptime > 0+ ? [{ label: 'Uptime', value: formatUptime(props.node.uptime) } satisfies NodeOverviewRow]+ : []),+ ...(formatLastSeen(props.node.lastSeen) ? [formatLastSeen(props.node.lastSeen)!] : []),+ ];++ const platformRows = (): NodeOverviewRow[] => [+ ...(versionLabel()+ ? [+ {+ label: 'PVE',+ value: `PVE ${versionLabel()}`,+ title: props.node.pveVersion,+ } satisfies NodeOverviewRow,+ ]+ : []),+ ...(cleanText(props.node.kernelVersion)+ ? [+ {+ label: 'Kernel',+ value: cleanText(props.node.kernelVersion),+ title: props.node.kernelVersion,+ } satisfies NodeOverviewRow,+ ]+ : []),+ {+ label: 'Cluster',+ value: clusterLabel(),+ },+ { label: 'Instance', value: props.node.instance || '-' },+ ];++ const hardwareRows = (): NodeOverviewRow[] => [+ ...(cleanText(props.node.cpuInfo?.model)+ ? [+ {+ label: 'CPU model',+ value: cleanText(props.node.cpuInfo?.model),+ title: props.node.cpuInfo?.model,+ } satisfies NodeOverviewRow,+ ]+ : []),+ ...(hasPositiveNumber(props.node.cpuInfo?.cores)+ ? [{ label: 'Cores', value: `${props.node.cpuInfo.cores}` } satisfies NodeOverviewRow]+ : []),+ ...(hasPositiveNumber(props.node.cpuInfo?.sockets)+ ? [{ label: 'Sockets', value: `${props.node.cpuInfo.sockets}` } satisfies NodeOverviewRow]+ : []),+ ...(clockLabel()+ ? [{ label: 'Clock', value: clockLabel() } satisfies NodeOverviewRow]+ : []),+ ...(loadAverageLabel() !== '-'+ ? [{ label: 'Load avg', value: loadAverageLabel() } satisfies NodeOverviewRow]+ : []),+ ];++ const memoryRows = (): NodeOverviewRow[] => [+ {+ label: 'Usage',+ value: `${getUsedPercent(props.node.memory?.used, props.node.memory?.total)} · ${formatBytes(+ props.node.memory?.used || 0,+ )}`,+ },+ { label: 'Total', value: formatBytes(props.node.memory?.total || 0) },+ { label: 'Free', value: formatBytes(props.node.memory?.free || 0) },+ ...(props.node.memory?.swapTotal+ ? [+ {+ label: 'Swap',+ value: `${formatBytes(props.node.memory.swapUsed || 0)} / ${formatBytes(+ props.node.memory.swapTotal,+ )}`,+ } satisfies NodeOverviewRow,+ ]+ : []),+ ];++ const storageRows = (): NodeOverviewRow[] => [+ {+ label: 'Root usage',+ value: `${formatPercent(props.node.disk?.usage)} · ${formatBytes(props.node.disk?.used || 0)}`,+ },+ { label: 'Root total', value: formatBytes(props.node.disk?.total || 0) },+ { label: 'Root free', value: formatBytes(props.node.disk?.free || 0) },+ {+ label: 'Disk I/O',+ value: `${formatSpeed(props.node.diskRead ?? 0)} / ${formatSpeed(props.node.diskWrite ?? 0)}`,+ },+ ];++ const telemetryRows = (): NodeOverviewRow[] => [+ {+ label: 'Connection',+ value: formatStatus(props.node.connectionHealth || props.node.status),+ },+ {+ label: 'Agent',+ value: linkedAgentId() ? stripAgentPrefix(linkedAgentId()) : 'PVE API only',+ title: linkedAgentId() || undefined,+ },+ {+ label: 'Temp monitor',+ value: formatTemperatureMonitoring(props.node.temperatureMonitoringEnabled),+ },+ ...(typeof props.node.pendingUpdates === 'number'+ ? [{ label: 'Updates', value: `${props.node.pendingUpdates}` } satisfies NodeOverviewRow]+ : []),+ {+ label: 'Network I/O',+ value: `${formatSpeed(props.node.networkIn ?? 0)} / ${formatSpeed(props.node.networkOut ?? 0)}`,+ },+ ];++ return (+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">+ <DetailCard title="System" rows={systemRows()} />+ <DetailCard title="Platform" rows={platformRows()} />+ <DetailCard title="Hardware" rows={hardwareRows()} />+ <DetailCard title="Memory" rows={memoryRows()} />+ <DetailCard title="Storage" rows={storageRows()} />+ <DetailCard title="Telemetry" rows={telemetryRows()} />+ <DetailCard title="Thermals" rows={getThermalRows(props.node.temperature)} />+ </div>+ );+}diff --git a/frontend-modern/src/components/Workloads/WorkloadPanel.tsx b/frontend-modern/src/components/Workloads/WorkloadPanel.tsxindex 243731b58c..b275186e29 100644--- a/frontend-modern/src/components/Workloads/WorkloadPanel.tsx+++ b/frontend-modern/src/components/Workloads/WorkloadPanel.tsx@@ -27,6 +27,7 @@ import {import { GuestDrawer } from './GuestDrawer';import { GuestRow } from './GuestRow';+import { NodeDrawer } from './NodeDrawer';import { buildWorkloadSummaryGroupScope } from './workloadSelectors';import type { WorkloadsState } from './useWorkloadsState';import type { WorkloadTableMetric } from './workloadMetricHistoryModel';@@ -384,6 +385,12 @@ export function WorkloadPanel(props: WorkloadPanelProps) {const isSummaryGroupHighlighted = createMemo(() => props.activeSummaryWorkloadGroupScope()?.id === groupKey(),);+ const shouldShowNodeDrawer = createMemo(+ () =>+ Boolean(node()) &&+ props.focusedSummaryWorkloadGroupId() === groupKey() &&+ props.selectedGuestId() === null,+ );const handleGroupHoverChange = (next: SummarySeriesGroupScope | null) => {props.setHoveredWorkloadGroupScope(next);};@@ -443,6 +450,7 @@ export function WorkloadPanel(props: WorkloadPanelProps) {showFactsInName={!props.workloadTableVisibleColumnIds().includes('info')}trClass="cursor-pointer select-none duration-150"trProps={{+ 'aria-expanded': shouldShowNodeDrawer() ? 'true' : 'false','data-summary-group-id': groupKey(),'data-summary-group-series-count': String(groupSummaryScope()?.seriesIds.length ?? 0,@@ -453,6 +461,21 @@ export function WorkloadPanel(props: WorkloadPanelProps) {}}/></Show>+ <Show when={shouldShowNodeDrawer()}>+ <TableRow data-inline-node-detail-for={groupKey()}>+ <TableCell+ colspan={props.totalColumns()}+ class="p-0 border-b border-border bg-surface-alt"+ >+ <div+ class="px-2 sm:px-4 py-3 sm:py-4"+ onClick={(event) => event.stopPropagation()}+ >+ <NodeDrawer node={node()!} />+ </div>+ </TableCell>+ </TableRow>+ </Show></Show><Index each={groupGuests()} fallback={<></>}>{(guest) => {diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsxindex 19990155ac..1394148209 100644--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx@@ -51,6 +51,9 @@ import guestDrawerSource from '../GuestDrawer.tsx?raw';import guestDrawerHistorySource from '../GuestDrawerHistory.tsx?raw';import guestDrawerOverviewSource from '../GuestDrawerOverview.tsx?raw';import guestDrawerModelSource from '../guestDrawerModel.ts?raw';+import nodeDrawerSource from '../NodeDrawer.tsx?raw';+import nodeDrawerOverviewSource from '../NodeDrawerOverview.tsx?raw';+import nodeDrawerModelSource from '../nodeDrawerModel.ts?raw';import guestRowSource from '../GuestRow.tsx?raw';import guestRowCellsSource from '../GuestRowCells.tsx?raw';import guestDrawerStateSource from '../useGuestDrawerState.ts?raw';@@ -230,6 +233,10 @@ vi.mock('../GuestDrawer', () => ({GuestDrawer: () => <div data-testid="guest-drawer">drawer</div>,}));+vi.mock('../NodeDrawer', () => ({+ NodeDrawer: () => <div data-testid="node-drawer">node drawer</div>,+}));+vi.mock('../GuestRow', () => {const columns = [{ id: 'name', label: 'Name', toggleable: false, sortKey: 'name' },@@ -1056,6 +1063,18 @@ describe('Workloads performance contract', () => {expect(guestDrawerHistorySource).toContain('data-testid="guest-history-hover-time"');expect(guestDrawerHistorySource).toContain('data-testid="guest-history-range-control"');expect(guestDrawerHistorySource).toContain('onPointerMove={handleHoverMove}');+ expect(guestDrawerHistorySource).toContain('fallbackMetrics');+ expect(guestDrawerHistorySource).toContain('props.groups ?? GUEST_DRAWER_HISTORY_GROUPS');+ expect(nodeDrawerSource).toContain('NodeDrawerOverview');+ expect(nodeDrawerSource).toContain('GuestDrawerHistoryRangeSelect');+ expect(nodeDrawerSource).toContain('NODE_DRAWER_HISTORY_GROUPS');+ expect(nodeDrawerOverviewSource).toContain('Hardware');+ expect(nodeDrawerOverviewSource).toContain('Telemetry');+ expect(nodeDrawerOverviewSource).toContain('Thermals');+ expect(nodeDrawerModelSource).toContain("id: 'thermals'");+ expect(nodeDrawerModelSource).toContain("metric: 'temperature'");+ expect(workloadPanelSource).toContain('NodeDrawer');+ expect(workloadPanelSource).toContain('data-inline-node-detail-for');expect(guestDrawerSource).not.toContain('const guestId = () =>');expect(guestDrawerSource).not.toContain('const infrastructureHref = () =>');expect(guestDrawerSource).not.toContain('Filesystems');diff --git a/frontend-modern/src/components/Workloads/guestDrawerModel.ts b/frontend-modern/src/components/Workloads/guestDrawerModel.tsindex 7cdcde0ad2..2a42e3f269 100644--- a/frontend-modern/src/components/Workloads/guestDrawerModel.ts+++ b/frontend-modern/src/components/Workloads/guestDrawerModel.ts@@ -120,6 +120,38 @@ export const getGuestDrawerHistoryScale = (): GuestDrawerHistoryScale => {if (unit === '%') return { minValue: 0, maxValue: 100 };+ if (unit === 'C') {+ let minValue = Infinity;+ let maxValue = -Infinity;+ for (const item of series) {+ for (const point of item.points) {+ const low = typeof point.min === 'number' ? point.min : point.value;+ const high = typeof point.max === 'number' ? point.max : point.value;+ if (Number.isFinite(low) && low < minValue) {+ minValue = low;+ }+ if (Number.isFinite(high) && high > maxValue) {+ maxValue = high;+ }+ }+ }++ if (!Number.isFinite(minValue) || !Number.isFinite(maxValue)) {+ return { minValue: 0, maxValue: 100 };+ }+ if (minValue === maxValue) {+ return {+ minValue: Math.max(0, minValue - 5),+ maxValue: maxValue + 5,+ };+ }+ const padding = Math.max(2, (maxValue - minValue) * 0.15);+ return {+ minValue: Math.max(0, minValue - padding),+ maxValue: maxValue + padding,+ };+ }+let maxValue = 0;for (const item of series) {for (const point of item.points) {diff --git a/frontend-modern/src/components/Workloads/nodeDrawerModel.ts b/frontend-modern/src/components/Workloads/nodeDrawerModel.tsnew file mode 100644index 0000000000..8c653b4669--- /dev/null+++ b/frontend-modern/src/components/Workloads/nodeDrawerModel.ts@@ -0,0 +1,61 @@+import type { ResourceType as HistoryResourceType } from '@/api/charts';+import type { Node } from '@/types/api';+import { getCpuTemperature } from '@/utils/temperature';++import type { GuestDrawerHistoryGroupConfig, GuestDrawerHistoryTarget } from './guestDrawerModel';++export interface NodeDrawerHistoryTarget extends GuestDrawerHistoryTarget {+ resourceType: Extract<HistoryResourceType, 'agent'>;+}++const stripAgentPrefix = (value: string): string =>+ value.startsWith('agent:') ? value.slice('agent:'.length) : value;++export const NODE_DRAWER_HISTORY_GROUPS: GuestDrawerHistoryGroupConfig[] = [+ {+ id: 'utilization',+ label: 'Utilization',+ unit: '%',+ series: [+ { metric: 'cpu', label: 'CPU', unit: '%', color: '#8b5cf6' },+ { metric: 'memory', label: 'Memory', unit: '%', color: '#f59e0b' },+ { metric: 'disk', label: 'Disk', unit: '%', color: '#10b981' },+ ],+ },+ {+ id: 'network',+ label: 'Network I/O',+ unit: 'B/s',+ series: [+ { metric: 'netin', label: 'In', unit: 'B/s', color: '#10b981' },+ { metric: 'netout', label: 'Out', unit: 'B/s', color: '#fb923c' },+ ],+ },+ {+ id: 'disk-io',+ label: 'Disk I/O',+ unit: 'B/s',+ series: [+ { metric: 'diskread', label: 'Read', unit: 'B/s', color: '#3b82f6' },+ { metric: 'diskwrite', label: 'Write', unit: 'B/s', color: '#f59e0b' },+ ],+ },+ {+ id: 'thermals',+ label: 'Thermals',+ unit: 'C',+ series: [{ metric: 'temperature', label: 'CPU', unit: 'C', color: '#ef4444' }],+ },+];++export const getNodeDrawerHistoryTarget = (node: Node): NodeDrawerHistoryTarget | null => {+ const resourceId = stripAgentPrefix((node.linkedAgentId || node.id || node.name || '').trim());+ if (!resourceId) return null;+ return { resourceType: 'agent', resourceId };+};++export const getNodeDrawerHistoryFallbackMetrics = (+ node: Node,+): Record<string, number | undefined> => ({+ temperature: getCpuTemperature(node.temperature) ?? undefined,+});diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex d202837ad0..af8ddc741d 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -9890,6 +9890,59 @@ func TestContract_MetricsHistoryLiveFallbackJSONSnapshot(t *testing.T) {assertJSONSnapshot(t, got, want)}+func TestContract_MetricsHistoryAgentTemperatureLiveFallback(t *testing.T) {+ state := models.NewState()+ state.UpsertHost(models.Host{+ ID: "agent-pve-node-1",+ Hostname: "pve-node-1",+ Status: "online",+ Sensors: models.HostSensorSummary{+ TemperatureCelsius: map[string]float64{+ "cpu_package": 62.5,+ },+ },+ })++ monitor := &monitoring.Monitor{}+ setUnexportedField(t, monitor, "state", state)+ setUnexportedField(t, monitor, "metricsHistory", monitoring.NewMetricsHistory(10, time.Hour))++ router := &Router{monitor: monitor}++ req := httptest.NewRequest(+ http.MethodGet,+ "/api/metrics-store/history?resourceType=agent&resourceId=agent-pve-node-1&metric=temperature&range=5m",+ nil,+ )+ rec := httptest.NewRecorder()+ router.handleMetricsHistory(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("status = %d, body=%s", rec.Code, rec.Body.String())+ }++ var resp metricsHistoryResponse+ if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {+ t.Fatalf("failed to unmarshal response: %v", err)+ }++ if resp.ResourceType != "agent" {+ t.Fatalf("expected resourceType agent, got %q", resp.ResourceType)+ }+ if resp.ResourceId != "agent-pve-node-1" {+ t.Fatalf("expected resource id agent-pve-node-1, got %q", resp.ResourceId)+ }+ if resp.Metric != "temperature" {+ t.Fatalf("expected metric temperature, got %q", resp.Metric)+ }+ if resp.Source != "live" {+ t.Fatalf("expected source live, got %q", resp.Source)+ }+ if len(resp.Points) != 1 || resp.Points[0].Value != 62.5 {+ t.Fatalf("expected one live temperature point 62.5, got %+v", resp.Points)+ }+}+func TestContract_MetricsHistoryCanonicalizesLegacyKubernetesPodIDs(t *testing.T) {mh := monitoring.NewMetricsHistory(1000, time.Hour)now := time.Now().UTC().Truncate(time.Second)diff --git a/internal/api/router.go b/internal/api/router.goindex 98d3b4338c..135fc61be5 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -9011,6 +9011,9 @@ func (r *Router) handleMetricsHistory(w http.ResponseWriter, req *http.Request)points["cpu"] = monitoring.MetricPoint{Timestamp: now, Value: node.CPU}points["memory"] = monitoring.MetricPoint{Timestamp: now, Value: node.Memory.Usage}points["disk"] = monitoring.MetricPoint{Timestamp: now, Value: node.Disk.Usage}+ if temperature := primaryNodeTemperatureCelsius(node.Temperature); temperature != nil {+ points["temperature"] = monitoring.MetricPoint{Timestamp: now, Value: *temperature}+ }case "storage":storage := findStorage(resourceID)if storage == nil {@@ -9047,6 +9050,9 @@ func (r *Router) handleMetricsHistory(w http.ResponseWriter, req *http.Request)diskPercent = host.Disks[0].Usage}points["disk"] = monitoring.MetricPoint{Timestamp: now, Value: diskPercent}+ if temperature := primaryHostSensorTemperatureCelsius(host.Sensors); temperature != nil {+ points["temperature"] = monitoring.MetricPoint{Timestamp: now, Value: *temperature}+ }// Note: We intentionally don't include netin/netout here because the host model// only has cumulative RXBytes/TXBytes (total since boot), not rates.// The RateTracker in ApplyHostReport calculates rates and stores them in metrics history.@@ -9060,6 +9066,9 @@ func (r *Router) handleMetricsHistory(w http.ResponseWriter, req *http.Request)points["cpu"] = monitoring.MetricPoint{Timestamp: now, Value: node.CPU}points["memory"] = monitoring.MetricPoint{Timestamp: now, Value: node.Memory.Usage}points["disk"] = monitoring.MetricPoint{Timestamp: now, Value: node.Disk.Usage}+ if temperature := primaryNodeTemperatureCelsius(node.Temperature); temperature != nil {+ points["temperature"] = monitoring.MetricPoint{Timestamp: now, Value: *temperature}+ }case "app-container":container := findDockerContainer(resourceID)if container == nil {@@ -9575,6 +9584,61 @@ func canonicalizeMetricsHistoryResourceID(runtimeResourceType, resourceID stringreturn trimmed}+func primaryHostSensorTemperatureCelsius(sensors models.HostSensorSummary) *float64 {+ if len(sensors.TemperatureCelsius) == 0 {+ return nil+ }+ if value, ok := sensors.TemperatureCelsius["cpu_package"]; ok && value > 0 {+ return &value+ }++ var best float64+ found := false+ for key, value := range sensors.TemperatureCelsius {+ if value <= 0 || !strings.HasPrefix(strings.ToLower(key), "cpu") {+ continue+ }+ if !found || value > best {+ best = value+ found = true+ }+ }+ if !found {+ return nil+ }+ return &best+}++func primaryNodeTemperatureCelsius(temperature *models.Temperature) *float64 {+ if temperature == nil || !temperature.Available {+ return nil+ }+ if temperature.CPUMax > 0 {+ value := temperature.CPUMax+ return &value+ }+ if temperature.CPUPackage > 0 {+ value := temperature.CPUPackage+ return &value+ }++ var best float64+ found := false+ for _, core := range temperature.Cores {+ if core.Temp <= 0 {+ continue+ }+ if !found || core.Temp > best {+ best = core.Temp+ found = true+ }+ }+ if !found {+ return nil+ }+ return &best+}+func normalizeMetricsHistoryResourceType(input string) (responseType string, runtimeType string, storeTypes []string, err error) {switch strings.ToLower(strings.TrimSpace(input)) {case "node":diff --git a/internal/monitoring/metrics_history.go b/internal/monitoring/metrics_history.goindex dbd3512eda..6352490ab8 100644--- a/internal/monitoring/metrics_history.go+++ b/internal/monitoring/metrics_history.go@@ -14,13 +14,14 @@ type MetricPoint = models.MetricPoint// GuestMetrics holds historical metrics for a single guesttype GuestMetrics struct {- CPU []MetricPoint `json:"cpu"`- Memory []MetricPoint `json:"memory"`- Disk []MetricPoint `json:"disk"`- DiskRead []MetricPoint `json:"diskread"`- DiskWrite []MetricPoint `json:"diskwrite"`- NetworkIn []MetricPoint `json:"netin"`- NetworkOut []MetricPoint `json:"netout"`+ CPU []MetricPoint `json:"cpu"`+ Memory []MetricPoint `json:"memory"`+ Disk []MetricPoint `json:"disk"`+ DiskRead []MetricPoint `json:"diskread"`+ DiskWrite []MetricPoint `json:"diskwrite"`+ NetworkIn []MetricPoint `json:"netin"`+ NetworkOut []MetricPoint `json:"netout"`+ Temperature []MetricPoint `json:"temperature"`}// StorageMetrics holds historical metrics for a single storage@@ -102,6 +103,8 @@ func (mh *MetricsHistory) AddGuestMetric(guestID string, metricType string, valumetrics.NetworkIn = mh.appendMetric(metrics.NetworkIn, point)case "netout":metrics.NetworkOut = mh.appendMetric(metrics.NetworkOut, point)+ case "temperature":+ metrics.Temperature = mh.appendMetric(metrics.Temperature, point)}}@@ -130,6 +133,8 @@ func (mh *MetricsHistory) AddNodeMetric(nodeID string, metricType string, valuemetrics.NetworkIn = mh.appendMetric(metrics.NetworkIn, point)case "netout":metrics.NetworkOut = mh.appendMetric(metrics.NetworkOut, point)+ case "temperature":+ metrics.Temperature = mh.appendMetric(metrics.Temperature, point)}}@@ -194,6 +199,8 @@ func (mh *MetricsHistory) GetGuestMetrics(guestID string, metricType string, durdata = metrics.NetworkIncase "netout":data = metrics.NetworkOut+ case "temperature":+ data = metrics.Temperaturedefault:return []MetricPoint{}}@@ -233,6 +240,8 @@ func (mh *MetricsHistory) GetNodeMetrics(nodeID string, metricType string, duratdata = metrics.NetworkIncase "netout":data = metrics.NetworkOut+ case "temperature":+ data = metrics.Temperaturedefault:return []MetricPoint{}}@@ -299,6 +308,8 @@ func guestMetricSeries(metrics *GuestMetrics, metricType string) []MetricPoint {return metrics.NetworkIncase "netout":return metrics.NetworkOut+ case "temperature":+ return metrics.Temperaturedefault:return nil}@@ -310,7 +321,7 @@ func guestMetricsCoverageSpan(metrics *GuestMetrics, metricTypes []string, cutof}if len(metricTypes) == 0 {- metricTypes = []string{"cpu", "memory", "disk", "diskread", "diskwrite", "netin", "netout"}+ metricTypes = []string{"cpu", "memory", "disk", "diskread", "diskwrite", "netin", "netout", "temperature"}}var best time.Duration@@ -378,6 +389,7 @@ func (mh *MetricsHistory) GetAllGuestMetrics(guestID string, duration time.Duratresult["diskwrite"] = filterMetricsByTime(metrics.DiskWrite, cutoffTime)result["netin"] = filterMetricsByTime(metrics.NetworkIn, cutoffTime)result["netout"] = filterMetricsByTime(metrics.NetworkOut, cutoffTime)+ result["temperature"] = filterMetricsByTime(metrics.Temperature, cutoffTime)return result}@@ -498,11 +510,13 @@ func (mh *MetricsHistory) Cleanup() {metrics.DiskWrite = mh.cleanupMetrics(metrics.DiskWrite, cutoffTime)metrics.NetworkIn = mh.cleanupMetrics(metrics.NetworkIn, cutoffTime)metrics.NetworkOut = mh.cleanupMetrics(metrics.NetworkOut, cutoffTime)+ metrics.Temperature = mh.cleanupMetrics(metrics.Temperature, cutoffTime)// If all slices are empty, remove the map entry entirely to free memoryif len(metrics.CPU) == 0 && len(metrics.Memory) == 0 && len(metrics.Disk) == 0 &&len(metrics.DiskRead) == 0 && len(metrics.DiskWrite) == 0 &&- len(metrics.NetworkIn) == 0 && len(metrics.NetworkOut) == 0 {+ len(metrics.NetworkIn) == 0 && len(metrics.NetworkOut) == 0 &&+ len(metrics.Temperature) == 0 {delete(mh.guestMetrics, key)guestsRemoved++}@@ -513,8 +527,13 @@ func (mh *MetricsHistory) Cleanup() {metrics.CPU = mh.cleanupMetrics(metrics.CPU, cutoffTime)metrics.Memory = mh.cleanupMetrics(metrics.Memory, cutoffTime)metrics.Disk = mh.cleanupMetrics(metrics.Disk, cutoffTime)+ metrics.NetworkIn = mh.cleanupMetrics(metrics.NetworkIn, cutoffTime)+ metrics.NetworkOut = mh.cleanupMetrics(metrics.NetworkOut, cutoffTime)+ metrics.Temperature = mh.cleanupMetrics(metrics.Temperature, cutoffTime)- if len(metrics.CPU) == 0 && len(metrics.Memory) == 0 && len(metrics.Disk) == 0 {+ if len(metrics.CPU) == 0 && len(metrics.Memory) == 0 && len(metrics.Disk) == 0 &&+ len(metrics.NetworkIn) == 0 && len(metrics.NetworkOut) == 0 &&+ len(metrics.Temperature) == 0 {delete(mh.nodeMetrics, key)nodesRemoved++}diff --git a/internal/monitoring/metrics_history_test.go b/internal/monitoring/metrics_history_test.goindex d591cdc202..8823777426 100644--- a/internal/monitoring/metrics_history_test.go+++ b/internal/monitoring/metrics_history_test.go@@ -170,6 +170,33 @@ func TestAppendMetric(t *testing.T) {}}+func TestMetricsHistoryStoresGuestAndNodeTemperature(t *testing.T) {+ mh := NewMetricsHistory(10, time.Hour)+ now := time.Now()++ mh.AddGuestMetric("agent:host-1", "temperature", 62.5, now.Add(-time.Minute))+ mh.AddNodeMetric("node-1", "temperature", 58.25, now)++ guestPoints := mh.GetGuestMetrics("agent:host-1", "temperature", time.Hour)+ if len(guestPoints) != 1 || guestPoints[0].Value != 62.5 {+ t.Fatalf("expected guest temperature 62.5, got %+v", guestPoints)+ }++ nodePoints := mh.GetNodeMetrics("node-1", "temperature", time.Hour)+ if len(nodePoints) != 1 || nodePoints[0].Value != 58.25 {+ t.Fatalf("expected node temperature 58.25, got %+v", nodePoints)+ }++ allGuestMetrics := mh.GetAllGuestMetrics("agent:host-1", time.Hour)+ if len(allGuestMetrics["temperature"]) != 1 || allGuestMetrics["temperature"][0].Value != 62.5 {+ t.Fatalf("expected all guest metrics to include temperature, got %+v", allGuestMetrics)+ }++ if span := mh.GuestMetricCoverageSpan("agent:host-1", []string{"temperature"}, time.Hour); span != 0 {+ t.Fatalf("single-point guest temperature coverage span = %s, want 0", span)+ }+}+func TestCleanupMetrics(t *testing.T) {now := time.Now()diff --git a/internal/monitoring/mock_metrics_history.go b/internal/monitoring/mock_metrics_history.goindex 9978262b5a..67b95daae7 100644--- a/internal/monitoring/mock_metrics_history.go+++ b/internal/monitoring/mock_metrics_history.go@@ -1282,11 +1282,17 @@ func recordMockStateToMetricsHistory(mh *MetricsHistory, ms *metrics.Store, grapmh.AddNodeMetric(node.ID, "cpu", cpu, ts)mh.AddNodeMetric(node.ID, "memory", memory, ts)mh.AddNodeMetric(node.ID, "disk", disk, ts)+ if temperature := nodePrimaryTemperatureCelsius(node.Temperature); temperature != nil {+ mh.AddNodeMetric(node.ID, "temperature", *temperature, ts)+ }if ms != nil {ms.Write("node", node.ID, "cpu", cpu, ts)ms.Write("node", node.ID, "memory", memory, ts)ms.Write("node", node.ID, "disk", disk, ts)+ if temperature := nodePrimaryTemperatureCelsius(node.Temperature); temperature != nil {+ ms.Write("node", node.ID, "temperature", *temperature, ts)+ }}}@@ -1474,6 +1480,7 @@ func recordMockStateToMetricsHistory(mh *MetricsHistory, ms *metrics.Store, grapdiskwrite := mock.SampleMetric("agent", host.ID, "diskwrite", ts)netin := mock.SampleMetric("agent", host.ID, "netin", ts)netout := mock.SampleMetric("agent", host.ID, "netout", ts)+ temperature := hostPrimaryTemperatureCelsius(host.Sensors)mh.AddGuestMetric(hostKey, "cpu", cpu, ts)mh.AddGuestMetric(hostKey, "memory", memory, ts)mh.AddGuestMetric(hostKey, "disk", disk, ts)@@ -1481,6 +1488,9 @@ func recordMockStateToMetricsHistory(mh *MetricsHistory, ms *metrics.Store, grapmh.AddGuestMetric(hostKey, "diskwrite", diskwrite, ts)mh.AddGuestMetric(hostKey, "netin", netin, ts)mh.AddGuestMetric(hostKey, "netout", netout, ts)+ if temperature != nil {+ mh.AddGuestMetric(hostKey, "temperature", *temperature, ts)+ }if ms != nil {ms.Write("agent", host.ID, "cpu", cpu, ts)@@ -1490,6 +1500,9 @@ func recordMockStateToMetricsHistory(mh *MetricsHistory, ms *metrics.Store, grapms.Write("agent", host.ID, "diskwrite", diskwrite, ts)ms.Write("agent", host.ID, "netin", netin, ts)ms.Write("agent", host.ID, "netout", netout, ts)+ if temperature != nil {+ ms.Write("agent", host.ID, "temperature", *temperature, ts)+ }}}diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.goindex 7b307f6e66..84729e23d0 100644--- a/internal/monitoring/monitor_agents.go+++ b/internal/monitoring/monitor_agents.go@@ -2022,12 +2022,16 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.if len(host.Disks) > 0 {hostDiskPercent = host.Disks[0].Usage}+ hostTemperature := hostPrimaryTemperatureCelsius(host.Sensors)if !shouldSkipNativeMockStateMetricWrites() {if m.metricsHistory != nil {m.metricsHistory.AddGuestMetric(hostMetricKey, "cpu", host.CPUUsage, now)m.metricsHistory.AddGuestMetric(hostMetricKey, "memory", host.Memory.Usage, now)m.metricsHistory.AddGuestMetric(hostMetricKey, "disk", hostDiskPercent, now)+ if hostTemperature != nil {+ m.metricsHistory.AddGuestMetric(hostMetricKey, "temperature", *hostTemperature, now)+ }if netInRate >= 0 {m.metricsHistory.AddGuestMetric(hostMetricKey, "netin", netInRate, now)@@ -2049,6 +2053,9 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.m.metricsStore.Write("agent", host.ID, "cpu", host.CPUUsage, now)m.metricsStore.Write("agent", host.ID, "memory", host.Memory.Usage, now)m.metricsStore.Write("agent", host.ID, "disk", hostDiskPercent, now)+ if hostTemperature != nil {+ m.metricsStore.Write("agent", host.ID, "temperature", *hostTemperature, now)+ }m.writeHostSMARTMetrics(host, now)if netInRate >= 0 {m.metricsStore.Write("agent", host.ID, "netin", netInRate, now)@@ -2072,6 +2079,61 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.return host, nil}+func hostPrimaryTemperatureCelsius(sensors models.HostSensorSummary) *float64 {+ if len(sensors.TemperatureCelsius) == 0 {+ return nil+ }+ if value, ok := sensors.TemperatureCelsius["cpu_package"]; ok && value > 0 {+ return &value+ }++ var best float64+ found := false+ for key, value := range sensors.TemperatureCelsius {+ if value <= 0 || !strings.HasPrefix(strings.ToLower(key), "cpu") {+ continue+ }+ if !found || value > best {+ best = value+ found = true+ }+ }+ if !found {+ return nil+ }+ return &best+}++func nodePrimaryTemperatureCelsius(temperature *models.Temperature) *float64 {+ if temperature == nil || !temperature.Available {+ return nil+ }+ if temperature.CPUMax > 0 {+ value := temperature.CPUMax+ return &value+ }+ if temperature.CPUPackage > 0 {+ value := temperature.CPUPackage+ return &value+ }++ var best float64+ found := false+ for _, core := range temperature.Cores {+ if core.Temp <= 0 {+ continue+ }+ if !found || core.Temp > best {+ best = core.Temp+ found = true+ }+ }+ if !found {+ return nil+ }+ return &best+}+func (m *Monitor) writeHostSMARTMetrics(host models.Host, now time.Time) {if shouldSkipNativeMockStateMetricWrites() || m.metricsStore == nil {returndiff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.goindex 9614db66d3..7999b142a6 100644--- a/internal/monitoring/monitor_host_agents_test.go+++ b/internal/monitoring/monitor_host_agents_test.go@@ -1236,6 +1236,69 @@ func TestApplyHostReportPersistsSMARTMetricsForAgentDisks(t *testing.T) {}}+func TestApplyHostReportPersistsAgentTemperatureMetric(t *testing.T) {+ t.Helper()++ storeCfg := metrics.DefaultConfig(t.TempDir())+ storeCfg.WriteBufferSize = 1+ store, err := metrics.NewStore(storeCfg)+ if err != nil {+ t.Fatalf("NewStore: %v", err)+ }+ defer store.Close()++ monitor := &Monitor{+ state: models.NewState(),+ alertManager: alerts.NewManager(),+ hostTokenBindings: make(map[string]string),+ config: &config.Config{},+ rateTracker: NewRateTracker(),+ metricsHistory: NewMetricsHistory(10, time.Hour),+ metricsStore: store,+ }+ t.Cleanup(func() { monitor.alertManager.Stop() })++ report := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-thermal",+ Version: "1.0.0",+ IntervalSeconds: 30,+ },+ Host: agentshost.HostInfo{+ ID: "machine-thermal",+ Hostname: "thermal-node",+ MachineID: "machine-thermal",+ },+ Metrics: agentshost.Metrics{+ CPUUsagePercent: 12.5,+ Memory: agentshost.MemoryMetric{TotalBytes: 1024, UsedBytes: 512, FreeBytes: 512, Usage: 50},+ },+ Sensors: agentshost.Sensors{+ TemperatureCelsius: map[string]float64{+ "cpu_core_0": 59,+ "cpu_package": 62.5,+ },+ },+ Timestamp: time.Now().UTC(),+ }++ host, err := monitor.ApplyHostReport(report, nil)+ if err != nil {+ t.Fatalf("ApplyHostReport: %v", err)+ }+ store.Flush()++ storePoints := waitForStoredMetric(t, store, "agent", host.ID, "temperature")+ if got := storePoints[len(storePoints)-1].Value; got != 62.5 {+ t.Fatalf("expected persisted temperature 62.5, got %f", got)+ }++ historyPoints := monitor.GetGuestMetrics("agent:"+host.ID, time.Hour)["temperature"]+ if len(historyPoints) == 0 || historyPoints[len(historyPoints)-1].Value != 62.5 {+ t.Fatalf("expected in-memory temperature 62.5, got %+v", historyPoints)+ }+}+func TestApplyHostReportPersistsSMARTMetricsForAgentDisksWithFallbackID(t *testing.T) {t.Helper()@@ -1481,10 +1544,16 @@ func TestApplyHostReportSkipsMetricsAndSMARTWritesInMockMode(t *testing.T) {func waitForStoredDiskMetric(t *testing.T, store *metrics.Store, resourceID, metric string) []metrics.MetricPoint {t.Helper()+ return waitForStoredMetric(t, store, "disk", resourceID, metric)+}++func waitForStoredMetric(t *testing.T, store *metrics.Store, resourceType, resourceID, metric string) []metrics.MetricPoint {+ t.Helper()+deadline := time.Now().Add(2 * time.Second)for {now := time.Now().UTC()- points, err := store.Query("disk", resourceID, metric, now.Add(-time.Hour), now.Add(time.Hour), 60)+ points, err := store.Query(resourceType, resourceID, metric, now.Add(-time.Hour), now.Add(time.Hour), 60)if err != nil {t.Fatalf("Query %s: %v", metric, err)}