Proxmox VE PVE EPYC CPU 显示温度传感器
🔦

Proxmox VE PVE EPYC CPU 显示温度传感器

 
PVEtools可以一把嗦直接获取CPU温度和频率特别方便,但是EPYC获取到的温度不是Core温度,而是CCD和CTL温度,似乎会导致无法匹配到。所以自己需要手动获取温度并添加。
 
  • 确保已经删除原有企业源以及能正常访问Debian源
 
安装lm-sensors
apt-get update && apt-get install lm-sensors -y
 
加载温度传感器
sensors-detect
 
之后使用下面的命令,直接在命令行就可以直接查看温度传感器
sensors
 
但是我们实际要用原来的命令加 -j 获取的是输出的JSON格式,相比直接输出需要正则表达式去获取参数,JSON格式会更加方便。
sersors -j
然后你能获得这样的信息
notion image
 
修改/usr/share/perl5/PVE/API2/Nodes.pm文件内容
本文用的是nano,你也可以用vim或者直接文本编辑器
nano /usr/share/perl5/PVE/API2/Nodes.pm
 
ctrl+w 搜索 shared => $meminfo->{memshared}
$res->{ksm} = { shared => $meminfo->{memshared}, }; #增加下面这一行 $res->{sensinfo} = `sensors -j`; #$res->{ipmiinfo} = `ipmicfg -sdr`;
 
 
 
nano /usr/share/pve-manager/js/pvemanagerlib.js
同样搜索 Proxmox.Utils.render_cpu_model
找到下面的内容
{ xtype: 'box', colspan: 2, padding: '0 0 20 0', }, { itemId: 'cpus', colspan: 2, printBar: false, title: gettext('CPU(s)'), textField: 'cpuinfo', renderer: Proxmox.Utils.render_cpu_model, value: '', },
notion image
 
在上图绿色光标处插入下面的所有内容。
 
//CPU 频率 { itemId: 'MHz', colspan: 2, printBar: false, title: gettext('CPU频率'), textField: 'tdata', renderer:function(value){ var d = JSON.parse(value); f0 = d['CPU-MHz']; f1 = d['CPU-min-MHz']; f2 = d['CPU-max-MHz']; return `CPU实时(Cur): ${f0} MHz | 最小(min): ${f1} MHz | 最大(max): ${f2} MHz `; } },
//CPU 温度 { itemId: 'sensinfo', colspan: 2, printBar: false, title: gettext('温度传感器'), textField: 'sensinfo', renderer:function(value){ value = JSON.parse(value.replaceAll('Â', '')); const c0 = value['k10temp-pci-00c3']['Tctl']['temp1_input'].toFixed(1); const c1 = value['k10temp-pci-00c3']['Tccd1']['temp3_input'].toFixed(1); const c2 = value['k10temp-pci-00c3']['Tccd3']['temp5_input'].toFixed(1); const c3 = value['k10temp-pci-00c3']['Tccd5']['temp7_input'].toFixed(1); const c4 = value['k10temp-pci-00c3']['Tccd7']['temp9_input'].toFixed(1); return `CPU Temperature: Tctl: ${c0}℃ || Tccd1: ${c1}℃ | Tccd2: ${c2}℃ | Tccd3: ${c3}℃ | Tccd4: ${c4}℃`; } },
最后添加完应该是这样
notion image
 

修改管理界面的高度

 
搜索Ext.create('Ext.window.Window', {
将height改为600
notion image
 
 
搜索widget.pveNodeStatus
将height改为360
notion image
 
这里需要根据自己页面实际内容调整
 

执行重启pveproxy服务

systemctl restart pveproxy
 
 

引用&&参考: