Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix threshold-aware temperature severity

rcourtman6d17e117bb7e
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
index a9377ea2e8..debee409a0 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
@@ -2,7 +2,7 @@ import { For, Show, createMemo } from 'solid-js';
import type { Component } from 'solid-js';
import type { Disk } from '@/types/api';
import { formatBytes, formatSpeed, formatUptime, normalizeDiskArray } from '@/utils/format';
-import { formatTemperature } from '@/utils/temperature';
+import { formatTemperature, getTemperatureTextClass } from '@/utils/temperature';
import {
GROUPED_TABLE_ROW_BADGE_CLASS,
GROUPED_TABLE_ROW_META_CLASS,
@@ -288,6 +288,9 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
const diskThresholds = createMemo(() =>
table.getMetricThresholds('agent', 'disk', alertResourceIdCandidates()),
);
+ const temperatureThresholds = createMemo(() =>
+ table.getMetricThresholds('node', 'temperature', alertResourceIdCandidates()),
+ );
const detailControlsId = createMemo(() =>
buildSummaryDisclosureControlsId(resource.id),
);
@@ -743,13 +746,10 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
}
>
<span
- class={`text-xs whitespace-nowrap font-medium ${
- (resource.temperature ?? 0) >= 80
- ? 'text-red-600 dark:text-red-400'
- : (resource.temperature ?? 0) >= 65
- ? 'text-amber-600 dark:text-amber-400'
- : 'text-emerald-600 dark:text-emerald-400'
- }`}
+ class={`text-xs whitespace-nowrap font-medium ${getTemperatureTextClass(
+ resource.temperature,
+ temperatureThresholds(),
+ )}`}
>
{formatTemperature(resource.temperature)}
</span>
diff --git a/frontend-modern/src/components/Storage/DiskList.tsx b/frontend-modern/src/components/Storage/DiskList.tsx
index f118f80c61..2ca148e4d3 100644
--- a/frontend-modern/src/components/Storage/DiskList.tsx
+++ b/frontend-modern/src/components/Storage/DiskList.tsx
@@ -353,7 +353,11 @@ export const DiskList: Component<DiskListProps> = (props) => {
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
<span
- class={`${PHYSICAL_DISK_TEMPERATURE_CLASS} ${getTemperatureTextClass(data.temperature)}`}
+ class={`${PHYSICAL_DISK_TEMPERATURE_CLASS} ${getTemperatureTextClass(
+ data.temperature,
+ undefined,
+ 'diskTemperature',
+ )}`}
>
{formatTemperature(data.temperature)}
</span>
diff --git a/frontend-modern/src/components/shared/TemperatureGauge.tsx b/frontend-modern/src/components/shared/TemperatureGauge.tsx
index fafc9577a4..98875b81e9 100644
--- a/frontend-modern/src/components/shared/TemperatureGauge.tsx
+++ b/frontend-modern/src/components/shared/TemperatureGauge.tsx
@@ -1,5 +1,6 @@
import { Component, createMemo } from 'solid-js';
-import { formatTemperature } from '@/utils/temperature';
+import { formatTemperature, getTemperatureTextClass } from '@/utils/temperature';
+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';
interface TemperatureGaugeProps {
value: number;
@@ -7,19 +8,26 @@ interface TemperatureGaugeProps {
max?: number | null;
critical?: number;
warning?: number;
+ thresholds?: MetricDisplayThresholds | null;
class?: string;
}
export const TemperatureGauge: Component<TemperatureGaugeProps> = (props) => {
- const critical = props.critical ?? 80;
- const warning = props.warning ?? 70;
+ const explicitThresholds = createMemo<MetricDisplayThresholds | null | undefined>(() => {
+ if (props.thresholds !== undefined) return props.thresholds;
+ if (props.critical === undefined && props.warning === undefined) return undefined;
- const textColorClass = createMemo(() => {
- if (props.value >= critical) return 'text-red-600 dark:text-red-400';
- if (props.value >= warning) return 'text-yellow-600 dark:text-yellow-400';
- return 'text-muted';
+ const critical = props.critical ?? 80;
+ return {
+ critical,
+ warning: props.warning ?? Math.max(0, critical - 5),
+ };
});
+ const textColorClass = createMemo(() =>
+ getTemperatureTextClass(props.value, explicitThresholds()),
+ );
+
return (
<span class={`text-xs whitespace-nowrap ${textColorClass()} ${props.class || ''}`}>
{formatTemperature(props.value)}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
index 0f1fdedbdf..7ba128b495 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
@@ -20,6 +20,7 @@ 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 { useBreakpoint } from '@/hooks/useBreakpoint';
import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
import { getSimpleStatusIndicator } from '@/utils/status';
@@ -311,6 +312,9 @@ export const ProxmoxNodesTable: Component<{
const uptime = () => formatNodeUptime(node.uptime);
const metricsKey = () => buildMetricKeyForUnifiedResource(node);
const temperature = () => node.temperature;
+ const alertResourceIds = () => hostOverrideIdCandidates(node);
+ const temperatureThresholds = () =>
+ alertsActivation.getMetricThresholds('node', 'temperature', alertResourceIds());
const cpuPercent = () => getPlatformTableFiniteMetric(node.cpu?.current) ?? 0;
const memoryUsed = () => getPlatformTableFiniteMetric(node.memory?.used) ?? 0;
const memoryTotal = () => getPlatformTableFiniteMetric(node.memory?.total) ?? 0;
@@ -521,7 +525,10 @@ export const ProxmoxNodesTable: Component<{
when={typeof temperature() === 'number' && (temperature() as number) > 0}
fallback={<span class="text-xs text-muted">—</span>}
>
- <TemperatureGauge value={temperature() as number} />
+ <TemperatureGauge
+ value={temperature() as number}
+ thresholds={temperatureThresholds()}
+ />
</Show>
</TableCell>
);
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx
index fcc232d124..50b1321269 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx
@@ -1,11 +1,13 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
-import { afterEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { Resource } from '@/types/resource';
import { ProxmoxNodesTable } from '../ProxmoxNodesTable';
const nodeDrawerMock = vi.hoisted(() => vi.fn());
const activeAlertsMock = vi.hoisted(() => ({ value: {} as Record<string, unknown> }));
+const getMetricThresholdsMock = vi.hoisted(() => vi.fn());
+const temperatureGaugeMock = vi.hoisted(() => vi.fn());
vi.mock('@/hooks/useBreakpoint', () => ({
useBreakpoint: () => ({
@@ -18,7 +20,10 @@ vi.mock('@/contexts/appRuntime', () => ({
}));
vi.mock('@/stores/alertsActivation', () => ({
- useAlertsActivation: () => ({ activationState: () => 'active' }),
+ useAlertsActivation: () => ({
+ activationState: () => 'active',
+ getMetricThresholds: getMetricThresholdsMock,
+ }),
}));
vi.mock('@/components/shared/responsive', () => ({
@@ -27,10 +32,7 @@ vi.mock('@/components/shared/responsive', () => ({
vi.mock('@/components/Workloads/StackedMemoryBar', () => ({
StackedMemoryBar: (props: { cacheInclusiveLabel?: string }) => (
- <div
- data-testid="stacked-memory-bar"
- data-cache-inclusive-label={props.cacheInclusiveLabel}
- />
+ <div data-testid="stacked-memory-bar" data-cache-inclusive-label={props.cacheInclusiveLabel} />
),
}));
@@ -43,7 +45,10 @@ vi.mock('@/components/Workloads/MetricMiniSparkline', () => ({
}));
vi.mock('@/components/shared/TemperatureGauge', () => ({
- TemperatureGauge: () => <div data-testid="temperature-gauge" />,
+ TemperatureGauge: (props: { value: number; thresholds?: unknown }) => {
+ temperatureGaugeMock({ value: props.value, thresholds: props.thresholds });
+ return <div data-testid="temperature-gauge" />;
+ },
}));
vi.mock('@/components/Workloads/useWorkloadTableMetricHistory', () => ({
@@ -80,12 +85,16 @@ const makeNodeResource = (overrides: Partial<Resource> = {}): Resource => ({
...overrides,
});
-afterEach(() => {
- cleanup();
+beforeEach(() => {
vi.clearAllMocks();
+ getMetricThresholdsMock.mockReturnValue({ warning: 80, critical: 85 });
activeAlertsMock.value = {};
});
+afterEach(() => {
+ cleanup();
+});
+
describe('ProxmoxNodesTable', () => {
it('links each node to its PVE web interface without hijacking the row click', () => {
render(() => (
@@ -126,9 +135,34 @@ describe('ProxmoxNodesTable', () => {
/>
));
- expect(
- screen.getByRole('link', { name: 'Open web interface for pve-node-1' }),
- ).toHaveAttribute('href', 'https://pve-node-1:8006');
+ expect(screen.getByRole('link', { name: 'Open web interface for pve-node-1' })).toHaveAttribute(
+ 'href',
+ 'https://pve-node-1:8006',
+ );
+ });
+
+ it('passes alert-backed temperature thresholds into the node temperature gauge', () => {
+ render(() => (
+ <ProxmoxNodesTable
+ nodes={[makeNodeResource({ temperature: 76 })]}
+ guests={[]}
+ emptyIcon={<span />}
+ emptyTitle="No Proxmox VE nodes"
+ emptyDescription="No nodes"
+ />
+ ));
+
+ expect(getMetricThresholdsMock).toHaveBeenCalledWith(
+ 'node',
+ 'temperature',
+ expect.arrayContaining(['agent:pve-node-1']),
+ );
+ expect(temperatureGaugeMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ value: 76,
+ thresholds: { warning: 80, critical: 85 },
+ }),
+ );
});
it('keeps the Proxmox cache-inclusive memory comparison label on node rows', () => {
diff --git a/frontend-modern/src/utils/__tests__/metricThresholds.test.ts b/frontend-modern/src/utils/__tests__/metricThresholds.test.ts
index 52cf287c18..7d2830bd27 100644
--- a/frontend-modern/src/utils/__tests__/metricThresholds.test.ts
+++ b/frontend-modern/src/utils/__tests__/metricThresholds.test.ts
@@ -5,6 +5,7 @@ import {
getMetricColorRgba,
getMetricColorHex,
getMetricTextColorClass,
+ getDefaultDisplayMetricThresholds,
getDefaultMetricDisplayThresholds,
resolveMetricDisplayThresholds,
METRIC_THRESHOLDS,
@@ -79,6 +80,16 @@ describe('metricThresholds', () => {
expect(getMetricSeverity(100, metric)).toBe('critical');
});
});
+
+ describe('temperature', () => {
+ it('uses configured display thresholds instead of static frontend cutoffs', () => {
+ const thresholds = { warning: 80, critical: 85 };
+
+ expect(getMetricSeverity(76, 'temperature', thresholds)).toBe('normal');
+ expect(getMetricSeverity(80, 'temperature', thresholds)).toBe('warning');
+ expect(getMetricSeverity(85, 'temperature', thresholds)).toBe('critical');
+ });
+ });
});
describe('getMetricColorClass', () => {
@@ -168,6 +179,14 @@ describe('metricThresholds', () => {
expect(getDefaultMetricDisplayThresholds('cpu')).toEqual({ warning: 75, critical: 80 });
expect(getDefaultMetricDisplayThresholds('memory')).toEqual({ warning: 80, critical: 85 });
expect(getDefaultMetricDisplayThresholds('disk')).toEqual({ warning: 85, critical: 90 });
+ expect(getDefaultDisplayMetricThresholds('temperature', 'node')).toEqual({
+ warning: 75,
+ critical: 80,
+ });
+ expect(getDefaultDisplayMetricThresholds('diskTemperature')).toEqual({
+ warning: 50,
+ critical: 55,
+ });
expect(getDefaultMetricDisplayThresholds('generic')).toEqual({
warning: 75,
critical: 90,
@@ -244,6 +263,23 @@ describe('metricThresholds', () => {
});
});
+ it('resolves node temperature display thresholds from configured alert defaults', () => {
+ const config = {
+ enabled: true,
+ guestDefaults: {},
+ nodeDefaults: {
+ temperature: { trigger: 85, clear: 80 },
+ },
+ storageDefault: { trigger: 85, clear: 80 },
+ overrides: {},
+ } as AlertConfig;
+
+ expect(resolveMetricDisplayThresholds(config, 'node', 'temperature')).toEqual({
+ warning: 80,
+ critical: 85,
+ });
+ });
+
it('keeps Kubernetes, TrueNAS, and vSphere factory defaults explicit for alert configuration', () => {
expect(FACTORY_KUBERNETES_DEFAULTS).toEqual({
cpu: 80,
diff --git a/frontend-modern/src/utils/__tests__/temperature.test.ts b/frontend-modern/src/utils/__tests__/temperature.test.ts
index 717716e779..ec4824f67f 100644
--- a/frontend-modern/src/utils/__tests__/temperature.test.ts
+++ b/frontend-modern/src/utils/__tests__/temperature.test.ts
@@ -123,11 +123,25 @@ describe('temperature', () => {
});
it('returns amber for elevated temperatures', () => {
- expect(getTemperatureTextClass(60)).toContain('text-amber-600');
+ expect(getTemperatureTextClass(75)).toContain('text-amber-600');
});
it('returns red for high temperatures', () => {
- expect(getTemperatureTextClass(70)).toContain('text-red-600');
+ expect(getTemperatureTextClass(80)).toContain('text-red-600');
+ });
+
+ it('honors configured warning and critical thresholds', () => {
+ const thresholds = { warning: 80, critical: 85 };
+
+ expect(getTemperatureTextClass(76, thresholds)).toContain('text-green-600');
+ expect(getTemperatureTextClass(80, thresholds)).toContain('text-amber-600');
+ expect(getTemperatureTextClass(85, thresholds)).toContain('text-red-600');
+ });
+
+ it('uses disk temperature defaults for disk temperature displays', () => {
+ expect(getTemperatureTextClass(49, undefined, 'diskTemperature')).toContain('text-green-600');
+ expect(getTemperatureTextClass(50, undefined, 'diskTemperature')).toContain('text-amber-600');
+ expect(getTemperatureTextClass(55, undefined, 'diskTemperature')).toContain('text-red-600');
});
});
diff --git a/frontend-modern/src/utils/metricThresholds.ts b/frontend-modern/src/utils/metricThresholds.ts
index 63d7548049..241c33f5a4 100644
--- a/frontend-modern/src/utils/metricThresholds.ts
+++ b/frontend-modern/src/utils/metricThresholds.ts
@@ -47,6 +47,15 @@ const DEFAULT_GENERIC_THRESHOLDS: MetricDisplayThresholds = {
const DEFAULT_HYSTERESIS_MARGIN = 5;
+const DISPLAY_METRIC_DEFAULT_SCOPES: Record<DisplayMetricType, AlertThresholdScope> = {
+ cpu: 'guest',
+ memory: 'guest',
+ disk: 'guest',
+ temperature: 'node',
+ diskTemperature: 'agent',
+ usage: 'storage',
+};
+
const SCOPE_DEFAULTS: Record<
Exclude<AlertThresholdScope, 'storage'>,
Partial<Record<DisplayMetricType, number>>
@@ -222,6 +231,12 @@ export const getDefaultMetricDisplayThresholds = (
);
};
+export const getDefaultDisplayMetricThresholds = (
+ metric: DisplayMetricType,
+ scope: AlertThresholdScope = DISPLAY_METRIC_DEFAULT_SCOPES[metric],
+): MetricDisplayThresholds | null =>
+ resolveThreshold(undefined, getFallbackCritical(scope, metric), DEFAULT_HYSTERESIS_MARGIN);
+
export const resolveMetricDisplayThresholds = (
config: AlertConfig | null,
scope: AlertThresholdScope,
@@ -236,13 +251,20 @@ export const resolveMetricDisplayThresholds = (
return resolveThreshold(overrideValue ?? baseValue, getFallbackCritical(scope, metric), margin);
};
-/** Determine severity level from a percentage value and metric type. */
+const getFallbackSeverityThresholds = (metric: DisplayMetricType): MetricDisplayThresholds => {
+ if (metric === 'cpu' || metric === 'memory' || metric === 'disk') {
+ return METRIC_THRESHOLDS[metric];
+ }
+ return getDefaultDisplayMetricThresholds(metric) ?? DEFAULT_GENERIC_THRESHOLDS;
+};
+
+/** Determine severity level from a metric value and display thresholds. */
export function getMetricSeverity(
value: number,
- metric: MetricType,
+ metric: DisplayMetricType,
thresholds?: MetricDisplayThresholds | null,
): MetricSeverity {
- const t = thresholds ?? METRIC_THRESHOLDS[metric];
+ const t = thresholds ?? getFallbackSeverityThresholds(metric);
if (value >= t.critical) return 'critical';
if (value >= t.warning) return 'warning';
return 'normal';
@@ -258,7 +280,7 @@ const BG_CLASSES: Record<MetricSeverity, string> = {
export function getMetricColorClass(
value: number,
- metric: MetricType,
+ metric: DisplayMetricType,
thresholds?: MetricDisplayThresholds | null,
): string {
return BG_CLASSES[getMetricSeverity(value, metric, thresholds)];
@@ -274,7 +296,7 @@ const RGBA_COLORS: Record<MetricSeverity, string> = {
export function getMetricColorRgba(
value: number,
- metric: MetricType,
+ metric: DisplayMetricType,
thresholds?: MetricDisplayThresholds | null,
): string {
return RGBA_COLORS[getMetricSeverity(value, metric, thresholds)];
@@ -290,7 +312,7 @@ const HEX_COLORS: Record<MetricSeverity, string> = {
export function getMetricColorHex(
value: number,
- metric: MetricType,
+ metric: DisplayMetricType,
thresholds?: MetricDisplayThresholds | null,
): string {
return HEX_COLORS[getMetricSeverity(value, metric, thresholds)];
@@ -306,7 +328,7 @@ const TEXT_CLASSES: Record<MetricSeverity, string> = {
export function getMetricTextColorClass(
value: number,
- metric: MetricType,
+ metric: DisplayMetricType,
thresholds?: MetricDisplayThresholds | null,
): string {
return TEXT_CLASSES[getMetricSeverity(value, metric, thresholds)];
diff --git a/frontend-modern/src/utils/temperature.ts b/frontend-modern/src/utils/temperature.ts
index 1346918a33..cf015e31c3 100644
--- a/frontend-modern/src/utils/temperature.ts
+++ b/frontend-modern/src/utils/temperature.ts
@@ -1,5 +1,11 @@
import type { Temperature } from '@/types/api';
import { createSignal, createRoot } from 'solid-js';
+import {
+ getDefaultDisplayMetricThresholds,
+ getMetricSeverity,
+ type DisplayMetricType,
+ type MetricDisplayThresholds,
+} from './metricThresholds';
import { STORAGE_KEYS } from './localStorage';
export type TemperatureUnit = 'celsius' | 'fahrenheit';
@@ -92,11 +98,23 @@ export const getCpuTemperature = (temperature?: Temperature | null): number | nu
return Math.max(...candidates);
};
-export const getTemperatureTextClass = (celsius: number | null | undefined): string => {
+const TEMPERATURE_TEXT_CLASSES = {
+ critical: 'text-red-600 dark:text-red-400',
+ warning: 'text-amber-600 dark:text-amber-400',
+ normal: 'text-green-600 dark:text-green-400',
+} as const;
+
+type TemperatureDisplayMetric = Extract<DisplayMetricType, 'temperature' | 'diskTemperature'>;
+
+export const getTemperatureTextClass = (
+ celsius: number | null | undefined,
+ thresholds?: MetricDisplayThresholds | null,
+ metric: TemperatureDisplayMetric = 'temperature',
+): string => {
if (celsius === null || celsius === undefined || !Number.isFinite(celsius)) {
return 'text-muted';
}
- if (celsius >= 70) return 'text-red-600 dark:text-red-400';
- if (celsius >= 60) return 'text-amber-600 dark:text-amber-400';
- return 'text-green-600 dark:text-green-400';
+ return TEMPERATURE_TEXT_CLASSES[
+ getMetricSeverity(celsius, metric, thresholds ?? getDefaultDisplayMetricThresholds(metric))
+ ];
};