安装温度检测工具
#CPU 及主板温度检测:lm-sensors apt install lm-sensors -y #安装完成后执行探测 sensors acpitz-acpi-0 Adapter: ACPI interface temp1: +36.0°C (crit = +120.0°C) 10900t Adapter: ISA adapter Package id 0: +37.0°C (high = +84.0°C, crit = +100.0°C) Core 0: +37.0°C (high = +84.0°C, crit = +100.0°C) Core 1: +35.0°C (high = +84.0°C, crit = +100.0°C) Core 2: +32.0°C (high = +84.0°C, crit = +100.0°C) Core 3: +34.0°C (high = +84.0°C, crit = +100.0°C) ... #硬盘温度检测:hddtemp apt install hddtemp -y #安装完成后执行探测 hddtemp /dev/sd? /dev/sda: WDC WD40EZRZ-00WN9B0: 29°C /dev/sdb: ADATA SP600: 26°C /dev/sdc: WD2500: 29°C /dev/sdd: ADATA SP900: 38°C #赋予特权 chmod +s /usr/sbin/hddtemp
编辑 PVE web 服务文件
#首先备份/usr/share/perl5/PVE/API2/Nodes.pm,切记要备份!!! #编辑文件 /usr/share/perl5/PVE/API2/Nodes.pm,跳转到res->{pveversion} # ...[OMITTED]... $res->{pveversion} = PVE::pvecfg::package() . "/" . PVE::pvecfg::version_text(); $res->{temperatures} = `sensors`; # 添加此行以获取 CPU 与主板温度 $res->{hdd_temperatures} = `hddtemp /dev/sd?`; # 添加此行以获取硬盘温度 my $dinfo = df('/', 1); # output is bytes # ...[OMITTED]... #首先备份/usr/share/pve-manager/js/pvemanagerlib.js,编辑文件 /usr/share/pve-manager/js/pvemanagerlib.js,跳转到 gettext('Status') + ': ' + zpool, 位置 // ...[OMITTED]... var win = Ext.create('Ext.window.Window', { modal: true, width: 800, height: 500, // 原始值为 400,可以根据自己的喜好调整 resizable: true, layout: 'fit', title: gettext('Status') + ': ' + zpool, items:[{ // ...[OMITTED]... #跳转到 widget.pveNodeStatus 位置 #两处 height 的值需按情况修改,每多一行数据增加 20 #例如有 1 行 CPU 与主板温度数据、3 行硬盘温度数据(3 块硬盘),即为 480 与 380 // ...[OMITTED]... Ext.define('PVE.node.StatusView', { extend: 'PVE.panel.StatusView', alias: 'widget.pveNodeStatus', height: 400, // 原始值为 300 bodyPadding: '20 15 20 15', layout: { // ...[OMITTED]... #跳转到 PVE Manager Version 位置 // ...[OMITTED]... { itemId: 'version', colspan: 2, printBar: false, title: gettext('PVE Manager Version'), textField: 'pveversion', value: '' }, // 注意添加逗号 { itemId: 'temperatures', colspan: 2, printBar: false, title: gettext('CPU Temperatures'), textField: 'temperatures', renderer: function(value) { value = value.replace(/Â/g, ''); let data = []; let cpus = value.matchAll(/^coretemp-isa-(\d{4})$\n.*?\n((?:Package|Core)[\s\S]*?^\n)+/gm); for (const cpu of cpus) { let cpuNumber = parseInt(cpu[1], 10); data[cpuNumber] = { packages: [], cores: [] }; let packages = cpu[2].matchAll(/^Package id \d+:\s*([^°]+).*$/gm); for (const package of packages) { data[cpuNumber]['packages'].push(package[1]); } let cores = cpu[2].matchAll(/^Core \d+:\s*([^°]+).*$/gm); for (const core of cores) { data[cpuNumber]['cores'].push(core[1]); } } let output = ''; for (const [i, cpu] of data.entries()) { output += `CPU ${i}: `; if (cpu.packages.length > 0) { for (const packageTemp of cpu.packages) { output += `${packageTemp}°C `; } } if (cpu.cores.length > 0) { output += '('; for (const coreTemp of cpu.cores) { output += `${coreTemp}, `; } output = output.slice(0, -2); output += ')°C'; } output += ' | '; } let boardTemp = value.match(/^acpitz-acpi-\d+$\n.*?\n^temp1:\s*([^°]+).*$/m); if (boardTemp.length > 0) { output += `Board: ${boardTemp[1]}°C | ` } let nvmeTemp = value.match(/^nvme-pci-\d+$\n.*?\n^Composite:\s*([^°]+).*$/m); if (nvmeTemp.length > 0) { output += `NVME: ${nvmeTemp[1]}°C | ` } output = output.slice(0, -3); return output; } }, { itemId: 'hdd-temperatures', colspan: 2, printBar: false, title: gettext('HDD Temperatures'), textField: 'hdd_temperatures', renderer: function(value) { value = value.replace(/Â/g, ''); return value.replace(/\n/g, '<br>') } } ], // ...[OMITTED]... #全部编辑完成后执行 systemctl restart pveproxy
显示效果
在浏览器中清除 PVE 控制台的缓存,重新加载即可在节点概要显示温度信息