diff --git a/src/modules/node_info/files/Collector/LmSensors.pm b/src/modules/node_info/files/Collector/LmSensors.pm index 465bc60..0f3a32a 100644 --- a/src/modules/node_info/files/Collector/LmSensors.pm +++ b/src/modules/node_info/files/Collector/LmSensors.pm @@ -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 }, }); diff --git a/src/modules/node_info/files/Config.pm b/src/modules/node_info/files/Config.pm index f60d448..2edc9c3 100644 --- a/src/modules/node_info/files/Config.pm +++ b/src/modules/node_info/files/Config.pm @@ -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', diff --git a/src/modules/node_info/files/PveMod_SensorInfo.pm b/src/modules/node_info/files/PveMod_SensorInfo.pm index 09f55ae..03bacd7 100644 --- a/src/modules/node_info/files/PveMod_SensorInfo.pm +++ b/src/modules/node_info/files/PveMod_SensorInfo.pm @@ -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} // {}}); diff --git a/src/modules/node_info/files/PveMod_pvemanagerlib.js b/src/modules/node_info/files/PveMod_pvemanagerlib.js index e170d2e..234e8df 100644 --- a/src/modules/node_info/files/PveMod_pvemanagerlib.js +++ b/src/modules/node_info/files/PveMod_pvemanagerlib.js @@ -225,6 +225,7 @@ Ext.define('PVE.node.StatusView', { } // 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(); @@ -304,7 +305,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;'; @@ -483,17 +484,20 @@ Ext.define('PVE.node.StatusView', { // Temperature if (stats.temperature) { const gpuTemp = gpuTempHelper.getTemp(parseFloat(stats.temperature.gpu)); - const tempUnit = gpuTempHelper.getUnit(); - // Convert thresholds to target unit for comparison - const tempHigh = gpuTempHelper.getTemp(80); - const tempWarn = gpuTempHelper.getTemp(70); - let tempStyle = ''; - if (gpuTemp >= tempHigh) { - tempStyle = 'color: red; font-weight: bold;'; - } else if (gpuTemp >= tempWarn) { - tempStyle = 'color: #FFC300; font-weight: bold;'; + 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); + const tempWarn = gpuTempHelper.getTemp(70); + let tempStyle = ''; + if (gpuTemp >= tempHigh) { + tempStyle = 'color: red; font-weight: bold;'; + } else if (gpuTemp >= tempWarn) { + tempStyle = 'color: #FFC300; font-weight: bold;'; + } + details.push(`Temp: ${Ext.util.Format.number(gpuTemp, '0')}${tempUnit}`); } - details.push(`Temp: ${Ext.util.Format.number(gpuTemp, '0')}${tempUnit}`); } // Power @@ -544,6 +548,7 @@ Ext.define('PVE.node.StatusView', { objValue = {}; } 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) => { @@ -559,7 +564,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;'; @@ -624,6 +629,7 @@ Ext.define('PVE.node.StatusView', { objValue = {}; } 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) => { @@ -641,7 +647,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;'; @@ -712,6 +718,7 @@ Ext.define('PVE.node.StatusView', { objValue = {}; } 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 => @@ -746,7 +753,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;'; diff --git a/src/modules/node_info/node_info.conf b/src/modules/node_info/node_info.conf index be6cb7b..7e2d349 100644 --- a/src/modules/node_info/node_info.conf +++ b/src/modules/node_info/node_info.conf @@ -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. diff --git a/src/modules/node_info/node_info.configure.sh b/src/modules/node_info/node_info.configure.sh index c7d32ee..ae647ab 100644 --- a/src/modules/node_info/node_info.configure.sh +++ b/src/modules/node_info/node_info.configure.sh @@ -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.