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.

Add macOS thermal state reporting

rcourtman6a162a1736b0
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 2305589299..ad100de95e 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -738,6 +738,10 @@ instead of lifecycle-local centered icon/text shells.
or no-data results, and partial or plain-text smartctl output must still
preserve model, serial, health, and temperature data through the same
host-agent runtime boundary instead of leaving monitoring to guess.
+ macOS thermal telemetry belongs in the same host-agent sensor contract, but
+ it must report Darwin `pmset` thermal and performance pressure as
+ `sensors.thermalState` instead of inventing Celsius readings from unavailable
+ Apple silicon sensor values.
Runtime RAID collection uses `/proc/mdstat` as the canonical discovery
baseline for Linux md arrays. `mdadm --detail` may enrich level, state,
member, UUID, and rebuild fields when available, but missing or failing
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 590a883c04..fafb25c34d 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -2186,6 +2186,11 @@ 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.
+Host sensor summaries also carry optional `thermalState` for platforms such as
+macOS that expose thermal pressure but not stable Celsius sensor readings. API
+payloads must keep that state separate from `temperatureCelsius`; clients may
+display pressure and throttling limits, but must not synthesize a temperature
+metric or table value from pressure-only payloads.
`aicontracts.Finding` (the shape Patrol hands the investigation
orchestrator) carries optional `OperatorContext` and
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 6ea2ceb476..e149999dd1 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -555,6 +555,12 @@ 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.
+Host-agent thermal pressure is not part of that Celsius history stream.
+`internal/monitoring/monitor_agents.go`, `internal/monitoring/monitor.go`, and
+the shared model conversion helpers must preserve `sensors.thermalState`
+through ingest, read-state projection, and frontend conversion, while leaving
+`agent.temperature` and `metric=temperature` unset unless a real Celsius value
+exists.
That same monitoring owner also owns canonical unified-resource publication on
`/api/state` and the websocket `state.resources` hydrate path. Monitoring must
publish those resources from the same canonical unified snapshot that
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 2694cb63a2..fa38d17b18 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -758,6 +758,11 @@ 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.
+Standalone agent thermal pressure follows the same drawer-only density rule:
+`resourceDetailMappers.ts` may render compact pressure and throttling-limit rows
+inside the selected system's thermals card, but platform and Workloads table
+temperature cells must remain blank when the source has no positive Celsius
+reading.
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
@@ -1248,6 +1253,9 @@ while canonical drawer discovery-target derivation now lives in
under `unified-resources`. Future discovery-config or target-resolution
changes must extend through that unified-resource owner instead of
re-accumulating discovery heuristics back into the performance hot-path mapper.
+That mapper may add simple host-agent thermals rows from already-loaded sensor
+metadata, including `thermalState`, but it must not perform additional resource
+lookups, history reads, or polling work to decorate the drawer.
The PBS service-table hot path now follows that same split: raw job arrays may
cross the transport boundary, but
`frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts`
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 1a31792a46..fd6af12197 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1654,6 +1654,10 @@ 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.
+The same boundary applies to host-agent `thermalState`: macOS pressure and
+throttling limits may appear as host context, but storage and recovery must not
+reinterpret pressure state as disk temperature, pool risk, backup freshness, or
+a storage-owned thermal timeline.
Storage and recovery still consume the shared unified-resource contract, but
they do not own the timeline store itself. The canonical resource-change
@@ -2865,6 +2869,9 @@ SMART disk temperatures in the wrapper payload. Storage and recovery disk
temperature surfaces may depend on that monitoring-owned SMART merge path, but
they must not reintroduce raw `sensors -j` as the setup contract or build a
storage-local disk-temperature collector.
+Pressure-only host-agent telemetry remains outside that storage collector
+contract: storage surfaces may read the shared host context, but may not add a
+parallel macOS thermal collector or fold `thermalState` into disk SMART state.
That same shared discovery dependency also assumes runtime discovery state owns
only structured errors, while adjacent API and WebSocket payloads may derive
the deprecated string `errors` list only as a compatibility field from those
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 7583a64dcd..7b11855e90 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -314,6 +314,10 @@ normalization/clamping when the source metric requires it, positive Celsius
validation, tabular styling, and empty markers instead of local
`formatPercent`, `formatPercentLabel`, `toFixed(1)%`, `formatTemperature`, or
temperature label helpers.
+Thermal pressure state is a separate host sensor facet, not a table temperature
+source. Unified-resource adapters must carry `agent.sensors.thermalState`
+alongside `temperatureCelsius`, and table consumers must continue to render an
+empty temperature marker when only pressure state is present.
Metric bar fallbacks follow that split as well: unified-resource consumers own
which CPU or memory value is selected, plus any source-specific fallback reason
such as outdated standalone agent telemetry, while platform tables must use
@@ -1776,6 +1780,11 @@ TrueNAS system records must project `cputemp` readings into the shared
`agent.temperature` and `agent.sensors.temperatureCelsius` fields instead of
inventing a provider-local temperature payload or leaving TrueNAS host
temperatures unavailable without the unified agent.
+Pressure-only host telemetry follows the same canonical host-sensor route:
+agent resources may include `agent.sensors.thermalState` even when
+`agent.temperature` and `agent.sensors.temperatureCelsius` are absent, so
+platform consumers can show macOS pressure without creating provider-local
+thermal payloads or fake Celsius values.
AI discovery and query surfaces now follow the same rule. Assistant runtime
paths such as `pulse_query` and unified AI context must expose TrueNAS-backed
canonical `agent`, `vm`, `app-container`, `storage`, and `physical-disk`
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
index 3049f6bcfd..79c07a6f07 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
@@ -162,7 +162,7 @@ const HostDetailsDisclosure: Component<{
<NetworkInterfacesCard interfaces={agent().networkInterfaces} />
<DisksCard disks={agent().disks} />
<RaidCard arrays={props.drawer.agentMeta()?.raid} />
- <TemperaturesCard rows={props.drawer.temperatureRows()} />
+ <TemperaturesCard rows={props.drawer.temperatureRows()} title="Thermals" />
</>
)}
</Show>
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index 27ef79fa97..18948c6fdb 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -5,7 +5,10 @@ import { render, waitFor, within } from '@solidjs/testing-library';
import type { Resource } from '@/types/resource';
import { UnifiedResourceTable } from '@/components/Infrastructure/UnifiedResourceTable';
import { ResourceFacetSummary } from '@/components/Infrastructure/ResourceFacetSummary';
-import { formatSensorName } from '@/components/Infrastructure/resourceDetailMappers';
+import {
+ buildTemperatureRows,
+ formatSensorName,
+} from '@/components/Infrastructure/resourceDetailMappers';
import { getPreferredInfrastructureDisplayName } from '@/utils/resourceIdentity';
import unifiedResourceTableSource from '@/components/Infrastructure/UnifiedResourceTable.tsx?raw';
import unifiedResourceTableStateSource from '@/components/Infrastructure/useUnifiedResourceTableState.ts?raw';
@@ -507,6 +510,19 @@ describe('UnifiedResourceTable performance contract', () => {
it('formats sensor labels through the shared resource detail mapper helper', () => {
expect(formatSensorName('fan1_cpu_temp')).toBe('Cpu Temp');
expect(formatSensorName('psu_temp')).toBe('Temp');
+ expect(
+ buildTemperatureRows({
+ temperatureCelsius: {},
+ thermalState: {
+ source: 'pmset',
+ pressure: 'constrained',
+ limitsPercent: { cpu_speed_limit: 72, scheduler_limit: 100 },
+ },
+ }),
+ ).toEqual([
+ { label: 'Thermal pressure', value: 'Constrained', valueTitle: 'Constrained via pmset' },
+ { label: 'Speed Limit', value: '72%', valueTitle: 'Speed Limit 72%' },
+ ]);
expect(resourceDetailMappersSource).toContain('titleCaseDelimitedLabel');
expect(resourceDetailMappersSource).not.toContain('export const toDiscoveryConfig');
expect(resourceDetailDiscoveryModelSource).toContain('export const toDiscoveryConfig');
@@ -598,7 +614,7 @@ describe('UnifiedResourceTable performance contract', () => {
expect(unifiedResourcePBSTableSectionSource).not.toContain('getPbsActivitySummary');
});
- it('keeps contextual resource-row emphasis on the shared active-row presentation contract', () => {
+ it('keeps contextual resource-row emphasis on the shared active-row presentation contract', () => {
expect(frontendIndexCssSource).toContain("tr[data-summary-row-active='true'] > td");
expect(frontendIndexCssSource).toContain('--color-summary-row-bg');
expect(frontendIndexCssSource).toContain('--color-summary-row-accent');
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
index c9e98301a2..b27d999835 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import {
+ buildTemperatureRows,
formatInteger,
formatSensorName,
formatSourceType,
@@ -95,6 +96,34 @@ describe('resourceDetailMappers', () => {
});
});
+ describe('buildTemperatureRows', () => {
+ it('surfaces macOS thermal pressure without inventing Celsius temperatures', () => {
+ const rows = buildTemperatureRows({
+ thermalState: {
+ source: 'pmset',
+ pressure: 'constrained',
+ limitsPercent: {
+ cpu_speed_limit: 80,
+ scheduler_limit: 100,
+ },
+ },
+ });
+
+ expect(rows).toEqual([
+ {
+ label: 'Thermal pressure',
+ value: 'Constrained',
+ valueTitle: 'Constrained via pmset',
+ },
+ {
+ label: 'Speed Limit',
+ value: '80%',
+ valueTitle: 'Speed Limit 80%',
+ },
+ ]);
+ });
+ });
+
describe('toNodeFromProxmox', () => {
it('preserves canonical linkedAgentId for hybrid hosts', () => {
const node = toNodeFromProxmox(createHybridHostResource());
diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
index e75cbc817b..8d68d724e2 100644
--- a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
+++ b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
@@ -326,6 +326,29 @@ export const formatSensorName = (name: string) => {
export const buildTemperatureRows = (sensors?: HostSensorSummary) => {
const rows: { label: string; value: string; valueTitle?: string }[] = [];
+ const thermalState = sensors?.thermalState;
+ if (thermalState?.pressure) {
+ rows.push({
+ label: 'Thermal pressure',
+ value: titleCaseDelimitedLabel(thermalState.pressure),
+ valueTitle: thermalState.source
+ ? `${titleCaseDelimitedLabel(thermalState.pressure)} via ${thermalState.source}`
+ : titleCaseDelimitedLabel(thermalState.pressure),
+ });
+ }
+ const limits = thermalState?.limitsPercent;
+ if (limits) {
+ Object.entries(limits)
+ .filter(([, value]) => Number.isFinite(value) && value < 100)
+ .sort(([a], [b]) => a.localeCompare(b))
+ .forEach(([name, value]) => {
+ rows.push({
+ label: formatSensorName(name),
+ value: `${Math.round(value)}%`,
+ valueTitle: `${formatSensorName(name)} ${Math.round(value)}%`,
+ });
+ });
+ }
const temps = sensors?.temperatureCelsius;
if (temps) {
const entries = Object.entries(temps).sort(([a], [b]) => a.localeCompare(b));
diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.ts
index 29d90400ad..e46f3e9622 100644
--- a/frontend-modern/src/hooks/useUnifiedResources.ts
+++ b/frontend-modern/src/hooks/useUnifiedResources.ts
@@ -95,6 +95,14 @@ type APIAgentSensorSummary = {
temperatureCelsius?: Record<string, number>;
fanRpm?: Record<string, number>;
additional?: Record<string, number>;
+ thermalState?: {
+ source?: string;
+ pressure?: string;
+ thermalWarningLevel?: number;
+ performanceWarningLevel?: number;
+ cpuPowerStatus?: number;
+ limitsPercent?: Record<string, number>;
+ };
smart?: Array<{
device: string;
model?: string;
diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.ts
index f8749b628e..5c7d3e0368 100644
--- a/frontend-modern/src/types/api.ts
+++ b/frontend-modern/src/types/api.ts
@@ -478,9 +478,19 @@ export interface HostSensorSummary {
temperatureCelsius?: Record<string, number>;
fanRpm?: Record<string, number>;
additional?: Record<string, number>;
+ thermalState?: HostThermalState;
smart?: HostDiskSMART[]; // S.M.A.R.T. disk data
}
+export interface HostThermalState {
+ source?: string;
+ pressure?: 'nominal' | 'constrained' | 'unknown' | string;
+ thermalWarningLevel?: number;
+ performanceWarningLevel?: number;
+ cpuPowerStatus?: number;
+ limitsPercent?: Record<string, number>;
+}
+
export interface HostDiskSMART {
device: string; // Device name (e.g., sda)
model?: string; // Disk model
diff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.go
index 3bb395ece0..fd74b07f19 100644
--- a/internal/hostagent/agent.go
+++ b/internal/hostagent/agent.go
@@ -1026,6 +1026,8 @@ func (a *Agent) collectTemperatures(ctx context.Context) agentshost.Sensors {
switch a.collector.GOOS() {
case "linux":
// Continue below with lm-sensors path
+ case "darwin":
+ return a.collectDarwinThermalState(ctx)
case "freebsd":
return a.collectFreeBSDTemperatures(ctx)
default:
@@ -1128,6 +1130,174 @@ func convertTemperatureDataToSensors(tempData *sensors.TemperatureData) agentsho
return result
}
+// collectDarwinThermalState reads macOS thermal pressure signals. macOS does
+// not expose Linux-style raw temperature sensors through a stable unprivileged
+// interface, so this reports OS pressure state without inventing Celsius data.
+func (a *Agent) collectDarwinThermalState(ctx context.Context) agentshost.Sensors {
+ cmdCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
+ defer cancel()
+
+ output, err := a.collector.CommandCombinedOutput(cmdCtx, "pmset", "-g", "therm")
+ if err != nil {
+ a.logger.Debug().Err(err).Msg("Failed to collect macOS thermal state via pmset")
+ return agentshost.Sensors{}
+ }
+
+ state := parseDarwinPMSetThermalState(output)
+ if state == nil {
+ a.logger.Debug().Msg("No macOS thermal state available from pmset")
+ return agentshost.Sensors{}
+ }
+
+ a.logger.Debug().
+ Str("pressure", state.Pressure).
+ Int("limitCount", len(state.LimitsPercent)).
+ Msg("Collected macOS thermal state")
+
+ return agentshost.Sensors{ThermalState: state}
+}
+
+func parseDarwinPMSetThermalState(output string) *agentshost.ThermalState {
+ output = strings.TrimSpace(output)
+ if output == "" {
+ return nil
+ }
+
+ state := &agentshost.ThermalState{
+ Source: "pmset",
+ Pressure: agentshost.ThermalPressureUnknown,
+ }
+ seen := false
+ constrained := false
+ limits := make(map[string]int)
+
+ for _, rawLine := range strings.Split(output, "\n") {
+ line := strings.TrimSpace(rawLine)
+ if line == "" {
+ continue
+ }
+ lower := strings.ToLower(line)
+
+ switch {
+ case strings.Contains(lower, "no thermal warning level"):
+ state.ThermalWarningLevel = intPtr(0)
+ seen = true
+ continue
+ case strings.Contains(lower, "no performance warning level"):
+ state.PerformanceWarningLevel = intPtr(0)
+ seen = true
+ continue
+ case strings.Contains(lower, "no cpu power status"):
+ state.CPUPowerStatus = intPtr(0)
+ seen = true
+ continue
+ }
+
+ if value, ok := parseIntegerAfterMarker(line, "thermal warning level"); ok {
+ state.ThermalWarningLevel = intPtr(value)
+ seen = true
+ if value > 0 {
+ constrained = true
+ }
+ continue
+ }
+ if value, ok := parseIntegerAfterMarker(line, "performance warning level"); ok {
+ state.PerformanceWarningLevel = intPtr(value)
+ seen = true
+ if value > 0 {
+ constrained = true
+ }
+ continue
+ }
+ if value, ok := parseIntegerAfterMarker(line, "cpu power status"); ok {
+ state.CPUPowerStatus = intPtr(value)
+ seen = true
+ if value > 0 {
+ constrained = true
+ }
+ continue
+ }
+ if key, value, ok := parsePMSetLimitPercent(line); ok {
+ limits[key] = value
+ seen = true
+ if value >= 0 && value < 100 {
+ constrained = true
+ }
+ }
+ }
+
+ if !seen {
+ return nil
+ }
+ if len(limits) > 0 {
+ state.LimitsPercent = limits
+ }
+ if constrained {
+ state.Pressure = agentshost.ThermalPressureConstrained
+ } else {
+ state.Pressure = agentshost.ThermalPressureNominal
+ }
+ return state
+}
+
+func parsePMSetLimitPercent(line string) (string, int, bool) {
+ parts := strings.SplitN(line, "=", 2)
+ if len(parts) != 2 {
+ return "", 0, false
+ }
+ key := strings.TrimSpace(parts[0])
+ if key == "" || !strings.Contains(strings.ToLower(key), "limit") {
+ return "", 0, false
+ }
+ value, ok := parseFirstInteger(parts[1])
+ if !ok {
+ return "", 0, false
+ }
+ return normalizePMSetLimitKey(key), value, true
+}
+
+func normalizePMSetLimitKey(key string) string {
+ key = strings.TrimSpace(strings.ToLower(key))
+ replacer := strings.NewReplacer(" ", "_", "-", "_")
+ key = replacer.Replace(key)
+ for strings.Contains(key, "__") {
+ key = strings.ReplaceAll(key, "__", "_")
+ }
+ return strings.Trim(key, "_")
+}
+
+func parseIntegerAfterMarker(line, marker string) (int, bool) {
+ lower := strings.ToLower(line)
+ idx := strings.Index(lower, strings.ToLower(marker))
+ if idx < 0 {
+ return 0, false
+ }
+ return parseFirstInteger(line[idx+len(marker):])
+}
+
+func parseFirstInteger(input string) (int, bool) {
+ for i := 0; i < len(input); i++ {
+ ch := input[i]
+ if (ch < '0' || ch > '9') && ch != '-' {
+ continue
+ }
+ j := i + 1
+ for j < len(input) && input[j] >= '0' && input[j] <= '9' {
+ j++
+ }
+ value, err := strconv.Atoi(input[i:j])
+ if err != nil {
+ continue
+ }
+ return value, true
+ }
+ return 0, false
+}
+
+func intPtr(value int) *int {
+ return &value
+}
+
// collectFreeBSDTemperatures reads CPU and ACPI thermal zone temperatures
// from sysctl on FreeBSD. Returns an empty Sensors struct on any error.
func (a *Agent) collectFreeBSDTemperatures(ctx context.Context) agentshost.Sensors {
diff --git a/internal/hostagent/agent_metrics_test.go b/internal/hostagent/agent_metrics_test.go
index 3a1117edc6..30cfd9ec1d 100644
--- a/internal/hostagent/agent_metrics_test.go
+++ b/internal/hostagent/agent_metrics_test.go
@@ -390,6 +390,65 @@ rdevId.29=
})
}
+func TestBuildReportIncludesDarwinThermalState(t *testing.T) {
+ mc := &mockCollector{
+ goos: "darwin",
+ nowFn: func() time.Time { return time.Date(2026, 6, 14, 10, 0, 0, 0, time.UTC) },
+ hostInfoFn: func(ctx context.Context) (*gohost.InfoStat, error) {
+ return &gohost.InfoStat{
+ Hostname: "mac-mini",
+ OS: "darwin",
+ Platform: "darwin",
+ HostID: "mac-machine-id",
+ }, nil
+ },
+ hostUptimeFn: func(ctx context.Context) (uint64, error) {
+ return 3600, nil
+ },
+ metricsFn: func(ctx context.Context, diskExclude []string) (hostmetrics.Snapshot, error) {
+ return hostmetrics.Snapshot{}, nil
+ },
+ commandCombinedOutputFn: func(ctx context.Context, name string, arg ...string) (string, error) {
+ if name != "pmset" || len(arg) != 2 || arg[0] != "-g" || arg[1] != "therm" {
+ t.Fatalf("unexpected command %s %v", name, arg)
+ }
+ return "Thermal Warning Level: 1\nCPU_Speed_Limit = 72\n", nil
+ },
+ }
+
+ agent, err := New(Config{
+ AgentID: "mac-agent",
+ APIToken: "token",
+ LogLevel: -1,
+ Collector: mc,
+ })
+ if err != nil {
+ t.Fatalf("New() failed: %v", err)
+ }
+
+ report, err := agent.buildReport(context.Background())
+ if err != nil {
+ t.Fatalf("buildReport failed: %v", err)
+ }
+
+ if report.Sensors.ThermalState == nil {
+ t.Fatalf("expected Darwin thermal state in report, got %+v", report.Sensors)
+ }
+ state := report.Sensors.ThermalState
+ if state.Source != "pmset" || state.Pressure != agentshost.ThermalPressureConstrained {
+ t.Fatalf("unexpected thermal state: %+v", state)
+ }
+ if state.ThermalWarningLevel == nil || *state.ThermalWarningLevel != 1 {
+ t.Fatalf("thermal warning level = %+v, want 1", state.ThermalWarningLevel)
+ }
+ if got := state.LimitsPercent["cpu_speed_limit"]; got != 72 {
+ t.Fatalf("cpu_speed_limit = %d, want 72", got)
+ }
+ if len(report.Sensors.TemperatureCelsius) != 0 {
+ t.Fatalf("Darwin pressure-only report must not invent Celsius readings: %+v", report.Sensors.TemperatureCelsius)
+ }
+}
+
func TestBuildReportUsesResolvedNASOSIdentity(t *testing.T) {
fixedTime := time.Date(2026, time.April, 15, 12, 0, 0, 0, time.UTC)
diff --git a/internal/hostagent/agent_sensors_test.go b/internal/hostagent/agent_sensors_test.go
index 15916a498e..15148ed13a 100644
--- a/internal/hostagent/agent_sensors_test.go
+++ b/internal/hostagent/agent_sensors_test.go
@@ -76,13 +76,80 @@ func TestAgent_collectTemperatures_BestEffortFailuresReturnEmpty(t *testing.T) {
}
}
-func TestAgent_collectTemperatures_SkipsNonLinux(t *testing.T) {
- mc := &mockCollector{goos: "darwin"}
+func TestAgent_collectTemperatures_SkipsUnsupportedOS(t *testing.T) {
+ mc := &mockCollector{goos: "windows"}
a := &Agent{logger: zerolog.Nop(), collector: mc}
got := a.collectTemperatures(context.Background())
if len(got.TemperatureCelsius) != 0 {
- t.Fatalf("expected empty sensors on non-linux, got %#v", got.TemperatureCelsius)
+ t.Fatalf("expected empty sensors on unsupported OS, got %#v", got.TemperatureCelsius)
+ }
+}
+
+func TestAgent_collectTemperatures_DarwinThermalState(t *testing.T) {
+ mc := &mockCollector{
+ goos: "darwin",
+ commandCombinedOutputFn: func(_ context.Context, name string, arg ...string) (string, error) {
+ if name != "pmset" {
+ t.Fatalf("command name = %q, want pmset", name)
+ }
+ if len(arg) != 2 || arg[0] != "-g" || arg[1] != "therm" {
+ t.Fatalf("command args = %#v, want [-g therm]", arg)
+ }
+ return `Note: No thermal warning level has been recorded
+Note: No performance warning level has been recorded
+Note: No CPU power status has been recorded
+CPU_Speed_Limit = 100
+Scheduler_Limit = 100
+`, nil
+ },
+ }
+ a := &Agent{logger: zerolog.Nop(), collector: mc}
+
+ got := a.collectTemperatures(context.Background())
+ if len(got.TemperatureCelsius) != 0 {
+ t.Fatalf("expected no Celsius temperatures on macOS thermal-state collection, got %#v", got.TemperatureCelsius)
+ }
+ if got.ThermalState == nil {
+ t.Fatal("expected macOS thermal state")
+ }
+ if got.ThermalState.Source != "pmset" {
+ t.Fatalf("Source = %q, want pmset", got.ThermalState.Source)
+ }
+ if got.ThermalState.Pressure != "nominal" {
+ t.Fatalf("Pressure = %q, want nominal", got.ThermalState.Pressure)
+ }
+ if got.ThermalState.ThermalWarningLevel == nil || *got.ThermalState.ThermalWarningLevel != 0 {
+ t.Fatalf("ThermalWarningLevel = %#v, want 0", got.ThermalState.ThermalWarningLevel)
+ }
+ if got.ThermalState.LimitsPercent["cpu_speed_limit"] != 100 {
+ t.Fatalf("cpu_speed_limit = %d, want 100", got.ThermalState.LimitsPercent["cpu_speed_limit"])
+ }
+}
+
+func TestParseDarwinPMSetThermalState_Constrained(t *testing.T) {
+ got := parseDarwinPMSetThermalState(`Thermal Warning Level: 1
+Performance Warning Level: 2
+CPU Power Status: 1
+CPU_Speed_Limit = 80
+`)
+ if got == nil {
+ t.Fatal("expected thermal state")
+ }
+ if got.Pressure != "constrained" {
+ t.Fatalf("Pressure = %q, want constrained", got.Pressure)
+ }
+ if got.ThermalWarningLevel == nil || *got.ThermalWarningLevel != 1 {
+ t.Fatalf("ThermalWarningLevel = %#v, want 1", got.ThermalWarningLevel)
+ }
+ if got.PerformanceWarningLevel == nil || *got.PerformanceWarningLevel != 2 {
+ t.Fatalf("PerformanceWarningLevel = %#v, want 2", got.PerformanceWarningLevel)
+ }
+ if got.CPUPowerStatus == nil || *got.CPUPowerStatus != 1 {
+ t.Fatalf("CPUPowerStatus = %#v, want 1", got.CPUPowerStatus)
+ }
+ if got.LimitsPercent["cpu_speed_limit"] != 80 {
+ t.Fatalf("cpu_speed_limit = %d, want 80", got.LimitsPercent["cpu_speed_limit"])
}
}
diff --git a/internal/models/converters.go b/internal/models/converters.go
index 0611f78a45..8c8aef0ce3 100644
--- a/internal/models/converters.go
+++ b/internal/models/converters.go
@@ -839,7 +839,7 @@ func (s DockerSwarmInfo) ToFrontend() DockerSwarmFrontend {
}
func hostSensorSummaryToFrontend(src HostSensorSummary) *HostSensorSummaryFrontend {
- if len(src.TemperatureCelsius) == 0 && len(src.FanRPM) == 0 && len(src.Additional) == 0 && len(src.SMART) == 0 {
+ if len(src.TemperatureCelsius) == 0 && len(src.FanRPM) == 0 && len(src.Additional) == 0 && src.ThermalState == nil && len(src.SMART) == 0 {
return nil
}
@@ -853,6 +853,9 @@ func hostSensorSummaryToFrontend(src HostSensorSummary) *HostSensorSummaryFronte
if len(src.Additional) > 0 {
dest.Additional = copyStringFloatMap(src.Additional)
}
+ if src.ThermalState != nil {
+ dest.ThermalState = copyHostThermalState(src.ThermalState)
+ }
if len(src.SMART) > 0 {
dest.SMART = make([]HostDiskSMARTFrontend, len(src.SMART))
for i, disk := range src.SMART {
@@ -873,6 +876,18 @@ func hostSensorSummaryToFrontend(src HostSensorSummary) *HostSensorSummaryFronte
return &normalized
}
+func copyHostThermalState(src *HostThermalState) *HostThermalState {
+ if src == nil {
+ return nil
+ }
+ dest := *src
+ dest.ThermalWarningLevel = cloneIntPtr(src.ThermalWarningLevel)
+ dest.PerformanceWarningLevel = cloneIntPtr(src.PerformanceWarningLevel)
+ dest.CPUPowerStatus = cloneIntPtr(src.CPUPowerStatus)
+ dest.LimitsPercent = copyStringIntMap(src.LimitsPercent)
+ return &dest
+}
+
func copyStringFloatMap(src map[string]float64) map[string]float64 {
if len(src) == 0 {
return nil
@@ -884,6 +899,17 @@ func copyStringFloatMap(src map[string]float64) map[string]float64 {
return dest
}
+func copyStringIntMap(src map[string]int) map[string]int {
+ if len(src) == 0 {
+ return nil
+ }
+ dest := make(map[string]int, len(src))
+ for k, v := range src {
+ dest[k] = v
+ }
+ return dest
+}
+
func toDockerHostCommandFrontend(cmd DockerHostCommandStatus) *DockerHostCommandFrontend {
result := &DockerHostCommandFrontend{
ID: cmd.ID,
diff --git a/internal/models/converters_test.go b/internal/models/converters_test.go
index 050d2469fb..2648e66d15 100644
--- a/internal/models/converters_test.go
+++ b/internal/models/converters_test.go
@@ -618,6 +618,17 @@ func TestHostSensorSummaryToFrontend(t *testing.T) {
},
nilCheck: false,
},
+ {
+ name: "with thermal state",
+ input: HostSensorSummary{
+ ThermalState: &HostThermalState{
+ Source: "pmset",
+ Pressure: "nominal",
+ LimitsPercent: map[string]int{"cpu_speed_limit": 100},
+ },
+ },
+ nilCheck: false,
+ },
}
for _, tc := range tests {
@@ -632,6 +643,15 @@ func TestHostSensorSummaryToFrontend(t *testing.T) {
if result == nil {
t.Error("hostSensorSummaryToFrontend should not return nil for non-empty sensors")
}
+ if tc.input.ThermalState != nil {
+ if result.ThermalState == nil || result.ThermalState.Pressure != tc.input.ThermalState.Pressure {
+ t.Fatalf("thermal state not copied to frontend: %+v", result.ThermalState)
+ }
+ result.ThermalState.LimitsPercent["cpu_speed_limit"] = 80
+ if tc.input.ThermalState.LimitsPercent["cpu_speed_limit"] != 100 {
+ t.Fatal("frontend thermal state should not share limit map with source")
+ }
+ }
})
}
}
diff --git a/internal/models/deepcopy.go b/internal/models/deepcopy.go
index 2cf94cf717..47e39d12b2 100644
--- a/internal/models/deepcopy.go
+++ b/internal/models/deepcopy.go
@@ -67,6 +67,17 @@ func cloneStringFloat64Map(src map[string]float64) map[string]float64 {
return dest
}
+func cloneStringIntMap(src map[string]int) map[string]int {
+ if len(src) == 0 {
+ return nil
+ }
+ dest := make(map[string]int, len(src))
+ for k, v := range src {
+ dest[k] = v
+ }
+ return dest
+}
+
func cloneCoreTemps(src []CoreTemp) []CoreTemp {
return append([]CoreTemp(nil), src...)
}
@@ -218,10 +229,23 @@ func cloneHostSensorSummary(src HostSensorSummary) HostSensorSummary {
TemperatureCelsius: cloneStringFloat64Map(src.TemperatureCelsius),
FanRPM: cloneStringFloat64Map(src.FanRPM),
Additional: cloneStringFloat64Map(src.Additional),
+ ThermalState: cloneHostThermalState(src.ThermalState),
SMART: cloneHostDiskSMART(src.SMART),
}.NormalizeCollections()
}
+func cloneHostThermalState(src *HostThermalState) *HostThermalState {
+ if src == nil {
+ return nil
+ }
+ dest := *src
+ dest.ThermalWarningLevel = cloneIntPtr(src.ThermalWarningLevel)
+ dest.PerformanceWarningLevel = cloneIntPtr(src.PerformanceWarningLevel)
+ dest.CPUPowerStatus = cloneIntPtr(src.CPUPowerStatus)
+ dest.LimitsPercent = cloneStringIntMap(src.LimitsPercent)
+ return &dest
+}
+
func cloneHostRAIDArrays(src []HostRAIDArray) []HostRAIDArray {
if len(src) == 0 {
return nil
diff --git a/internal/models/deepcopy_test.go b/internal/models/deepcopy_test.go
index 6857496f24..fff6d83996 100644
--- a/internal/models/deepcopy_test.go
+++ b/internal/models/deepcopy_test.go
@@ -284,23 +284,38 @@ func TestCloneVM_NetworkIsolation(t *testing.T) {
// --- Host clone ---
func TestCloneHost_MapIsolation(t *testing.T) {
+ thermalWarningLevel := 0
src := Host{
ID: "host-1",
Hostname: "server1",
Tags: []string{"env:prod"},
Sensors: HostSensorSummary{
TemperatureCelsius: map[string]float64{"cpu": 42.0},
+ ThermalState: &HostThermalState{
+ Source: "pmset",
+ Pressure: "nominal",
+ ThermalWarningLevel: &thermalWarningLevel,
+ LimitsPercent: map[string]int{"cpu_speed_limit": 100},
+ },
},
}
dst := cloneHost(src)
dst.Tags = append(dst.Tags, "new:val")
dst.Sensors.TemperatureCelsius["gpu"] = 65.0
+ dst.Sensors.ThermalState.LimitsPercent["cpu_speed_limit"] = 80
+ *dst.Sensors.ThermalState.ThermalWarningLevel = 1
if len(src.Tags) != 1 {
t.Error("clone tags should be independent")
}
if _, ok := src.Sensors.TemperatureCelsius["gpu"]; ok {
t.Error("clone sensor map should be independent")
}
+ if src.Sensors.ThermalState.LimitsPercent["cpu_speed_limit"] != 100 {
+ t.Error("clone thermal limit map should be independent")
+ }
+ if *src.Sensors.ThermalState.ThermalWarningLevel != 0 {
+ t.Error("clone thermal warning pointer should be independent")
+ }
}
func TestCloneHosts_Nil(t *testing.T) {
diff --git a/internal/models/models.go b/internal/models/models.go
index 86e3b40d55..e7b59b7845 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -345,9 +345,19 @@ type HostSensorSummary struct {
TemperatureCelsius map[string]float64 `json:"temperatureCelsius,omitempty"`
FanRPM map[string]float64 `json:"fanRpm,omitempty"`
Additional map[string]float64 `json:"additional,omitempty"`
+ ThermalState *HostThermalState `json:"thermalState,omitempty"`
SMART []HostDiskSMART `json:"smart,omitempty"` // S.M.A.R.T. disk data
}
+type HostThermalState struct {
+ Source string `json:"source,omitempty"`
+ Pressure string `json:"pressure,omitempty"`
+ ThermalWarningLevel *int `json:"thermalWarningLevel,omitempty"`
+ PerformanceWarningLevel *int `json:"performanceWarningLevel,omitempty"`
+ CPUPowerStatus *int `json:"cpuPowerStatus,omitempty"`
+ LimitsPercent map[string]int `json:"limitsPercent,omitempty"`
+}
+
func (s HostSensorSummary) NormalizeCollections() HostSensorSummary {
if s.TemperatureCelsius == nil {
s.TemperatureCelsius = map[string]float64{}
diff --git a/internal/models/models_frontend.go b/internal/models/models_frontend.go
index 175127a246..4153cba9e2 100644
--- a/internal/models/models_frontend.go
+++ b/internal/models/models_frontend.go
@@ -750,6 +750,7 @@ type HostSensorSummaryFrontend struct {
TemperatureCelsius map[string]float64 `json:"temperatureCelsius"`
FanRPM map[string]float64 `json:"fanRpm"`
Additional map[string]float64 `json:"additional"`
+ ThermalState *HostThermalState `json:"thermalState,omitempty"`
SMART []HostDiskSMARTFrontend `json:"smart"` // S.M.A.R.T. disk data
}
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index f5dff83ebc..183b0b1679 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -3388,6 +3388,9 @@ func hostSensorsFromReadStateView(sensors *unifiedresources.HostSensorMeta) mode
out.Additional[k] = v
}
}
+ if sensors.ThermalState != nil {
+ out.ThermalState = hostThermalStateFromReadStateView(sensors.ThermalState)
+ }
if len(sensors.SMART) > 0 {
out.SMART = make([]models.HostDiskSMART, 0, len(sensors.SMART))
for _, smart := range sensors.SMART {
@@ -3408,6 +3411,20 @@ func hostSensorsFromReadStateView(sensors *unifiedresources.HostSensorMeta) mode
return out
}
+func hostThermalStateFromReadStateView(in *unifiedresources.HostThermalState) *models.HostThermalState {
+ if in == nil {
+ return nil
+ }
+ return &models.HostThermalState{
+ Source: in.Source,
+ Pressure: in.Pressure,
+ ThermalWarningLevel: cloneIntPtr(in.ThermalWarningLevel),
+ PerformanceWarningLevel: cloneIntPtr(in.PerformanceWarningLevel),
+ CPUPowerStatus: cloneIntPtr(in.CPUPowerStatus),
+ LimitsPercent: cloneStringIntMap(in.LimitsPercent),
+ }
+}
+
func hostRAIDFromReadStateView(raid []unifiedresources.HostRAIDMeta) []models.HostRAIDArray {
if len(raid) == 0 {
return nil
diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.go
index bffa2e61ab..58537ad6cc 100644
--- a/internal/monitoring/monitor_agents.go
+++ b/internal/monitoring/monitor_agents.go
@@ -1937,6 +1937,7 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.
TemperatureCelsius: cloneStringFloatMap(report.Sensors.TemperatureCelsius),
FanRPM: cloneStringFloatMap(report.Sensors.FanRPM),
Additional: cloneStringFloatMap(report.Sensors.Additional),
+ ThermalState: convertAgentThermalStateToModels(report.Sensors.ThermalState),
SMART: convertAgentSMARTToModels(report.Sensors.SMART),
},
RAID: raid,
@@ -2424,6 +2425,7 @@ func (m *Monitor) applyClusterSensors(entries []agentshost.ClusterNodeSensors, r
TemperatureCelsius: cloneStringFloatMap(entry.Sensors.TemperatureCelsius),
FanRPM: cloneStringFloatMap(entry.Sensors.FanRPM),
Additional: cloneStringFloatMap(entry.Sensors.Additional),
+ ThermalState: convertAgentThermalStateToModels(entry.Sensors.ThermalState),
},
updatedAt: reportTime,
}
diff --git a/internal/monitoring/monitor_helpers.go b/internal/monitoring/monitor_helpers.go
index e1151b9961..2b33ece148 100644
--- a/internal/monitoring/monitor_helpers.go
+++ b/internal/monitoring/monitor_helpers.go
@@ -197,6 +197,25 @@ func cloneStringFloatMap(src map[string]float64) map[string]float64 {
return out
}
+func cloneStringIntMap(src map[string]int) map[string]int {
+ if len(src) == 0 {
+ return nil
+ }
+ out := make(map[string]int, len(src))
+ for k, v := range src {
+ out[k] = v
+ }
+ return out
+}
+
+func cloneIntPtr(src *int) *int {
+ if src == nil {
+ return nil
+ }
+ out := *src
+ return &out
+}
+
func cloneStringMap(src map[string]string) map[string]string {
if len(src) == 0 {
return nil
@@ -595,6 +614,20 @@ func convertAgentSMARTToModels(smart []agentshost.DiskSMART) []models.HostDiskSM
return result
}
+func convertAgentThermalStateToModels(src *agentshost.ThermalState) *models.HostThermalState {
+ if src == nil {
+ return nil
+ }
+ return &models.HostThermalState{
+ Source: strings.TrimSpace(src.Source),
+ Pressure: strings.TrimSpace(src.Pressure),
+ ThermalWarningLevel: cloneIntPtr(src.ThermalWarningLevel),
+ PerformanceWarningLevel: cloneIntPtr(src.PerformanceWarningLevel),
+ CPUPowerStatus: cloneIntPtr(src.CPUPowerStatus),
+ LimitsPercent: cloneStringIntMap(src.LimitsPercent),
+ }
+}
+
// convertAgentSMARTAttributes converts agent SMARTAttributes to models SMARTAttributes.
func convertAgentSMARTAttributes(src *agentshost.SMARTAttributes) *models.SMARTAttributes {
if src == nil {
diff --git a/internal/monitoring/monitor_helpers_test.go b/internal/monitoring/monitor_helpers_test.go
index cb69b83c46..93c4ac41e2 100644
--- a/internal/monitoring/monitor_helpers_test.go
+++ b/internal/monitoring/monitor_helpers_test.go
@@ -256,6 +256,39 @@ func TestConvertAgentSMARTToModels_FullConversion(t *testing.T) {
}
}
+func TestConvertAgentThermalStateToModels_CopiesValues(t *testing.T) {
+ thermalWarningLevel := 0
+ performanceWarningLevel := 1
+ cpuPowerStatus := 2
+ src := &agentshost.ThermalState{
+ Source: " pmset ",
+ Pressure: " constrained ",
+ ThermalWarningLevel: &thermalWarningLevel,
+ PerformanceWarningLevel: &performanceWarningLevel,
+ CPUPowerStatus: &cpuPowerStatus,
+ LimitsPercent: map[string]int{"cpu_speed_limit": 80},
+ }
+
+ got := convertAgentThermalStateToModels(src)
+ if got == nil {
+ t.Fatal("expected converted thermal state")
+ }
+ if got.Source != "pmset" || got.Pressure != "constrained" {
+ t.Fatalf("unexpected source/pressure: %+v", got)
+ }
+ if got.ThermalWarningLevel == nil || *got.ThermalWarningLevel != 0 {
+ t.Fatalf("ThermalWarningLevel = %#v, want 0", got.ThermalWarningLevel)
+ }
+ got.LimitsPercent["cpu_speed_limit"] = 100
+ *got.PerformanceWarningLevel = 3
+ if src.LimitsPercent["cpu_speed_limit"] != 80 {
+ t.Fatal("converted thermal limits should not share source map")
+ }
+ if *src.PerformanceWarningLevel != 1 {
+ t.Fatal("converted thermal pointers should not share source pointers")
+ }
+}
+
// --- convertDockerSwarmInfo ---
func TestConvertDockerSwarmInfo_Nil(t *testing.T) {
diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.go
index fd71fd5b29..1d98abe6aa 100644
--- a/internal/monitoring/monitor_host_agents_test.go
+++ b/internal/monitoring/monitor_host_agents_test.go
@@ -492,6 +492,61 @@ func TestApplyHostReportAllowsTokenReuseAcrossHosts(t *testing.T) {
}
}
+func TestApplyHostReportPreservesThermalState(t *testing.T) {
+ monitor := &Monitor{
+ state: models.NewState(),
+ alertManager: alerts.NewManager(),
+ hostTokenBindings: make(map[string]string),
+ config: &config.Config{},
+ rateTracker: NewRateTracker(),
+ }
+ t.Cleanup(func() { monitor.alertManager.Stop() })
+
+ warningLevel := 1
+ report := agentshost.Report{
+ Agent: agentshost.AgentInfo{ID: "mac-agent", Version: "1.0.0", IntervalSeconds: 30},
+ Host: agentshost.HostInfo{
+ ID: "mac-machine",
+ Hostname: "mac-mini",
+ Platform: "macos",
+ },
+ Timestamp: time.Now().UTC(),
+ Sensors: agentshost.Sensors{
+ ThermalState: &agentshost.ThermalState{
+ Source: "pmset",
+ Pressure: agentshost.ThermalPressureConstrained,
+ ThermalWarningLevel: &warningLevel,
+ LimitsPercent: map[string]int{"cpu_speed_limit": 72},
+ },
+ },
+ }
+
+ host, err := monitor.ApplyHostReport(report, nil)
+ if err != nil {
+ t.Fatalf("ApplyHostReport: %v", err)
+ }
+ if host.Sensors.ThermalState == nil {
+ t.Fatalf("expected thermal state on applied host: %+v", host.Sensors)
+ }
+ report.Sensors.ThermalState.LimitsPercent["cpu_speed_limit"] = 99
+ *report.Sensors.ThermalState.ThermalWarningLevel = 2
+
+ snapshot := monitor.state.GetSnapshot()
+ if len(snapshot.Hosts) != 1 || snapshot.Hosts[0].Sensors.ThermalState == nil {
+ t.Fatalf("expected one host with thermal state, got %+v", snapshot.Hosts)
+ }
+ state := snapshot.Hosts[0].Sensors.ThermalState
+ if state.Pressure != agentshost.ThermalPressureConstrained {
+ t.Fatalf("pressure = %q, want constrained", state.Pressure)
+ }
+ if got := state.LimitsPercent["cpu_speed_limit"]; got != 72 {
+ t.Fatalf("thermal limit = %d, want copied value 72", got)
+ }
+ if state.ThermalWarningLevel == nil || *state.ThermalWarningLevel != 1 {
+ t.Fatalf("thermal warning level = %+v, want copied value 1", state.ThermalWarningLevel)
+ }
+}
+
func TestApplyDockerReportPreservesNativeRuntimeInventory(t *testing.T) {
monitor := newTestMonitor(t)
now := time.Date(2026, 5, 24, 8, 0, 0, 0, time.UTC)
diff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.go
index 43b6592c8d..2f56b5ed66 100644
--- a/internal/unifiedresources/adapters.go
+++ b/internal/unifiedresources/adapters.go
@@ -168,7 +168,7 @@ func resourceFromHost(host models.Host) (Resource, ResourceIdentity) {
storageAssessments := make([]storagehealth.Assessment, 0, len(host.RAID)+1)
// Populate sensors
- if len(host.Sensors.TemperatureCelsius) > 0 || len(host.Sensors.FanRPM) > 0 || len(host.Sensors.Additional) > 0 || len(host.Sensors.SMART) > 0 {
+ if len(host.Sensors.TemperatureCelsius) > 0 || len(host.Sensors.FanRPM) > 0 || len(host.Sensors.Additional) > 0 || host.Sensors.ThermalState != nil || len(host.Sensors.SMART) > 0 {
sensorMeta := &HostSensorMeta{}
if len(host.Sensors.TemperatureCelsius) > 0 {
sensorMeta.TemperatureCelsius = make(map[string]float64, len(host.Sensors.TemperatureCelsius))
@@ -188,6 +188,9 @@ func resourceFromHost(host models.Host) (Resource, ResourceIdentity) {
sensorMeta.Additional[k] = v
}
}
+ if host.Sensors.ThermalState != nil {
+ sensorMeta.ThermalState = hostThermalStateToMeta(host.Sensors.ThermalState)
+ }
if len(host.Sensors.SMART) > 0 {
sensorMeta.SMART = make([]HostSMARTMeta, len(host.Sensors.SMART))
for i, s := range host.Sensors.SMART {
@@ -435,6 +438,20 @@ func resourceFromHost(host models.Host) (Resource, ResourceIdentity) {
return resource, identity
}
+func hostThermalStateToMeta(in *models.HostThermalState) *HostThermalState {
+ if in == nil {
+ return nil
+ }
+ return &HostThermalState{
+ Source: in.Source,
+ Pressure: in.Pressure,
+ ThermalWarningLevel: cloneIntPtr(in.ThermalWarningLevel),
+ PerformanceWarningLevel: cloneIntPtr(in.PerformanceWarningLevel),
+ CPUPowerStatus: cloneIntPtr(in.CPUPowerStatus),
+ LimitsPercent: cloneStringIntMap(in.LimitsPercent),
+ }
+}
+
func agentRuntimePlatformForHost(host models.Host, hostProfile string) string {
return platformsupport.NormalizeRuntimePlatformForAgentHostProfile(hostProfile, host.Platform)
}
diff --git a/internal/unifiedresources/adapters_test.go b/internal/unifiedresources/adapters_test.go
index c25570a31b..9ab0c90dca 100644
--- a/internal/unifiedresources/adapters_test.go
+++ b/internal/unifiedresources/adapters_test.go
@@ -522,6 +522,39 @@ func TestResourceFromHostProjectsAgentHostProfile(t *testing.T) {
}
}
+func TestResourceFromHostProjectsPressureOnlyThermalState(t *testing.T) {
+ warningLevel := 1
+ host := models.Host{
+ ID: "mac-host",
+ Hostname: "mac-mini",
+ Platform: "macos",
+ Status: "online",
+ Sensors: models.HostSensorSummary{
+ ThermalState: &models.HostThermalState{
+ Source: "pmset",
+ Pressure: "constrained",
+ ThermalWarningLevel: &warningLevel,
+ LimitsPercent: map[string]int{"cpu_speed_limit": 72},
+ },
+ },
+ }
+
+ resource, _ := resourceFromHost(host)
+ if resource.Agent == nil || resource.Agent.Sensors == nil || resource.Agent.Sensors.ThermalState == nil {
+ t.Fatalf("expected host thermal state on agent resource, got %+v", resource.Agent)
+ }
+ state := resource.Agent.Sensors.ThermalState
+ if state.Source != "pmset" || state.Pressure != "constrained" {
+ t.Fatalf("unexpected thermal state: %+v", state)
+ }
+ if got := state.LimitsPercent["cpu_speed_limit"]; got != 72 {
+ t.Fatalf("thermal limit = %d, want 72", got)
+ }
+ if resource.Agent.Temperature != nil || len(resource.Agent.Sensors.TemperatureCelsius) != 0 {
+ t.Fatalf("pressure-only host must not create Celsius values: agent=%+v sensors=%+v", resource.Agent.Temperature, resource.Agent.Sensors)
+ }
+}
+
func TestResourceFromVMPreservesProxmoxPool(t *testing.T) {
vm := models.VM{
ID: "cluster-a:pve-a:101",
diff --git a/internal/unifiedresources/clone.go b/internal/unifiedresources/clone.go
index 087aea1705..2301ed6dc5 100644
--- a/internal/unifiedresources/clone.go
+++ b/internal/unifiedresources/clone.go
@@ -689,10 +689,23 @@ func cloneHostSensorMeta(in *HostSensorMeta) *HostSensorMeta {
out.TemperatureCelsius = cloneStringFloat64Map(in.TemperatureCelsius)
out.FanRPM = cloneStringFloat64Map(in.FanRPM)
out.Additional = cloneStringFloat64Map(in.Additional)
+ out.ThermalState = cloneHostThermalState(in.ThermalState)
out.SMART = cloneHostSMARTMetaSlice(in.SMART)
return &out
}
+func cloneHostThermalState(in *HostThermalState) *HostThermalState {
+ if in == nil {
+ return nil
+ }
+ out := *in
+ out.ThermalWarningLevel = cloneIntPtr(in.ThermalWarningLevel)
+ out.PerformanceWarningLevel = cloneIntPtr(in.PerformanceWarningLevel)
+ out.CPUPowerStatus = cloneIntPtr(in.CPUPowerStatus)
+ out.LimitsPercent = cloneStringIntMap(in.LimitsPercent)
+ return &out
+}
+
func cloneHostCephMeta(in *HostCephMeta) *HostCephMeta {
if in == nil {
return nil
@@ -1054,6 +1067,17 @@ func cloneStringFloat64Map(in map[string]float64) map[string]float64 {
return out
}
+func cloneStringIntMap(in map[string]int) map[string]int {
+ if in == nil {
+ return nil
+ }
+ out := make(map[string]int, len(in))
+ for k, v := range in {
+ out[k] = v
+ }
+ return out
+}
+
func cloneStringSlice(in []string) []string {
if in == nil {
return nil
@@ -1080,6 +1104,14 @@ func cloneStringPtr(in *string) *string {
return &out
}
+func cloneIntPtr(in *int) *int {
+ if in == nil {
+ return nil
+ }
+ out := *in
+ return &out
+}
+
func cloneInt64Ptr(in *int64) *int64 {
if in == nil {
return nil
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index 60fc10a176..4045a2a17a 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -249,6 +249,36 @@ func TestCloneResourceClonesDockerSecurityPosture(t *testing.T) {
}
}
+func TestCloneResourceCopiesHostThermalState(t *testing.T) {
+ warningLevel := 1
+ resource := Resource{
+ ID: "agent:mac-host",
+ Type: ResourceTypeAgent,
+ Agent: &AgentData{
+ Sensors: &HostSensorMeta{
+ ThermalState: &HostThermalState{
+ Source: "pmset",
+ Pressure: "constrained",
+ ThermalWarningLevel: &warningLevel,
+ LimitsPercent: map[string]int{"cpu_speed_limit": 72},
+ },
+ },
+ },
+ }
+
+ clone := cloneResource(&resource)
+ clone.Agent.Sensors.ThermalState.LimitsPercent["cpu_speed_limit"] = 95
+ *clone.Agent.Sensors.ThermalState.ThermalWarningLevel = 2
+
+ originalState := resource.Agent.Sensors.ThermalState
+ if got := originalState.LimitsPercent["cpu_speed_limit"]; got != 72 {
+ t.Fatalf("original thermal limit = %d, want 72 after clone mutation", got)
+ }
+ if originalState.ThermalWarningLevel == nil || *originalState.ThermalWarningLevel != 1 {
+ t.Fatalf("original thermal warning level = %+v, want 1 after clone mutation", originalState.ThermalWarningLevel)
+ }
+}
+
func TestProxmoxWorkloadActionTargetsStayBackendAuthored(t *testing.T) {
apiSource, err := os.ReadFile(filepath.Join("..", "api", "resources.go"))
if err != nil {
diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.go
index 9fd08af8db..8a8944d843 100644
--- a/internal/unifiedresources/types.go
+++ b/internal/unifiedresources/types.go
@@ -535,9 +535,19 @@ type HostSensorMeta struct {
TemperatureCelsius map[string]float64 `json:"temperatureCelsius,omitempty"`
FanRPM map[string]float64 `json:"fanRpm,omitempty"`
Additional map[string]float64 `json:"additional,omitempty"`
+ ThermalState *HostThermalState `json:"thermalState,omitempty"`
SMART []HostSMARTMeta `json:"smart,omitempty"`
}
+type HostThermalState struct {
+ Source string `json:"source,omitempty"`
+ Pressure string `json:"pressure,omitempty"`
+ ThermalWarningLevel *int `json:"thermalWarningLevel,omitempty"`
+ PerformanceWarningLevel *int `json:"performanceWarningLevel,omitempty"`
+ CPUPowerStatus *int `json:"cpuPowerStatus,omitempty"`
+ LimitsPercent map[string]int `json:"limitsPercent,omitempty"`
+}
+
// HostSMARTMeta describes a disk's SMART data.
type HostSMARTMeta struct {
Device string `json:"device"`
diff --git a/pkg/agents/host/report.go b/pkg/agents/host/report.go
index f552ef082f..7173613a86 100644
--- a/pkg/agents/host/report.go
+++ b/pkg/agents/host/report.go
@@ -119,9 +119,28 @@ type Sensors struct {
FanRPM map[string]float64 `json:"fanRpm,omitempty"`
PowerWatts map[string]float64 `json:"powerWatts,omitempty"` // Power consumption (e.g., cpu_package, dram)
Additional map[string]float64 `json:"additional,omitempty"`
+ ThermalState *ThermalState `json:"thermalState,omitempty"`
SMART []DiskSMART `json:"smart,omitempty"` // S.M.A.R.T. disk data
}
+// ThermalState captures OS-level thermal pressure that is not a direct
+// Celsius temperature reading. macOS exposes this kind of signal more
+// reliably than raw sensor temperatures.
+type ThermalState struct {
+ Source string `json:"source,omitempty"`
+ Pressure string `json:"pressure,omitempty"` // nominal, constrained, or unknown
+ ThermalWarningLevel *int `json:"thermalWarningLevel,omitempty"`
+ PerformanceWarningLevel *int `json:"performanceWarningLevel,omitempty"`
+ CPUPowerStatus *int `json:"cpuPowerStatus,omitempty"`
+ LimitsPercent map[string]int `json:"limitsPercent,omitempty"`
+}
+
+const (
+ ThermalPressureNominal = "nominal"
+ ThermalPressureConstrained = "constrained"
+ ThermalPressureUnknown = "unknown"
+)
+
// DiskSMART represents S.M.A.R.T. data for a single disk.
type DiskSMART struct {
Device string `json:"device"` // Block device name (e.g., sda, nvme0n1)
diff --git a/pkg/agents/host/report_test.go b/pkg/agents/host/report_test.go
index 2eb0292367..f5846afc10 100644
--- a/pkg/agents/host/report_test.go
+++ b/pkg/agents/host/report_test.go
@@ -184,6 +184,7 @@ func TestNetworkInterface_Fields(t *testing.T) {
}
func TestSensors_Fields(t *testing.T) {
+ thermalWarningLevel := 0
sensors := Sensors{
TemperatureCelsius: map[string]float64{
"cpu_package": 45.0,
@@ -196,6 +197,12 @@ func TestSensors_Fields(t *testing.T) {
Additional: map[string]float64{
"voltage": 12.0,
},
+ ThermalState: &ThermalState{
+ Source: "pmset",
+ Pressure: "nominal",
+ ThermalWarningLevel: &thermalWarningLevel,
+ LimitsPercent: map[string]int{"cpu_speed_limit": 100},
+ },
}
if len(sensors.TemperatureCelsius) != 3 {
@@ -207,6 +214,12 @@ func TestSensors_Fields(t *testing.T) {
if sensors.FanRPM["cpu_fan"] != 1200.0 {
t.Errorf("cpu_fan RPM = %f, want 1200.0", sensors.FanRPM["cpu_fan"])
}
+ if sensors.ThermalState == nil || sensors.ThermalState.Pressure != "nominal" {
+ t.Fatalf("ThermalState = %#v, want nominal state", sensors.ThermalState)
+ }
+ if sensors.ThermalState.LimitsPercent["cpu_speed_limit"] != 100 {
+ t.Errorf("cpu_speed_limit = %d, want 100", sensors.ThermalState.LimitsPercent["cpu_speed_limit"])
+ }
}
func TestRAIDArray_Fields(t *testing.T) {