feat(node_info) Add configurable minimum-temperature ignore threshold (#316)

Co-authored-by: Meliox <na>
This commit is contained in:
Meliox 2026-08-23 00:30:51 +02:00 committed by GitHub
parent 0476410de5
commit 2a122ef3eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 58 additions and 25 deletions

View File

@ -97,8 +97,9 @@ sub _get_temperature_sensors {
fans => $config{lm_sensors}{enable_fan_speed} ? \1 : \0,
hdd => $config{lm_sensors}{enable_hdd_temp} ? \1 : \0,
other => $config{lm_sensors}{enable_other_temp} ? \1 : \0,
temp_unit => $config{lm_sensors}{temp_unit},
temp_unit => $config{system_info}{temp_unit},
cpu_temp_target => $config{lm_sensors}{cpu_temp_target},
ignore_temp_below => $config{system_info}{ignore_temp_below} + 0,
data => { 'PVE MOD lm-sensors Enhanced' => $sensors_json },
});

View File

@ -72,7 +72,6 @@ our %config = (
enable_other_temp => 0,
enable_fan_speed => 0,
display_zero_speed_fans => 0,
temp_unit => 'C',
},
ups => {
enabled => 0,
@ -81,6 +80,8 @@ our %config = (
system_info => {
enabled => 0,
type => 1, # 1 = System (dmidecode -t 1), 2 = Baseboard/Motherboard (dmidecode -t 2)
temp_unit => 'C',
ignore_temp_below => 5,
},
paths => {
working_dir => '/run/pveproxy/pve-mod',

View File

@ -71,7 +71,8 @@ sub _merge_graphics_files {
Intel => {},
NVIDIA => {},
AMD => {},
temp_unit => $config{lm_sensors}{temp_unit},
temp_unit => $config{system_info}{temp_unit},
ignore_temp_below => $config{system_info}{ignore_temp_below} + 0,
}
};
@ -135,7 +136,7 @@ sub _load_graphics_data {
\@filepaths,
$graphics_cache,
\&_merge_graphics_files,
{ Graphics => { Intel => {}, NVIDIA => {}, AMD => {}, temp_unit => $config{lm_sensors}{temp_unit} } }
{ Graphics => { Intel => {}, NVIDIA => {}, AMD => {}, temp_unit => $config{system_info}{temp_unit}, ignore_temp_below => $config{system_info}{ignore_temp_below} + 0 } }
);
my $intel_count = scalar(keys %{$data->{Graphics}{Intel} // {}});

View File

@ -226,6 +226,7 @@ Ext.define('PVE.node.StatusView', {
this.show();
// sensors configuration
const cpuTempHelper = Ext.create('PVE.mod.TempHelper', {srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: value.temp_unit === 'F' ? PVE.mod.TempHelper.FAHRENHEIT : PVE.mod.TempHelper.CELSIUS});
const cpuIgnoreThreshold = cpuTempHelper.getTemp(parseFloat(value.ignore_temp_below));
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();
@ -305,7 +306,7 @@ Ext.define('PVE.node.StatusView', {
}
});
if (!isNaN(tempVal)) {
if (!isNaN(tempVal) && tempVal >= cpuIgnoreThreshold) {
let tempStyle = '';
if (!isNaN(tempMax) && tempVal >= tempMax) {
tempStyle = 'color: #FFC300; font-weight: bold;';
@ -484,6 +485,8 @@ Ext.define('PVE.node.StatusView', {
// Temperature
if (stats.temperature) {
const gpuTemp = gpuTempHelper.getTemp(parseFloat(stats.temperature.gpu));
const gpuIgnoreThreshold = gpuTempHelper.getTemp(parseFloat(gpuStats.ignore_temp_below));
if (gpuTemp >= gpuIgnoreThreshold) {
const tempUnit = gpuTempHelper.getUnit();
// Convert thresholds to target unit for comparison
const tempHigh = gpuTempHelper.getTemp(80);
@ -496,6 +499,7 @@ Ext.define('PVE.node.StatusView', {
}
details.push(`Temp: <span style="${tempStyle}">${Ext.util.Format.number(gpuTemp, '0')}${tempUnit}</span>`);
}
}
// Power
if (stats.power) {
@ -546,6 +550,7 @@ Ext.define('PVE.node.StatusView', {
}
this.show();
const tempHelper = Ext.create('PVE.mod.TempHelper', {srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: value.temp_unit === 'F' ? PVE.mod.TempHelper.FAHRENHEIT : PVE.mod.TempHelper.CELSIUS});
const ignoreThreshold = tempHelper.getTemp(parseFloat(value.ignore_temp_below));
const drvKeys = Object.keys(objValue).filter(item => String(item).startsWith(addressPrefix)).sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }));
let drvData = [];
drvKeys.forEach((drvKey) => {
@ -561,7 +566,7 @@ Ext.define('PVE.node.StatusView', {
tempCrit = tempHelper.getTemp(parseFloat(drv[sensorName][secondLevelKey]));
}
});
if (!isNaN(tempVal)) {
if (!isNaN(tempVal) && tempVal >= ignoreThreshold) {
let tempStyle = '';
if (!isNaN(tempMax) && tempVal >= tempMax) {
tempStyle = 'color: #FFC300; font-weight: bold;';
@ -627,6 +632,7 @@ Ext.define('PVE.node.StatusView', {
}
this.show();
const tempHelper = Ext.create('PVE.mod.TempHelper', {srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: value.temp_unit === 'F' ? PVE.mod.TempHelper.FAHRENHEIT : PVE.mod.TempHelper.CELSIUS});
const ignoreThreshold = tempHelper.getTemp(parseFloat(value.ignore_temp_below));
const nvmeKeys = Object.keys(objValue).filter(item => String(item).startsWith(addressPrefix)).sort();
let nvmeData = [];
nvmeKeys.forEach((nvmeKey, index) => {
@ -644,7 +650,7 @@ Ext.define('PVE.node.StatusView', {
model = objValue[nvmeKey]['model'] || 'Unknown';
serial = objValue[nvmeKey]['serial'] || '';
if (!isNaN(tempVal)) {
if (!isNaN(tempVal) && tempVal >= ignoreThreshold) {
let tempStyle = '';
if (!isNaN(tempMax) && tempVal >= tempMax) {
tempStyle = 'color: #FFC300; font-weight: bold;';
@ -716,6 +722,7 @@ Ext.define('PVE.node.StatusView', {
}
this.show();
const tempHelper = Ext.create('PVE.mod.TempHelper', {srcUnit: PVE.mod.TempHelper.CELSIUS, dstUnit: value.temp_unit === 'F' ? PVE.mod.TempHelper.FAHRENHEIT : PVE.mod.TempHelper.CELSIUS});
const ignoreThreshold = tempHelper.getTemp(parseFloat(value.ignore_temp_below));
// Keep only keys that do not belong to known categories
const otherKeys = Object.keys(objValue).filter(key =>
@ -750,7 +757,7 @@ Ext.define('PVE.node.StatusView', {
}
});
if (!isNaN(tempVal)) {
if (!isNaN(tempVal) && tempVal >= ignoreThreshold) {
let tempStyle = '';
if (!isNaN(tempMax) && tempVal >= tempMax) {
tempStyle = 'color: #FFC300; font-weight: bold;';

View File

@ -17,7 +17,6 @@ enable_hdd_temp=0
enable_nvme_temp=0
enable_fan_speed=0
display_zero_speed_fans=0
temp_unit=C
[ups]
enabled=0
@ -26,6 +25,8 @@ device_name=ups@localhost
[system_info]
enabled=0
type=1
temp_unit=C
ignore_temp_below=5
# Debug mode: when a collector's mode is 1, the real tool is not required.
# Data is read from the file path instead. Useful for development/testing.

View File

@ -65,11 +65,11 @@ node_info_defaults() {
LM_SENSORS_ENABLED=0
ENABLE_CPU=0; CPU_TEMP_TARGET="Core"
ENABLE_RAM_TEMP=0; ENABLE_HDD_TEMP=0; ENABLE_NVME_TEMP=0; ENABLE_OTHER_TEMP=0
ENABLE_FAN_SPEED=0; DISPLAY_ZERO_SPEED_FANS=0; TEMP_UNIT="C"
ENABLE_FAN_SPEED=0; DISPLAY_ZERO_SPEED_FANS=0
ENABLE_INTEL_GPU_INFO=0; ENABLE_NVIDIA_GPU_INFO=0; ENABLE_AMD_GPU_INFO=0
ENABLE_GPU_HISTORY=0
ENABLE_UPS=0; UPS_DEVICE_NAME="ups@localhost"
ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1
ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1; TEMP_UNIT="C"; IGNORE_TEMP_BELOW=5
DEBUG_LM_SENSORS=0; DEBUG_LM_SENSORS_FILE="/tmp/sensors-output.json"
DEBUG_INTEL=0; DEBUG_INTEL_FILE="/tmp/intel-gpu-devices.txt"
DEBUG_INTEL_OUTPUT_FILE="/tmp/intel-gpu-top-output.txt"
@ -104,11 +104,12 @@ node_info_load_conf() {
lm_sensors.enable_other_temp) ENABLE_OTHER_TEMP="$val" ;;
lm_sensors.enable_fan_speed) ENABLE_FAN_SPEED="$val" ;;
lm_sensors.display_zero_speed_fans) DISPLAY_ZERO_SPEED_FANS="$val" ;;
lm_sensors.temp_unit) TEMP_UNIT="$val" ;;
ups.enabled) ENABLE_UPS="$val" ;;
ups.device_name) UPS_DEVICE_NAME="$val" ;;
system_info.enabled) ENABLE_SYSTEM_INFO="$val" ;;
system_info.type) SYSTEM_INFO_TYPE="$val" ;;
system_info.temp_unit) TEMP_UNIT="$val" ;;
system_info.ignore_temp_below) IGNORE_TEMP_BELOW="$val" ;;
debug.lm_sensors_mode) DEBUG_LM_SENSORS="$val" ;;
debug.lm_sensors_output_file) DEBUG_LM_SENSORS_FILE="$val" ;;
debug.intel_mode) DEBUG_INTEL="$val" ;;
@ -133,11 +134,11 @@ node_info_configure() {
LM_SENSORS_ENABLED=0
ENABLE_CPU=0; CPU_TEMP_TARGET="Core"
ENABLE_RAM_TEMP=0; ENABLE_HDD_TEMP=0; ENABLE_NVME_TEMP=0; ENABLE_OTHER_TEMP=0
ENABLE_FAN_SPEED=0; DISPLAY_ZERO_SPEED_FANS=0; TEMP_UNIT="C"
ENABLE_FAN_SPEED=0; DISPLAY_ZERO_SPEED_FANS=0
ENABLE_INTEL_GPU_INFO=0; ENABLE_NVIDIA_GPU_INFO=0; ENABLE_AMD_GPU_INFO=0
ENABLE_GPU_HISTORY=0
ENABLE_UPS=0; UPS_DEVICE_NAME="ups@localhost"
ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1
ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1; TEMP_UNIT="C"; IGNORE_TEMP_BELOW=5
local lm_sensors_ok=false
local sensors_detected=false
@ -294,6 +295,26 @@ node_info_configure() {
[fF]) TEMP_UNIT="F"; info "Using Fahrenheit." ;;
*) TEMP_UNIT="C"; info "Using Celsius." ;;
esac
msgb "\n=== Ignore threshold ==="
local default_c=5 default_display entered
if [[ "$TEMP_UNIT" == "F" ]]; then
default_display=$(awk -v c="$default_c" 'BEGIN{printf "%.0f", c*9/5+32}')
else
default_display="$default_c"
fi
while true; do
entered=$(ask "Hide temperature readings below this value (°${TEMP_UNIT}) [${default_display}]")
[[ -z "$entered" ]] && entered="$default_display"
[[ "$entered" =~ ^-?[0-9]+(\.[0-9]+)?$ ]] && break
warn "Invalid number, please try again."
done
if [[ "$TEMP_UNIT" == "F" ]]; then
IGNORE_TEMP_BELOW=$(awk -v f="$entered" 'BEGIN{printf "%.1f", (f-32)*5/9}')
else
IGNORE_TEMP_BELOW="$entered"
fi
info "Temperature readings below ${entered}°${TEMP_UNIT} will be hidden."
fi
#endregion Temperature unit
fi
@ -478,7 +499,6 @@ enable_nvme_temp=${ENABLE_NVME_TEMP}
enable_other_temp=${ENABLE_OTHER_TEMP}
enable_fan_speed=${ENABLE_FAN_SPEED}
display_zero_speed_fans=${DISPLAY_ZERO_SPEED_FANS}
temp_unit=${TEMP_UNIT}
[ups]
enabled=${ENABLE_UPS}
@ -487,6 +507,8 @@ device_name=${UPS_DEVICE_NAME}
[system_info]
enabled=${ENABLE_SYSTEM_INFO}
type=${SYSTEM_INFO_TYPE}
temp_unit=${TEMP_UNIT}
ignore_temp_below=${IGNORE_TEMP_BELOW}
# Debug mode: when a collector's mode is 1, the real tool is not required.
# Data is read from the file path instead. Useful for development/testing.