Show linked-agent power in Proxmox node hardware details

Use the existing sensor wattage formatter for #3799's missing package, core and DRAM readings. Preserve measured zero and snapshot withdrawal, and carry the linked agent reporting lease so retained watts say last known even while the PVE API is healthy. No additional resource lookup or collector change is needed.

Contract-Neutral: Repairs presentation of existing power readings and projects existing agent freshness into the client-only node view; no wire payload, API, auth, collection, stored state, TLS or subsystem contract changes.
Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-11-03 00:54:25 +00:00
parent c457504328
commit f5942b881b
5 changed files with 26 additions and 16 deletions

View File

@@ -385,6 +385,16 @@ const formatPowerWatts = (value: number) => {
return `${value.toFixed(1)} W`;
};
export const buildPowerRows = (power?: HostSensorSummary['powerWatts']) =>
Object.entries(power ?? {})
.map(([name, value]) => [name, formatPowerWatts(value)] as const)
.filter(([, value]) => value)
.sort(([a], [b]) => a.localeCompare(b))
.map(([name, value]) => {
const label = formatPowerSensorLabel(name);
return { label, value, valueTitle: `${label} ${value}` };
});
const formatFanRPM = (value: number) => {
if (!Number.isFinite(value)) return '';
return `${Math.round(Math.max(0, value)).toLocaleString()} RPM`;
@@ -502,21 +512,7 @@ export const buildTemperatureRows = (
});
}
const power = sensors?.powerWatts;
if (power) {
Object.entries(power)
.map(([name, value]) => [name, formatPowerWatts(value)] as const)
.filter(([, value]) => value)
.sort(([a], [b]) => a.localeCompare(b))
.forEach(([name, value]) => {
const label = formatPowerSensorLabel(name);
rows.push({
label,
value,
valueTitle: `${label} ${value}`,
});
});
}
rows.push(...buildPowerRows(sensors?.powerWatts));
// This card has no other cue that a value is not current, so a retained
// sensor reading says so in its value, as a retained disk reading does.

View File

@@ -268,7 +268,7 @@ describe('NodeDrawer', () => {
expect(details).not.toHaveAttribute('open');
expect(within(details).getByText('12.9 W')).not.toBeVisible();
fireEvent.click(within(details).getByText('Details'));
const hardware = within(details).getByText('Hardware').closest('tr')!;
const hardware = within(details).getByText('Hardware').closest('tbody')!;
expect(hardware).toHaveTextContent('CPU Core Power6.2 W');
expect(hardware).toHaveTextContent('CPU Package Power12.9 W');
expect(hardware).toHaveTextContent('DRAM Power1.7 W');

View File

@@ -22,6 +22,10 @@ import {
type DetailValueTone,
} from '@/components/shared/DetailSectionTable';
import type { Alert, Disk, HostGPUSensor, Node, Temperature } from '@/types/api';
import {
buildPowerRows,
HOST_AGENT_STOPPED_REPORTING_REASON,
} from '@/components/Infrastructure/resourceDetailMappers';
import { alertTypeDisplayLabel } from '@/features/alerts/helpers';
import { getAlertAttentionCopy } from '@/features/alerts/metricAlertPresentation';
import { formatBytes, formatRelativeTime, normalizeDiskArray } from '@/utils/format';
@@ -287,6 +291,13 @@ export function NodeDrawerOverview(props: NodeDrawerOverviewProps) {
...(loadAverageLabel() !== '-'
? [{ label: 'Load avg', value: loadAverageLabel() } satisfies NodeOverviewRow]
: []),
...buildPowerRows(props.node.sensors?.powerWatts).map((row) => ({
label: row.label,
value: props.node.sensorsStale ? `${row.value} (last known)` : row.value,
title: props.node.sensorsStale
? `Last known reading, not current: ${HOST_AGENT_STOPPED_REPORTING_REASON}`
: row.valueTitle,
})),
];
const memoryRows = (): NodeOverviewRow[] => [

View File

@@ -183,6 +183,8 @@ export interface Node {
cpuInfo: CPUInfo;
/** Typed telemetry from a linked Unified Agent, when this PVE node is hybrid. */
sensors?: HostSensorSummary;
/** Client-only projection of the linked agent's reporting lease, not PVE API health. */
sensorsStale?: boolean;
temperature?: Temperature; // CPU/NVMe temperatures
/**
* The node's primary CPU temperature in Celsius, chosen by the backend

View File

@@ -1467,6 +1467,7 @@ export const nodeFromResource = (resource: Resource): Node | null => {
mhz: asString(cpuInfo?.mhz) || '0',
},
sensors: agentFacet?.sensors,
sensorsStale: agentFacet?.stale === true,
temperature: buildTemperature(resource, proxmox),
// The backend's primary CPU reading: the agent's when one is linked, the
// same source the node's history line reads.