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
import { useRelativeTimeNow } from '@/utils/relativeTimeClock';
import {
For,
Show,
createMemo,
createSignal,
type Accessor,
type Component,
type JSX,
} from 'solid-js';
import { useWebSocket } from '@/contexts/appRuntime';
import { useAlertsActivation } from '@/stores/alertsActivation';
import { getAlertsForResource, getUnifiedResourceAlertStyles } from '@/utils/alerts';
import { StatusDot } from '@/components/shared/StatusDot';
import { ResourceNameWithWebInterfaceLink } from '@/components/shared/WebInterfaceLink';
import { InlineDetailTableRow } from '@/components/shared/InlineDetailTableRow';
import { ResponsiveMetricCell } from '@/components/shared/responsive';
import { NodeDrawer } from '@/components/Workloads/NodeDrawer';
import { StackedMemoryBar } from '@/components/Workloads/StackedMemoryBar';
import { StackedDiskBar } from '@/components/Workloads/StackedDiskBar';
import { MetricMiniSparkline } from '@/components/Workloads/MetricMiniSparkline';
import { TemperatureGauge } from '@/components/shared/TemperatureGauge';
import { hostOverrideIdCandidates } from '@/features/alerts/alertOverridesModel';
import { getMetricAlertPresentation } from '@/features/alerts/metricAlertPresentation';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import { TableCell, TableRow } from '@/components/shared/Table';
import { getSimpleStatusIndicator } from '@/utils/status';
import { getNodeExternalUrl } from '@/utils/nodes';
import { asTrimmedString } from '@/utils/stringUtils';
import { normalizeDiskArray } from '@/utils/format';
import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';
import { useWorkloadTableMetricHistory } from '@/components/Workloads/useWorkloadTableMetricHistory';
import { getWorkloadTableLayoutMode } from '@/components/Workloads/guestRowModel';
import {
PlatformSortableTableHead,
PlatformTableEmptyState,
PlatformTableMetricFallback,
PlatformTablePreviewFooter,
PlatformTableShell,
PlatformWindowedRows,
createPlatformTablePreview,
createPlatformTableSortState,
formatPlatformTableIntegerValue,
formatPlatformTablePercentValue,
formatPlatformTableUptimeValue,
getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
type PlatformTableSortValue,
} from '@/features/platformPage/sharedPlatformPage';
import {
getPlatformResourceDetailRowInteractionProps,
PlatformResourceDetailToggleButton,
} from '@/features/platformPage/PlatformResourceDetailTableRow';
import { PlatformHostScopeNameButton } from '@/features/platformPage/PlatformHostScope';
import { type ProxmoxEstateTopology } from '@/features/platformPage/platformEstateOverviewModel';
import { type WorkloadsMetricDisplayMode } from '@/components/Workloads/workloadsFilterModel';
import { type WorkloadTableMetricHistoryRange } from '@/components/Workloads/workloadMetricHistoryModel';
import type { Disk, Node as LegacyNode } from '@/types/api';
import type { Resource } from '@/types/resource';
import { hasCurrentProxmoxUpdateEvidence } from '@/utils/proxmoxUpdateEvidence';
import { nodeFromResource } from '@/utils/resourceStateAdapters';
import {
getResourceClusterLabel,
filterProxmoxNodes,
getResourceVersion,
isProxmoxChildOfNode,
} from './proxmoxPageModel';
import {
getProxmoxHostColumnWidthStyle,
getProxmoxHostTableLayoutModeForContainer,
getProxmoxHostTableMinWidthClass,
getProxmoxHostVisibleColumnsForLayout,
type ProxmoxHostTableColumn,
type ProxmoxHostTableColumnId,
} from './proxmoxHostTableModel';
// Proxmox Overview mirrors the v5 Dashboard layout: a dedicated nodes table on
// top, the canonical Workloads filter + guest table below. The nodes table
// uses the canonical metric primitives (ResponsiveMetricCell / StackedMemoryBar
// / StackedDiskBar / TemperatureGauge) so the bars, severity coloring, and
// sparkline overlays match the rest of the platform-first surfaces. v5's
// NodeSummaryTable didn't have a search box or status chip strip — node lists
// are short and the Workloads filter below covers the place where filtering
// actually matters, so this table renders the rows directly. The bars /
// sparklines toggle in the workloads filter is shared by the page-level
// metricDisplayMode signal so the hosts table swaps to MetricMiniSparkline
// whenever the user flips the toggle.
const formatNodeUptime = (
seconds: number | undefined,
compact = false,
): { label: string; warn: boolean } => {
if (!seconds || seconds <= 0) return { label: '—', warn: false };
// Full "26d 4h" precision matches v5 and the guest rows below; <1h keeps
// the v5 "recently restarted" highlight.
return {
label: formatPlatformTableUptimeValue(seconds, { compact }),
warn: seconds < 3_600,
};
};
type GuestCounts = { vms: number; containers: number };
const countGuestsForNode = (guests: Resource[], node: Resource): GuestCounts => {
const counts: GuestCounts = { vms: 0, containers: 0 };
for (const guest of guests) {
if (!isProxmoxChildOfNode(guest, node)) continue;
if (guest.type === 'vm') counts.vms += 1;
else if (guest.type === 'system-container' || guest.type === 'oci-container') {
counts.containers += 1;
}
}
return counts;
};
const VMS_BADGE =
'inline-flex min-w-8 justify-center items-center rounded-md bg-sky-100 px-1.5 py-0.5 text-[11px] font-semibold tabular-nums text-sky-700 dark:bg-sky-900/40 dark:text-sky-300';
const CTS_BADGE =
'inline-flex min-w-8 justify-center items-center rounded-md bg-violet-100 px-1.5 py-0.5 text-[11px] font-semibold tabular-nums text-violet-700 dark:bg-violet-900/40 dark:text-violet-300';
const ZERO_BADGE =
'inline-flex min-w-8 justify-center items-center rounded-md bg-surface-alt px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-muted';
// Shim a canonical Resource into the legacy Node shape that
// `useWorkloadTableMetricHistory.getNodeMetricSeries` uses for its chart-key
// candidate lookups. The lookup only reads `id`, `linkedAgentId`, `name`, and
// `instance`, so a minimal projection is enough; everything else is left at
// its harmless default. Field-cast through a Partial → unknown → LegacyNode
// chain because the legacy Node type carries dozens of optional shape fields
// the table doesn't need to satisfy here.
const projectResourceToLegacyNode = (resource: Resource): LegacyNode => {
const proxmoxMeta = resource.proxmox ?? {};
const projected: Partial<LegacyNode> & {
id: string;
name: string;
instance: string;
linkedAgentId?: string;
} = {
id: resource.id,
name: resource.name,
instance: proxmoxMeta.instance ?? '',
linkedAgentId: resource.agent?.agentId ?? undefined,
};
return projected as unknown as LegacyNode;
};
// Every host column carries a scalar to order on, so the sortable-key list is
// the full column-id list. Metric and count columns read "biggest on top", so
// their first click sorts descending; the identity/context text columns start
// ascending.
const PROXMOX_HOST_SORT_KEYS = [
'node',
'version',
'uptime',
'cpu',
'memory',
'disk',
'temp',
'vms',
'cts',
'cluster',
] as const satisfies readonly ProxmoxHostTableColumnId[];
type HostSortKey = (typeof PROXMOX_HOST_SORT_KEYS)[number];
const getHostSortValue = (
node: Resource,
guests: Resource[],
key: HostSortKey,
): PlatformTableSortValue => {
switch (key) {
case 'node':
return asTrimmedString(node.name) || node.id;
case 'version':
return asTrimmedString(getResourceVersion(node)) || null;
case 'cluster':
return getResourceClusterLabel(node);
case 'cpu':
return node.cpu?.current ?? null;
case 'memory': {
const total = node.memory?.total ?? 0;
if (total > 0) return ((node.memory?.used ?? 0) / total) * 100;
return typeof node.memory?.current === 'number' ? node.memory.current : null;
}
case 'disk':
return node.disk?.current ?? null;
case 'temp':
return typeof node.temperature === 'number' && node.temperature > 0 ? node.temperature : null;
case 'uptime':
return node.uptime ?? null;
case 'vms':
return countGuestsForNode(guests, node).vms;
case 'cts':
return countGuestsForNode(guests, node).containers;
default:
key satisfies never;
return null;
}
};
export const ProxmoxNodesTable: Component<{
nodes: Resource[];
guests: Resource[];
search?: Accessor<string>;
metricDisplayMode?: Accessor<WorkloadsMetricDisplayMode>;
metricHistoryRange?: Accessor<WorkloadTableMetricHistoryRange>;
layoutWidth?: Accessor<number | null | undefined>;
emptyIcon: JSX.Element;
emptyTitle: string;
emptyDescription: string;
topology?: ProxmoxEstateTopology;
inventoryCountsVisible?: Accessor<boolean>;
onShowGuests?: (node: Resource) => void;
guestFilterNodeId?: Accessor<string | null>;
}> = (props) => {
const breakpoint = useBreakpoint();
const inventoryCountsVisible = () => props.inventoryCountsVisible?.() ?? true;
const { activeAlerts } = useWebSocket();
const alertsActivation = useAlertsActivation();
const alertsEnabled = alertsActivation.detectionEnabled;
const now = useRelativeTimeNow();
const [selectedNodeId, setSelectedNodeId] = createSignal<string | null>(null);
const layoutMode = createMemo(() => {
const measuredWidth = props.layoutWidth?.();
return typeof measuredWidth === 'number' && measuredWidth > 0
? getProxmoxHostTableLayoutModeForContainer(measuredWidth)
: getWorkloadTableLayoutMode(breakpoint.width());
});
const singleClusterName = createMemo(() => {
const labels = new Set(props.nodes.map((node) => getResourceClusterLabel(node)));
if (labels.size !== 1) return null;
const [label] = [...labels];
return label && label !== '—' && props.topology?.standalone === 0 ? label : null;
});
const visibleColumns = createMemo(() =>
getProxmoxHostVisibleColumnsForLayout(layoutMode(), {
singleCluster: singleClusterName() !== null,
}),
);
const visibleColumnIds = createMemo(() => visibleColumns().map((column) => column.id));
const displayMode = () => props.metricDisplayMode?.() ?? 'bars';
const isSparklineMode = () => displayMode() === 'sparklines';
const filteredNodes = createMemo(() =>
filterProxmoxNodes(props.nodes, props.guests, props.search?.() ?? ''),
);
const sort = createPlatformTableSortState({
storageKey: 'proxmoxNodes',
sortKeys: PROXMOX_HOST_SORT_KEYS,
descendingFirst: ['uptime', 'cpu', 'memory', 'disk', 'temp', 'vms', 'cts'],
});
const sortedNodes = createMemo(() =>
sort.sortRows(filteredNodes(), (node, key) => getHostSortValue(node, props.guests, key)),
);
const previewLimit = createMemo(() =>
layoutMode() === 'narrow' || layoutMode() === 'phone' || layoutMode() === 'mobile' ? 6 : 12,
);
const nodePreview = createPlatformTablePreview({ rows: sortedNodes, limit: previewLimit });
const toggleNodePreview = () => {
if (nodePreview.expanded()) setSelectedNodeId(null);
nodePreview.toggle();
};
// Use the same canonical history reader the workloads table uses. This
// table draws node rows only, so it polls the infrastructure summary and
// leaves the guest history to the workloads table below.
const metricHistory = useWorkloadTableMetricHistory({
enabled: isSparklineMode,
range: () => props.metricHistoryRange?.() ?? '1h',
series: 'nodes',
});
return (
<Show
when={props.nodes.length > 0}
fallback={
<PlatformTableEmptyState
icon={props.emptyIcon}
title={props.emptyTitle}
description={props.emptyDescription}
/>
}
>
<Show
when={filteredNodes().length > 0}
fallback={
<PlatformTableEmptyState
icon={props.emptyIcon}
title="No matching Proxmox VE nodes"
description="Adjust the search to see nodes or guests in this Proxmox estate."
/>
}
>
<PlatformTableShell
title={
<span class="inline-flex items-center gap-1.5">
Nodes
<Show when={inventoryCountsVisible()}>
<span class="font-semibold tabular-nums text-base-content">
{formatPlatformTableIntegerValue(filteredNodes().length)}
<Show when={filteredNodes().length !== props.nodes.length}>
<span class="ml-1 text-xs font-medium text-muted">
of {formatPlatformTableIntegerValue(props.nodes.length)}
</span>
</Show>
</span>
</Show>
</span>
}
actions={
<span class="inline-flex items-center gap-2">
<Show
when={singleClusterName()}
fallback={
<Show
when={
inventoryCountsVisible() &&
props.topology &&
!props.search?.()?.trim() &&
(props.topology.clusters > 0 || props.topology.standalone > 0)
}
>
<span class="text-[10px] font-medium text-muted">
<Show when={props.topology!.clusters > 0}>
{formatPlatformTableIntegerValue(props.topology!.clusters)}{' '}
{props.topology!.clusters === 1 ? 'cluster' : 'clusters'}
</Show>
<Show when={props.topology!.clusters > 0 && props.topology!.standalone > 0}>
{' / '}
</Show>
<Show when={props.topology!.standalone > 0}>
{formatPlatformTableIntegerValue(props.topology!.standalone)} standalone
</Show>
</span>
</Show>
}
>
{/* The hidden Cluster column's value lives here, so it stays
visible while searching and when inventory counts are off. */}
{(name) => (
<span
class="text-[10px] font-medium text-muted"
data-testid="proxmox-single-cluster-label"
>
Cluster {name()}
</span>
)}
</Show>
</span>
}
footer={
<PlatformTablePreviewFooter
expanded={nodePreview.expanded()}
canExpand={nodePreview.canExpand()}
total={filteredNodes().length}
visibleCount={nodePreview.visibleRows().length}
noun="nodes"
showCount={inventoryCountsVisible()}
onToggle={toggleNodePreview}
/>
}
cardClass="proxmox-nodes-card"
tableClass={`${getProxmoxHostTableMinWidthClass(layoutMode())} table-fixed text-xs`}
colgroup={
<colgroup>
<For each={visibleColumns()}>
{(column) => (
<col
style={getProxmoxHostColumnWidthStyle(
column.id,
layoutMode(),
visibleColumnIds(),
)}
/>
)}
</For>
</colgroup>
}
header={
<For each={visibleColumns()}>
{(column) => (
<PlatformSortableTableHead kind={column.kind} sort={sort} sortKey={column.id}>
{(layoutMode() === 'narrow' ||
layoutMode() === 'phone' ||
layoutMode() === 'mobile') &&
column.id === 'memory'
? 'Mem'
: (layoutMode() === 'narrow' ||
layoutMode() === 'phone' ||
layoutMode() === 'mobile') &&
column.id === 'uptime'
? 'Age'
: column.label}
</PlatformSortableTableHead>
)}
</For>
}
body={
<PlatformWindowedRows items={nodePreview.visibleRows} estimatedRowHeight={32}>
{(node) => {
const name = () => asTrimmedString(node.name) || node.id;
const nativeNodeName = () => asTrimmedString(node.proxmox?.nodeName) ?? '';
const visibleNodeLabel = () =>
layoutMode() === 'narrow' && nativeNodeName().length > 0
? nativeNodeName()
: name();
const drawerNode = createMemo(() => nodeFromResource(node));
const detailRowId = () => `proxmox-host-drawer-${node.id}`;
const isSelected = () => selectedNodeId() === node.id;
const toggleNodeDrawer = () =>
setSelectedNodeId((current) => (current === node.id ? null : node.id));
const version = () => asTrimmedString(getResourceVersion(node));
const cluster = () => getResourceClusterLabel(node);
const counts = () => countGuestsForNode(props.guests, node);
const isGuestFilterSelected = () => props.guestFilterNodeId?.() === node.id;
const showGuests = () => props.onShowGuests?.(node);
const rowInteraction = getPlatformResourceDetailRowInteractionProps({
expanded: false,
onToggle: showGuests,
});
const indicator = () => getSimpleStatusIndicator(node.status);
const connectionHealth = createMemo(() =>
(asTrimmedString(node.proxmox?.connectionHealth) ?? '').toLowerCase(),
);
const availabilityLabel = createMemo(() => {
if (node.status === 'offline') return 'Offline';
// A linked Pulse agent can still prove that a host is online
// while the Proxmox provider path is unavailable. In that
// hybrid case the provider metrics are stale, not evidence
// that the host itself is powered off.
if (connectionHealth() === 'error' && node.status === 'online') return 'Stale';
if (connectionHealth() === 'error') return 'Offline';
if (
node.status === 'unknown' ||
connectionHealth() === 'degraded' ||
connectionHealth() === 'stale'
) {
return 'Stale';
}
if (node.status === 'degraded' || node.status === 'warning') return 'Degraded';
return 'Online';
});
const isOnline = createMemo(() => availabilityLabel() === 'Online');
const usesCompactMetrics = () =>
layoutMode() === 'narrow' ||
layoutMode() === 'phone' ||
layoutMode() === 'mobile';
const usesCondensedIdentity = () =>
layoutMode() === 'narrow' || layoutMode() === 'phone';
const uptime = () =>
formatNodeUptime(isOnline() ? node.uptime : undefined, usesCompactMetrics());
const fullUptime = () =>
formatNodeUptime(isOnline() ? node.uptime : undefined).label;
const metricsKey = () => buildMetricKeyForUnifiedResource(node);
const temperature = () => node.temperature;
const alertResourceIds = () => hostOverrideIdCandidates(node);
const temperatureThresholds = () =>
alertsActivation.getMetricThresholds('node', 'temperature', alertResourceIds());
// The node's own temperature alert holds after the reading dips
// under its trigger; the cell keeps the alert's tone and says why
// instead of reading green beside a warning row.
const temperatureAlert = createMemo(() =>
getAlertsForResource(alertResourceIds(), activeAlerts, alertsEnabled()).find(
(alert) => alert.type === 'temperature',
),
);
const temperatureAlertSeverity = () => {
const alert = temperatureAlert();
if (!alert || alert.acknowledged) return null;
return alert.level === 'critical' ? 'critical' : 'warning';
};
const temperatureAlertTitle = () => {
const alert = temperatureAlert();
const presentation = alert ? getMetricAlertPresentation(alert, now()) : null;
return presentation
? `${presentation.summary}. ${presentation.detail}`
: alert?.message;
};
const cpuThresholds = () =>
alertsActivation.getMetricThresholds('node', 'cpu', alertResourceIds());
const memoryThresholds = () =>
alertsActivation.getMetricThresholds('node', 'memory', alertResourceIds());
const diskThresholds = () =>
alertsActivation.getMetricThresholds('node', 'disk', alertResourceIds());
const cpuPercent = () => getPlatformTableFiniteMetric(node.cpu?.current) ?? 0;
const memoryUsed = () => getPlatformTableFiniteMetric(node.memory?.used) ?? 0;
const memoryTotal = () => getPlatformTableFiniteMetric(node.memory?.total) ?? 0;
const memoryPercent = () =>
memoryTotal() > 0
? (memoryUsed() / memoryTotal()) * 100
: (getPlatformTableFiniteMetric(node.memory?.current) ?? 0);
const memoryPercentOnly = () =>
!memoryTotal() && getPlatformTableFiniteMetric(node.memory?.current) !== undefined
? getPlatformTableFiniteMetric(node.memory?.current)
: undefined;
const diskPercent = () => getPlatformTableFiniteMetric(node.disk?.current) ?? 0;
const aggregateDisk = (): Disk | undefined => {
if (!node.disk) return undefined;
const total = getPlatformTableFiniteMetric(node.disk.total) ?? 0;
const used = getPlatformTableFiniteMetric(node.disk.used) ?? 0;
const free = getPlatformTableFiniteMetric(node.disk.free) ?? 0;
const usage = getPlatformTableFiniteMetric(node.disk.current) ?? 0;
return { total, used, free, usage } as Disk;
};
const legacyNode = () => projectResourceToLegacyNode(node);
const externalUrl = () => {
const shimmed = drawerNode();
return shimmed ? getNodeExternalUrl(shimmed) : '';
};
const pendingUpdates = () => drawerNode()?.pendingUpdates ?? 0;
const pendingUpdatesAreCurrent = () => {
const currentNode = drawerNode();
return currentNode ? hasCurrentProxmoxUpdateEvidence(currentNode) : false;
};
// The node's own alerts, the set its drawer lists, as on every
// other host table. Matching on the node name would also tint
// the row for any guest's alert, with nothing in it to say why.
const alertStyles = createMemo(() =>
getUnifiedResourceAlertStyles(node, activeAlerts, alertsEnabled()),
);
const alertAccentTone = createMemo<
'critical' | 'warning' | 'acknowledged' | undefined
>(() => {
const styles = alertStyles();
if (styles.hasUnacknowledgedAlert) {
return styles.severity === 'critical' ? 'critical' : 'warning';
}
return styles.hasAcknowledgedOnlyAlert ? 'acknowledged' : undefined;
});
const rowAlertBg = () => {
const styles = alertStyles();
if (!styles.hasUnacknowledgedAlert) return '';
return styles.severity === 'critical'
? 'bg-red-50 dark:bg-red-950/25'
: 'bg-yellow-50 dark:bg-yellow-950/25';
};
const cpuSeries = () => metricHistory.getNodeMetricSeries(legacyNode(), 'cpu');
const memorySeries = () =>
metricHistory.getNodeMetricSeries(legacyNode(), 'memory');
const diskSeries = () => metricHistory.getNodeMetricSeries(legacyNode(), 'disk');
const renderColumnCell = (column: ProxmoxHostTableColumn): JSX.Element => {
switch (column.id) {
case 'node':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<div
class={`flex min-w-0 items-center ${usesCondensedIdentity() ? 'gap-1' : 'gap-2'}`}
>
<PlatformResourceDetailToggleButton
expanded={isSelected()}
resourceLabel={name()}
controlsId={detailRowId()}
hideWhenRowTappableOnMobile={false}
onToggle={toggleNodeDrawer}
/>
<StatusDot
size="sm"
variant={indicator().variant}
title={node.status || 'unknown'}
ariaHidden
/>
<div class="min-w-0 flex-1">
<ResourceNameWithWebInterfaceLink
name={name()}
url={externalUrl()}
class={`min-w-0 ${usesCondensedIdentity() ? '[&>a]:hidden' : ''}`}
nameClass="truncate font-semibold text-base-content"
title={
nativeNodeName() && nativeNodeName() !== name()
? `${name()} · Proxmox node ${nativeNodeName()}`
: `Open ${name()} web interface`
}
>
<PlatformHostScopeNameButton
name={name()}
workloadNoun="guests"
controlsId="proxmox-guests-section"
selected={isGuestFilterSelected()}
onSelect={showGuests}
>
{visibleNodeLabel()}
</PlatformHostScopeNameButton>
</ResourceNameWithWebInterfaceLink>
</div>
<Show when={!isOnline()}>
<span class="hidden rounded-sm bg-surface-alt px-1.5 py-0.5 text-[10px] font-medium text-muted sm:inline-flex">
{availabilityLabel()}
</span>
</Show>
<Show
when={
isOnline() && pendingUpdatesAreCurrent() && pendingUpdates() > 0
}
>
<span
class={`hidden rounded px-1 py-0 text-[9px] font-medium whitespace-nowrap sm:inline-flex ${
pendingUpdates() >= 10
? 'bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-400'
: 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/25 dark:text-yellow-400'
}`}
title={`${pendingUpdates()} pending apt update${pendingUpdates() !== 1 ? 's' : ''}`}
>
{pendingUpdates()} updates
</span>
</Show>
</div>
</TableCell>
);
case 'version':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<Show when={version()} fallback={<span class="text-muted">—</span>}>
<span class="inline-flex items-center rounded-sm bg-surface-alt px-1.5 py-0.5 font-mono text-[10px] text-base-content">
{version()}
</span>
</Show>
</TableCell>
);
case 'uptime':
return (
<TableCell
class={`${getPlatformTableCellClassForKind(column.kind)} tabular-nums ${
uptime().warn
? 'text-orange-600 dark:text-orange-400'
: 'text-base-content'
}`}
title={usesCompactMetrics() ? fullUptime() : undefined}
>
{uptime().label}
</TableCell>
);
case 'cpu':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<Show when={isOnline()} fallback={<PlatformTableMetricFallback />}>
<Show
when={isSparklineMode()}
fallback={
<ResponsiveMetricCell
class="w-full"
value={cpuPercent()}
type="cpu"
resourceId={metricsKey()}
isRunning
showMobile={false}
thresholds={cpuThresholds()}
/>
}
>
<MetricMiniSparkline
series={cpuSeries()}
valueLabel={formatPlatformTablePercentValue(cpuPercent(), {
normalizeRatio: true,
clamp: true,
})}
title={`${name()} CPU history`}
/>
</Show>
</Show>
</TableCell>
);
case 'memory':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<Show
when={isOnline() && (memoryTotal() > 0 || memoryPercentOnly() != null)}
fallback={<PlatformTableMetricFallback />}
>
<Show
when={isSparklineMode()}
fallback={
<StackedMemoryBar
used={memoryUsed()}
total={memoryTotal()}
unavailable={drawerNode()?.memory?.usageUnavailable === true}
percentOnly={memoryPercentOnly()}
cache={drawerNode()?.memory?.cache || 0}
cacheInclusiveLabel="Shown in Proxmox"
swapUsed={drawerNode()?.memory?.swapUsed || 0}
swapTotal={drawerNode()?.memory?.swapTotal || 0}
thresholds={memoryThresholds()}
/>
}
>
<MetricMiniSparkline
series={memorySeries()}
valueLabel={
drawerNode()?.memory?.usageUnavailable
? 'N/A'
: formatPlatformTablePercentValue(memoryPercent(), {
normalizeRatio: true,
clamp: true,
})
}
title={`${name()} memory history`}
/>
</Show>
</Show>
</TableCell>
);
case 'disk':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<Show
when={isOnline() && (aggregateDisk() || node.agent?.disks?.length)}
fallback={<PlatformTableMetricFallback />}
>
<Show
when={isSparklineMode()}
fallback={
<StackedDiskBar
mode={
usesCompactMetrics()
? 'aggregate'
: (node.agent?.disks?.length ?? 0) > 1
? 'vertical-bars'
: undefined
}
// A compact cell has no room for per-disk bars; summarise it
// by the fullest disk so a full one is not averaged away.
summaryStrategy="max"
disks={normalizeDiskArray(node.agent?.disks)}
aggregateDisk={aggregateDisk()}
thresholds={diskThresholds()}
/>
}
>
<MetricMiniSparkline
series={diskSeries()}
valueLabel={formatPlatformTablePercentValue(diskPercent(), {
normalizeRatio: true,
clamp: true,
})}
title={`${name()} disk history`}
/>
</Show>
</Show>
</TableCell>
);
case 'temp':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<Show
when={
isOnline() &&
typeof temperature() === 'number' &&
(temperature() as number) > 0
}
fallback={<span class="text-xs text-muted">—</span>}
>
<TemperatureGauge
value={temperature() as number}
thresholds={temperatureThresholds()}
alertSeverity={temperatureAlertSeverity()}
title={temperatureAlertTitle()}
/>
</Show>
</TableCell>
);
case 'vms':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<span
class={counts().vms > 0 ? VMS_BADGE : ZERO_BADGE}
data-proxmox-vm-count
>
{counts().vms}
</span>
</TableCell>
);
case 'cts':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<span
class={counts().containers > 0 ? CTS_BADGE : ZERO_BADGE}
data-proxmox-container-count
>
{counts().containers}
</span>
</TableCell>
);
case 'cluster':
return (
<TableCell class={getPlatformTableCellClassForKind(column.kind)}>
<span class="inline-flex items-center rounded-md bg-surface-alt px-2 py-0.5 text-[11px] font-medium text-base-content">
{cluster()}
</span>
</TableCell>
);
default:
column.id satisfies never;
return <></>;
}
};
return (
<>
<TableRow
class={`host-row cursor-pointer text-[11px] sm:text-xs ${
isSelected() ? 'bg-surface-hover' : rowAlertBg()
} ${isOnline() ? '' : 'opacity-60'}`}
data-proxmox-host-row={node.id}
data-workload-alert-accent={alertAccentTone()}
data-summary-row-active={isGuestFilterSelected() ? 'true' : undefined}
onClick={rowInteraction.onClick}
>
<For each={visibleColumns()}>{(column) => renderColumnCell(column)}</For>
</TableRow>
<Show when={isSelected() && drawerNode()}>
{(selectedNode) => (
<InlineDetailTableRow
cellId={detailRowId()}
colspan={visibleColumns().length}
data-inline-detail-for={node.id}
>
<NodeDrawer
node={selectedNode()}
webInterfaceUrl={externalUrl()}
onClose={() => setSelectedNodeId(null)}
alerts={getAlertsForResource(
alertResourceIds(),
activeAlerts,
alertsEnabled(),
node.name,
)}
// Without the node-name match: the node's own alerts,
// not its guests', drive its trend cards.
ownAlerts={getAlertsForResource(
alertResourceIds(),
activeAlerts,
alertsEnabled(),
)}
disks={normalizeDiskArray(node.agent?.disks)}
temperatureThresholds={temperatureThresholds()}
/>
</InlineDetailTableRow>
)}
</Show>
</>
);
}}
</PlatformWindowedRows>
}
/>
</Show>
</Show>
);
};
export default ProxmoxNodesTable;