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.

Preserve richer agent telemetry in Machines table

rcourtman1307d681bfb0
diff --git a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
index ea05e637ab..7d94651859 100644
--- a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
+++ b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
@@ -1,8 +1,8 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
+import { EnhancedCPUBar } from '@/components/Workloads/EnhancedCPUBar';
import { StackedDiskBar } from '@/components/Workloads/StackedDiskBar';
import { StackedMemoryBar } from '@/components/Workloads/StackedMemoryBar';
import { ColumnPicker } from '@/components/shared/ColumnPicker';
-import { ResponsiveMetricCell } from '@/components/shared/responsive';
import { StatusDot } from '@/components/shared/StatusDot';
import {
Table,
@@ -136,6 +136,23 @@ const memoryPercentOnlyFor = (machine: Resource): number | undefined => {
return finiteMetric(machine.memory?.current) ?? finiteMetric(machine.agent?.memory?.usage);
};
+const memoryBalloonFor = (machine: Resource): number | undefined =>
+ finiteMetric(machine.agent?.memory?.balloon);
+
+const memorySwapUsedFor = (machine: Resource): number | undefined =>
+ finiteMetric(machine.agent?.memory?.swapUsed);
+
+const memorySwapTotalFor = (machine: Resource): number | undefined =>
+ finiteMetric(machine.agent?.memory?.swapTotal);
+
+const cpuCoresFor = (machine: Resource): number | undefined => {
+ const cores = finiteMetric(machine.agent?.cpuCount);
+ return cores && cores > 0 ? cores : undefined;
+};
+
+const cpuLoadAverageFor = (machine: Resource): number | undefined =>
+ finiteMetric(machine.agent?.loadAverage?.[0]);
+
const aggregateDiskFor = (machine: Resource): Disk | undefined => {
if (!machine.disk) return undefined;
const total = finiteMetric(machine.disk.total) ?? 0;
@@ -393,8 +410,13 @@ export const AgentsMachinesTable: Component<{
const canRenderMetrics = () => indicator().variant !== 'danger';
const metricsKey = () => buildMetricKeyForUnifiedResource(machine);
const cpuPercent = () => getAgentMachineCpuPercent(machine);
+ const cpuCores = () => cpuCoresFor(machine);
+ const cpuLoadAverage = () => cpuLoadAverageFor(machine);
const memoryUsed = () => memoryUsedFor(machine);
const memoryTotal = () => memoryTotalFor(machine);
+ const memoryBalloon = () => memoryBalloonFor(machine);
+ const memorySwapUsed = () => memorySwapUsedFor(machine);
+ const memorySwapTotal = () => memorySwapTotalFor(machine);
const memoryPercentOnly = () => memoryPercentOnlyFor(machine);
const hasMemoryMetric = () =>
memoryTotal() > 0 || memoryPercentOnly() !== undefined;
@@ -465,14 +487,17 @@ export const AgentsMachinesTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('metric-bar')} ${machineColumnWidthClass('cpu')}`}
>
- <ResponsiveMetricCell
- class="w-full"
- value={cpuPercent() ?? 0}
- type="cpu"
- resourceId={metricsKey()}
- isRunning={canRenderMetrics() && cpuPercent() !== undefined}
- showMobile={false}
- />
+ <Show
+ when={canRenderMetrics() && cpuPercent() !== undefined}
+ fallback={metricFallback()}
+ >
+ <EnhancedCPUBar
+ usage={cpuPercent() ?? 0}
+ loadAverage={cpuLoadAverage()}
+ cores={cpuCores()}
+ resourceId={metricsKey()}
+ />
+ </Show>
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('metric-bar')} ${machineColumnWidthClass('memory')}`}
@@ -485,6 +510,10 @@ export const AgentsMachinesTable: Component<{
used={memoryUsed()}
total={memoryTotal()}
percentOnly={memoryPercentOnly()}
+ balloon={memoryBalloon()}
+ swapUsed={memorySwapUsed()}
+ swapTotal={memorySwapTotal()}
+ resourceId={metricsKey()}
/>
</Show>
</TableCell>
diff --git a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
index 9fc4bd26e0..ee4010c6ba 100644
--- a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
+++ b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
@@ -7,6 +7,46 @@ vi.mock('@/components/Infrastructure/ResourceDetailDrawer', () => ({
ResourceDetailDrawer: () => <div data-testid="resource-detail-drawer" />,
}));
+vi.mock('@/components/Workloads/EnhancedCPUBar', () => ({
+ EnhancedCPUBar: (props: {
+ usage: number;
+ loadAverage?: number;
+ cores?: number;
+ resourceId?: string;
+ }) => (
+ <div
+ data-testid="agent-machine-cpu-bar"
+ data-usage={props.usage}
+ data-load-average={props.loadAverage}
+ data-cores={props.cores}
+ data-resource-id={props.resourceId}
+ />
+ ),
+}));
+
+vi.mock('@/components/Workloads/StackedMemoryBar', () => ({
+ StackedMemoryBar: (props: {
+ used: number;
+ total: number;
+ percentOnly?: number;
+ balloon?: number;
+ swapUsed?: number;
+ swapTotal?: number;
+ resourceId?: string;
+ }) => (
+ <div
+ data-testid="agent-machine-memory-bar"
+ data-used={props.used}
+ data-total={props.total}
+ data-percent-only={props.percentOnly}
+ data-balloon={props.balloon}
+ data-swap-used={props.swapUsed}
+ data-swap-total={props.swapTotal}
+ data-resource-id={props.resourceId}
+ />
+ ),
+}));
+
const resource = (overrides: Partial<Resource>): Resource =>
({
id: overrides.id ?? 'machine-1',
@@ -154,4 +194,50 @@ describe('AgentsMachinesTable', () => {
expect(screen.getByText('arm64')).toBeInTheDocument();
});
+
+ it('preserves agent CPU load and memory swap details in row metrics', () => {
+ render(() => (
+ <AgentsMachinesTable
+ resources={[
+ resource({
+ id: 'workstation',
+ name: 'Workstation',
+ cpu: { current: 48 },
+ memory: { current: 61 },
+ agent: {
+ cpuCount: 12,
+ loadAverage: [2.45, 2.1, 1.9],
+ memory: {
+ used: 6_000,
+ total: 12_000,
+ free: 6_000,
+ usage: 50,
+ balloon: 8_000,
+ swapUsed: 1_024,
+ swapTotal: 2_048,
+ },
+ },
+ }),
+ ]}
+ emptyIcon={emptyIcon}
+ emptyTitle="No machines"
+ emptyDescription="Install Pulse Agent."
+ />
+ ));
+
+ expect(screen.getByTestId('agent-machine-cpu-bar')).toHaveAttribute(
+ 'data-load-average',
+ '2.45',
+ );
+ expect(screen.getByTestId('agent-machine-cpu-bar')).toHaveAttribute('data-cores', '12');
+ expect(screen.getByTestId('agent-machine-memory-bar')).toHaveAttribute(
+ 'data-swap-used',
+ '1024',
+ );
+ expect(screen.getByTestId('agent-machine-memory-bar')).toHaveAttribute(
+ 'data-swap-total',
+ '2048',
+ );
+ expect(screen.getByTestId('agent-machine-memory-bar')).toHaveAttribute('data-balloon', '8000');
+ });
});
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index 533bb94cc3..970483b159 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -531,6 +531,7 @@ export interface ResourceAgentMeta {
architecture?: string;
uptimeSeconds?: number;
cpuCount?: number;
+ loadAverage?: number[];
memory?: Partial<Memory>;
networkInterfaces?: HostNetworkInterface[];
disks?: ResourceAgentDisk[];