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.

feat: Collect and display all lm-sensors data (fans, DDR5, etc.)

rcourtman7dd6c0d57a79
diff --git a/frontend-modern/src/components/Hosts/HostsOverview.tsx b/frontend-modern/src/components/Hosts/HostsOverview.tsx
index d8f08ed1c8..34f11cb913 100644
--- a/frontend-modern/src/components/Hosts/HostsOverview.tsx
+++ b/frontend-modern/src/components/Hosts/HostsOverview.tsx
@@ -157,27 +157,40 @@ function HostNetworkInfoCell(props: { networkInterfaces: NetworkInterface[] }) {
}
// Temperature cell with rich tooltip showing all sensor readings
-function HostTemperatureCell(props: { sensors: Record<string, number> | null | undefined }) {
+interface HostSensorSummaryForCell {
+ temperatureCelsius?: Record<string, number>;
+ fanRpm?: Record<string, number>;
+ additional?: Record<string, number>;
+}
+
+function HostTemperatureCell(props: { sensors: HostSensorSummaryForCell | null | undefined }) {
const [showTooltip, setShowTooltip] = createSignal(false);
const [tooltipPos, setTooltipPos] = createSignal({ x: 0, y: 0 });
// Get the primary (highest) temperature for display
const primaryTemp = createMemo(() => {
- if (!props.sensors) return null;
- const temps = Object.values(props.sensors);
+ if (!props.sensors?.temperatureCelsius) return null;
+ const temps = Object.values(props.sensors.temperatureCelsius);
if (temps.length === 0) return null;
// Find package/composite temp first, otherwise show max
- const keys = Object.keys(props.sensors);
+ const keys = Object.keys(props.sensors.temperatureCelsius);
const packageKey = keys.find(k =>
k.toLowerCase().includes('package') ||
k.toLowerCase().includes('composite') ||
k.toLowerCase().includes('tctl')
);
- if (packageKey) return props.sensors[packageKey];
+ if (packageKey) return props.sensors.temperatureCelsius[packageKey];
return Math.max(...temps);
});
- const hasSensors = () => props.sensors && Object.keys(props.sensors).length > 0;
+ const hasSensors = () => {
+ const temps = props.sensors?.temperatureCelsius;
+ const fans = props.sensors?.fanRpm;
+ const additional = props.sensors?.additional;
+ return (temps && Object.keys(temps).length > 0) ||
+ (fans && Object.keys(fans).length > 0) ||
+ (additional && Object.keys(additional).length > 0);
+ };
// Color based on temperature
const textColorClass = createMemo(() => {
@@ -199,9 +212,9 @@ function HostTemperatureCell(props: { sensors: Record<string, number> | null | u
};
// Sort sensors: package/composite first, then cores, then others
- const sortedSensors = createMemo(() => {
- if (!props.sensors) return [];
- return Object.entries(props.sensors).sort(([a], [b]) => {
+ const sortedTemps = createMemo(() => {
+ if (!props.sensors?.temperatureCelsius) return [];
+ return Object.entries(props.sensors.temperatureCelsius).sort(([a], [b]) => {
const aLower = a.toLowerCase();
const bLower = b.toLowerCase();
// Package/composite/tctl first
@@ -219,6 +232,26 @@ function HostTemperatureCell(props: { sensors: Record<string, number> | null | u
});
});
+ const sortedFans = createMemo(() => {
+ if (!props.sensors?.fanRpm) return [];
+ return Object.entries(props.sensors.fanRpm).sort(([a], [b]) => a.localeCompare(b));
+ });
+
+ const sortedAdditional = createMemo(() => {
+ if (!props.sensors?.additional) return [];
+ return Object.entries(props.sensors.additional).sort(([a], [b]) => a.localeCompare(b));
+ });
+
+ // Format sensor name for display (e.g., "nct6687_cpu_fan" -> "CPU Fan")
+ const formatSensorName = (name: string) => {
+ // Remove chip prefix (e.g., "nct6687_" or "coretemp_")
+ let clean = name.replace(/^[a-z]+\d*_/i, '');
+ // Replace underscores with spaces
+ clean = clean.replace(/_/g, ' ');
+ // Capitalize words
+ return clean.replace(/\b\w/g, c => c.toUpperCase());
+ };
+
return (
<>
<span
@@ -241,24 +274,63 @@ function HostTemperatureCell(props: { sensors: Record<string, number> | null | u
transform: 'translate(-50%, -100%)',
}}
>
- <div class="bg-gray-900 dark:bg-gray-800 text-white text-[10px] rounded-md shadow-lg px-2 py-1.5 min-w-[160px] max-w-[240px] border border-gray-700">
- <div class="font-medium mb-1 text-gray-300 border-b border-gray-700 pb-1">
- Temperature Sensors
- </div>
+ <div class="bg-gray-900 dark:bg-gray-800 text-white text-[10px] rounded-md shadow-lg px-2 py-1.5 min-w-[160px] max-w-[280px] border border-gray-700">
+ {/* Temperature section */}
+ <Show when={sortedTemps().length > 0}>
+ <div class="font-medium mb-1 text-gray-300 border-b border-gray-700 pb-1">
+ Temperatures
+ </div>
+ <div class="space-y-0.5 mb-2">
+ <For each={sortedTemps()}>
+ {([name, temp]) => {
+ const colorClass = temp >= 80 ? 'text-red-400' : temp >= 70 ? 'text-yellow-400' : 'text-gray-200';
+ return (
+ <div class="flex justify-between gap-3 py-0.5">
+ <span class="text-gray-400 truncate max-w-[140px]">{formatSensorName(name)}</span>
+ <span class={`font-medium font-mono ${colorClass}`}>{Math.round(temp)}°C</span>
+ </div>
+ );
+ }}
+ </For>
+ </div>
+ </Show>
- <div class="space-y-0.5">
- <For each={sortedSensors()}>
- {([name, temp]) => {
- const colorClass = temp >= 80 ? 'text-red-400' : temp >= 70 ? 'text-yellow-400' : 'text-gray-200';
- return (
+ {/* Fan speeds section */}
+ <Show when={sortedFans().length > 0}>
+ <div class="font-medium mb-1 text-gray-300 border-b border-gray-700 pb-1">
+ Fan Speeds
+ </div>
+ <div class="space-y-0.5 mb-2">
+ <For each={sortedFans()}>
+ {([name, rpm]) => (
<div class="flex justify-between gap-3 py-0.5">
- <span class="text-gray-400 truncate max-w-[120px]">{name}</span>
- <span class={`font-medium font-mono ${colorClass}`}>{Math.round(temp)}°C</span>
+ <span class="text-gray-400 truncate max-w-[140px]">{formatSensorName(name)}</span>
+ <span class="font-medium font-mono text-blue-300">{Math.round(rpm)} RPM</span>
</div>
- );
- }}
- </For>
- </div>
+ )}
+ </For>
+ </div>
+ </Show>
+
+ {/* Additional sensors section */}
+ <Show when={sortedAdditional().length > 0}>
+ <div class="font-medium mb-1 text-gray-300 border-b border-gray-700 pb-1">
+ Other Sensors
+ </div>
+ <div class="space-y-0.5">
+ <For each={sortedAdditional()}>
+ {([name, temp]) => {
+ const colorClass = temp >= 80 ? 'text-red-400' : temp >= 70 ? 'text-yellow-400' : 'text-gray-200';
+ return (
+ <div class="flex justify-between gap-3 py-0.5">
+ <span class="text-gray-400 truncate max-w-[140px]">{formatSensorName(name)}</span>
+ <span class={`font-medium font-mono ${colorClass}`}>{Math.round(temp)}°C</span>
+ </div>
+ );
+ }}
+ </For>
+ </div>
+ </Show>
</div>
</div>
</Portal>
@@ -1164,7 +1236,7 @@ const HostRow: Component<HostRowProps> = (props) => {
<Show when={props.isColVisible('temp')}>
<td class="px-2 py-1 align-middle">
<div class="flex justify-center">
- <HostTemperatureCell sensors={host.sensors?.temperatureCelsius} />
+ <HostTemperatureCell sensors={host.sensors} />
</div>
</td>
</Show>
diff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.go
index 4d9f8f3404..55575c0ca6 100644
--- a/internal/hostagent/agent.go
+++ b/internal/hostagent/agent.go
@@ -545,9 +545,27 @@ func (a *Agent) collectTemperatures(ctx context.Context) agentshost.Sensors {
result.TemperatureCelsius[gpuName] = temp
}
+ // Add fan speeds (RPM)
+ if len(tempData.Fans) > 0 {
+ result.FanRPM = make(map[string]float64)
+ for fanName, rpm := range tempData.Fans {
+ result.FanRPM[fanName] = rpm
+ }
+ }
+
+ // Add other temperatures (DDR5, motherboard, etc.)
+ if len(tempData.Other) > 0 {
+ result.Additional = make(map[string]float64)
+ for sensorName, temp := range tempData.Other {
+ result.Additional[sensorName] = temp
+ }
+ }
+
a.logger.Debug().
Int("temperatureCount", len(result.TemperatureCelsius)).
- Msg("Collected temperature data")
+ Int("fanCount", len(result.FanRPM)).
+ Int("additionalCount", len(result.Additional)).
+ Msg("Collected sensor data")
return result
}
diff --git a/internal/sensors/parser.go b/internal/sensors/parser.go
index 4f68353398..fefdaed29b 100644
--- a/internal/sensors/parser.go
+++ b/internal/sensors/parser.go
@@ -17,6 +17,8 @@ type TemperatureData struct {
Cores map[string]float64 // Per-core temperatures (e.g., "Core 0": 45.0)
NVMe map[string]float64 // NVMe drive temperatures (e.g., "nvme0": 42.0)
GPU map[string]float64 // GPU temperatures (e.g., "amdgpu-pci-0400": 55.0)
+ Fans map[string]float64 // Fan speeds in RPM (e.g., "cpu_fan": 1200)
+ Other map[string]float64 // Other temperatures (DDR5, mobo, etc.)
Available bool // Whether any temperature data was found
}
@@ -35,6 +37,8 @@ func Parse(jsonStr string) (*TemperatureData, error) {
Cores: make(map[string]float64),
NVMe: make(map[string]float64),
GPU: make(map[string]float64),
+ Fans: make(map[string]float64),
+ Other: make(map[string]float64),
}
foundCPUChip := false
@@ -66,6 +70,9 @@ func Parse(jsonStr string) (*TemperatureData, error) {
if strings.Contains(chipLower, "amdgpu") || strings.Contains(chipLower, "nouveau") {
parseGPUTemps(chipName, chipMap, data)
}
+
+ // Parse all fans and other temperatures from every chip
+ parseFansAndOther(chipName, chipMap, data)
}
// If we got CPU temps, calculate max from cores if package not available
@@ -96,7 +103,7 @@ func Parse(jsonStr string) (*TemperatureData, error) {
}
}
- data.Available = foundCPUChip || len(data.NVMe) > 0 || len(data.GPU) > 0
+ data.Available = foundCPUChip || len(data.NVMe) > 0 || len(data.GPU) > 0 || len(data.Fans) > 0 || len(data.Other) > 0
log.Debug().
Bool("available", data.Available).
@@ -105,6 +112,8 @@ func Parse(jsonStr string) (*TemperatureData, error) {
Int("coreCount", len(data.Cores)).
Int("nvmeCount", len(data.NVMe)).
Int("gpuCount", len(data.GPU)).
+ Int("fanCount", len(data.Fans)).
+ Int("otherCount", len(data.Other)).
Msg("Parsed temperature data")
return data, nil
@@ -281,3 +290,108 @@ func extractTempInput(sensorMap map[string]interface{}) float64 {
}
return math.NaN()
}
+
+// parseFansAndOther extracts fan speeds and other temperature readings from a sensor chip.
+// This captures DDR5/RAM temps, motherboard temps, additional NVMe sensors, fan speeds, etc.
+func parseFansAndOther(chipName string, chipMap map[string]interface{}, data *TemperatureData) {
+ chipLower := strings.ToLower(chipName)
+
+ for sensorName, sensorData := range chipMap {
+ sensorMap, ok := sensorData.(map[string]interface{})
+ if !ok {
+ continue
+ }
+
+ sensorNameLower := strings.ToLower(sensorName)
+
+ // Extract fan speeds (fan*_input fields report RPM)
+ for key, value := range sensorMap {
+ keyLower := strings.ToLower(key)
+
+ // Fan speed readings end in _input and are under fan* sensors
+ if strings.HasPrefix(keyLower, "fan") && strings.HasSuffix(keyLower, "_input") {
+ rpm := extractNumericValue(value)
+ if rpm > 0 {
+ // Create a readable key: chipName_sensorName (e.g., "nct6687_cpu_fan")
+ fanKey := normalizeSensorKey(chipName, sensorName)
+ data.Fans[fanKey] = rpm
+ log.Debug().
+ Str("chip", chipName).
+ Str("sensor", sensorName).
+ Float64("rpm", rpm).
+ Msg("Found fan speed")
+ }
+ }
+ }
+
+ // Skip sensors we've already handled in specific parsers
+ if isCPUChip(chipLower) {
+ // Skip CPU temps - already handled
+ if strings.Contains(sensorName, "Package") ||
+ strings.Contains(sensorName, "Core ") ||
+ strings.Contains(sensorNameLower, "tdie") ||
+ strings.Contains(sensorNameLower, "tctl") ||
+ strings.HasPrefix(sensorName, "Tccd") ||
+ strings.Contains(sensorNameLower, "cputin") {
+ continue
+ }
+ }
+
+ if strings.Contains(chipLower, "nvme") && strings.Contains(sensorName, "Composite") {
+ continue // Already handled
+ }
+
+ if (strings.Contains(chipLower, "amdgpu") || strings.Contains(chipLower, "nouveau")) &&
+ (strings.Contains(sensorNameLower, "edge") ||
+ strings.Contains(sensorNameLower, "junction") ||
+ strings.Contains(sensorNameLower, "mem")) {
+ continue // Already handled as GPU temps
+ }
+
+ // Extract other temperature readings (DDR5, motherboard, etc.)
+ tempVal := extractTempInput(sensorMap)
+ if !math.IsNaN(tempVal) && tempVal > 0 && tempVal < 150 { // Sanity check: 0-150°C range
+ tempKey := normalizeSensorKey(chipName, sensorName)
+ // Avoid duplicating temps already in other maps
+ if _, exists := data.Other[tempKey]; !exists {
+ data.Other[tempKey] = tempVal
+ log.Debug().
+ Str("chip", chipName).
+ Str("sensor", sensorName).
+ Float64("temp", tempVal).
+ Msg("Found other temperature")
+ }
+ }
+ }
+}
+
+// normalizeSensorKey creates a readable, normalized key from chip and sensor names.
+// e.g., "nct6687-isa-0a20" + "CPU Fan" -> "nct6687_cpu_fan"
+func normalizeSensorKey(chipName, sensorName string) string {
+ // Strip the address suffix from chip names (e.g., "-isa-0a20", "-pci-0400")
+ chipClean := chipName
+ if idx := strings.Index(chipName, "-"); idx > 0 {
+ // Keep just the chip type (e.g., "nct6687", "amdgpu")
+ chipClean = chipName[:idx]
+ }
+
+ // Normalize sensor name: lowercase, replace spaces with underscores
+ sensorClean := strings.ToLower(sensorName)
+ sensorClean = strings.ReplaceAll(sensorClean, " ", "_")
+ sensorClean = strings.ReplaceAll(sensorClean, "-", "_")
+
+ return fmt.Sprintf("%s_%s", strings.ToLower(chipClean), sensorClean)
+}
+
+// extractNumericValue extracts a numeric value from an interface{}
+func extractNumericValue(value interface{}) float64 {
+ switch v := value.(type) {
+ case float64:
+ return v
+ case int:
+ return float64(v)
+ case int64:
+ return float64(v)
+ }
+ return 0
+}
diff --git a/internal/sensors/parser_test.go b/internal/sensors/parser_test.go
index ac8949f425..6803ae9663 100644
--- a/internal/sensors/parser_test.go
+++ b/internal/sensors/parser_test.go
@@ -268,7 +268,7 @@ func TestParse_EmptyObject(t *testing.T) {
}
func TestParse_NoRecognizedSensors(t *testing.T) {
- // JSON with unknown sensor types
+ // JSON with unknown sensor types - should still be captured in Other map
unknownJSON := `{
"unknown-chip-0000": {
"Adapter": "Unknown adapter",
@@ -281,8 +281,19 @@ func TestParse_NoRecognizedSensors(t *testing.T) {
t.Fatalf("Parse() error: %v", err)
}
- if data.Available {
- t.Error("Expected Available to be false for unknown sensors")
+ // Unknown sensors should now be captured in Other, making data available
+ if !data.Available {
+ t.Error("Expected Available to be true for sensors in Other map")
+ }
+
+ if len(data.Other) != 1 {
+ t.Errorf("len(Other) = %d, want 1", len(data.Other))
+ }
+
+ // Check that the sensor was captured with normalized key
+ expectedKey := "unknown_some_sensor"
+ if data.Other[expectedKey] != 50.0 {
+ t.Errorf("Other[%s] = %v, want 50.0", expectedKey, data.Other[expectedKey])
}
}