add rpi cpu temp support
This commit is contained in:
parent
96b8a1277e
commit
f0593cf132
@ -287,7 +287,7 @@ sub _get_cpu_name {
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
@ -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 };
|
||||
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);
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# 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
|
||||
# ============================================================================
|
||||
|
||||
@ -296,6 +296,7 @@ Ext.define('PVE.node.StatusView', {
|
||||
|
||||
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 cpuKeysRpi = Object.keys(objValue).filter(item => String(item).startsWith('cpu_thermal-virtual-')).sort();
|
||||
const bINTEL = cpuKeysI.length > 0 ? true : false;
|
||||
const INTELPackagePrefix = 'Core' == 'Core' ? 'Core ' : 'Package id';
|
||||
const INTELPackageCaption = 'Core' == 'Core' ? 'Core' : 'Package';
|
||||
@ -332,9 +333,9 @@ Ext.define('PVE.node.StatusView', {
|
||||
}
|
||||
}
|
||||
|
||||
const cpuKeys = bINTEL ? cpuKeysI : cpuKeysA;
|
||||
const cpuItemPrefix = bINTEL ? INTELPackagePrefix : AMDPackagePrefix;
|
||||
const cpuTempCaption = bINTEL ? INTELPackageCaption : AMDPackageCaption;
|
||||
const cpuKeys = bINTEL ? cpuKeysI : cpuKeysA.length > 0 ? cpuKeysA : cpuKeysRpi;
|
||||
const cpuItemPrefix = bINTEL ? INTELPackagePrefix : cpuKeysA.length > 0 ? AMDPackagePrefix : 'temp';
|
||||
const cpuTempCaption = bINTEL ? INTELPackageCaption : cpuKeysA.length > 0 ? AMDPackageCaption : 'Temp';
|
||||
const formatTemp = bINTEL ? '0' : '0.0';
|
||||
const cpuCount = cpuKeys.length;
|
||||
let temps = [];
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
# node_info_write_conf — write /etc/pve-mod/conf.d/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 ---------------------------------------------------------------
|
||||
|
||||
@ -191,15 +191,25 @@ node_info_configure() {
|
||||
if [[ "$ENABLE_CPU" -eq 1 ]]; then
|
||||
info "Detected CPU sensors ($cpuCount): $cpuList"
|
||||
sensors_detected=true
|
||||
while true; do
|
||||
local choice
|
||||
choice=$(ask "Display temperatures for all cores [C] or average per CPU [a]? (C/a)")
|
||||
case "$choice" in
|
||||
[cC]|"") CPU_TEMP_TARGET="Core"; info "Showing per-core temperatures."; break ;;
|
||||
[aA]) CPU_TEMP_TARGET="Package"; info "Showing average per-CPU temperature."; break ;;
|
||||
*) warn "Invalid input, choose C or a." ;;
|
||||
esac
|
||||
done
|
||||
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
|
||||
local choice
|
||||
choice=$(ask "Display temperatures for all cores [C] or average per CPU [a]? (C/a)")
|
||||
case "$choice" in
|
||||
[cC]|"") CPU_TEMP_TARGET="Core"; info "Showing per-core temperatures."; break ;;
|
||||
[aA]) CPU_TEMP_TARGET="Package"; info "Showing average per-CPU temperature."; break ;;
|
||||
*) warn "Invalid input, choose C or a." ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
else
|
||||
warn "No CPU temperature sensors found."
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user