add rpi cpu temp support (#226)

* add rpi cpu temp support

* change render to SOC

---------

Co-authored-by: Meliox <na>
This commit is contained in:
Meliox 2026-07-05 12:13:24 +02:00 committed by GitHub
parent 96b8a1277e
commit 0855a19cc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 14 deletions

View File

@ -287,7 +287,7 @@ sub _get_cpu_name {
} }
my @entries = my @entries =
grep { /^coretemp-isa-/ || /^k10temp-pci-/ } keys %{$sensors_data}; grep { /^coretemp-isa-/ || /^k10temp-pci-/ || /^cpu_thermal-virtual-/ } keys %{$sensors_data};
debug(__LINE__, "Found " . scalar(@entries) . " CPU entries in sensors output"); debug(__LINE__, "Found " . scalar(@entries) . " CPU entries in sensors output");
@ -364,6 +364,13 @@ sub _get_cpu_name {
} }
} }
# ----- Raspberry Pi cpu_thermal -----
elsif ($entry =~ /^cpu_thermal-virtual-/) {
$pkg = 0;
$cpu_model = _rpi_cpu_model();
debug(__LINE__, "Found RPi CPU: $entry -> Model: $cpu_model");
}
$cache_ref->{$entry} = { model => $cpu_model, package => $pkg }; $cache_ref->{$entry} = { model => $cpu_model, package => $pkg };
debug(__LINE__, "CPU: $entry -> Package $pkg (Model: $cpu_model)"); debug(__LINE__, "CPU: $entry -> Package $pkg (Model: $cpu_model)");
} }
@ -378,6 +385,27 @@ sub _get_cpu_name {
return JSON->new->pretty->canonical->encode($sensors_data); return JSON->new->pretty->canonical->encode($sensors_data);
} }
# ============================================================================
# Raspberry Pi model lookup helper
# ============================================================================
sub _rpi_cpu_model {
for my $field ('Model', 'Hardware') {
if (open my $fh, '<', '/proc/cpuinfo') {
while (my $line = <$fh>) {
chomp $line;
if ($line =~ /^$field\s*:\s*(.+)$/) {
close $fh;
(my $model = $1) =~ s/^\s+|\s+$//g;
return $model;
}
}
close $fh;
}
}
return "Raspberry Pi";
}
# ============================================================================ # ============================================================================
# CPU model lookup helper # CPU model lookup helper
# ============================================================================ # ============================================================================

View File

@ -296,6 +296,7 @@ Ext.define('PVE.node.StatusView', {
const cpuKeysI = Object.keys(objValue).filter(item => String(item).startsWith('coretemp-isa-')).sort(); const cpuKeysI = Object.keys(objValue).filter(item => String(item).startsWith('coretemp-isa-')).sort();
const cpuKeysA = Object.keys(objValue).filter(item => String(item).startsWith('k10temp-pci-')).sort(); const cpuKeysA = Object.keys(objValue).filter(item => String(item).startsWith('k10temp-pci-')).sort();
const cpuKeysRpi = Object.keys(objValue).filter(item => String(item).startsWith('cpu_thermal-virtual-')).sort();
const bINTEL = cpuKeysI.length > 0 ? true : false; const bINTEL = cpuKeysI.length > 0 ? true : false;
const INTELPackagePrefix = 'Core' == 'Core' ? 'Core ' : 'Package id'; const INTELPackagePrefix = 'Core' == 'Core' ? 'Core ' : 'Package id';
const INTELPackageCaption = 'Core' == 'Core' ? 'Core' : 'Package'; const INTELPackageCaption = 'Core' == 'Core' ? 'Core' : 'Package';
@ -332,9 +333,9 @@ Ext.define('PVE.node.StatusView', {
} }
} }
const cpuKeys = bINTEL ? cpuKeysI : cpuKeysA; const cpuKeys = bINTEL ? cpuKeysI : cpuKeysA.length > 0 ? cpuKeysA : cpuKeysRpi;
const cpuItemPrefix = bINTEL ? INTELPackagePrefix : AMDPackagePrefix; const cpuItemPrefix = bINTEL ? INTELPackagePrefix : cpuKeysA.length > 0 ? AMDPackagePrefix : 'temp';
const cpuTempCaption = bINTEL ? INTELPackageCaption : AMDPackageCaption; const cpuTempCaption = bINTEL ? INTELPackageCaption : cpuKeysA.length > 0 ? AMDPackageCaption : 'SoC';
const formatTemp = bINTEL ? '0' : '0.0'; const formatTemp = bINTEL ? '0' : '0.0';
const cpuCount = cpuKeys.length; const cpuCount = cpuKeys.length;
let temps = []; let temps = [];

View File

@ -12,7 +12,7 @@
# node_info_write_conf — write /etc/pve-mod/conf.d/node_info.conf # node_info_write_conf — write /etc/pve-mod/conf.d/node_info.conf
NODE_INFO_CONF="${CONFD_DIR}/node_info.conf" NODE_INFO_CONF="${CONFD_DIR}/node_info.conf"
KNOWN_CPU_SENSORS=("coretemp-isa-" "k10temp-pci-") KNOWN_CPU_SENSORS=("coretemp-isa-" "k10temp-pci-" "cpu_thermal-virtual-")
# --- utilities --------------------------------------------------------------- # --- utilities ---------------------------------------------------------------
@ -191,6 +191,15 @@ node_info_configure() {
if [[ "$ENABLE_CPU" -eq 1 ]]; then if [[ "$ENABLE_CPU" -eq 1 ]]; then
info "Detected CPU sensors ($cpuCount): $cpuList" info "Detected CPU sensors ($cpuCount): $cpuList"
sensors_detected=true sensors_detected=true
local bRpiOnly=false
if [[ "$cpuList" == *"cpu_thermal-virtual-"* ]] && \
[[ "$cpuList" != *"coretemp-isa-"* ]] && \
[[ "$cpuList" != *"k10temp-pci-"* ]]; then
bRpiOnly=true
fi
if [[ "$bRpiOnly" == true ]]; then
CPU_TEMP_TARGET="Core"
else
while true; do while true; do
local choice local choice
choice=$(ask "Display temperatures for all cores [C] or average per CPU [a]? (C/a)") choice=$(ask "Display temperatures for all cores [C] or average per CPU [a]? (C/a)")
@ -200,6 +209,7 @@ node_info_configure() {
*) warn "Invalid input, choose C or a." ;; *) warn "Invalid input, choose C or a." ;;
esac esac
done done
fi
else else
warn "No CPU temperature sensors found." warn "No CPU temperature sensors found."
fi fi