脚本方案
sensors 温度
sensors-detect 插件安装
pwmconfig 风扇测试
apt-get install lm-sensors fancontrol 风扇控制安装
service fancontrol start 风扇控制
wget https://pan.98hg.top/d/189/pve/pve.sh
chmod +x pve.sh
./pve.sh
一、安装lm-sensors
apt-get install lm-sensors
sensors-detect
安装成功后,可以通过命令查看cpu温度:
root@home:~# sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +74.0°C)
temp2: +29.8°C (crit = +74.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +38.0°C (high = +68.0°C, crit = +73.0°C)
Core 0: +36.0°C (high = +68.0°C, crit = +73.0°C)
Core 1: +35.0°C (high = +68.0°C, crit = +73.0°C)
Core 2: +34.0°C (high = +68.0°C, crit = +73.0°C)
Core 3: +38.0°C (high = +68.0°C, crit = +73.0°C)
二、编辑修改文件
1、/usr/share/perl5/PVE/API2/Nodes.pm
搜索my $dinfo = df('/', 1);
以pve5.4.3为例,在296行:
$res->{pveversion} = PVE::pvecfg::package() . "/" .
PVE::pvecfg::version_text();
my $dinfo = df('/', 1); # output is bytes
添加:$res->{thermalstate} = sensors
;
修改后:
$res->{pveversion} = PVE::pvecfg::package() . "/" .
PVE::pvecfg::version_text();
$res->{thermalstate} = `sensors`;
my $dinfo = df('/', 1); # output is bytes
2、/usr/share/pve-manager/js/pvemanagerlib.js
2.1、搜索PVE.panel.StatusView,修改height为320
Ext.define('PVE.node.StatusView', {
extend: 'PVE.panel.StatusView',
alias: 'widget.pveNodeStatus',
height: 300,
bodyPadding: '20 15 20 15',
layout: {
type: 'table',
columns: 2,
tableAttrs: {
style: {
width: '100%'
}
}
},
2.2、搜索PVE Manager Version
{
itemId: 'version',
colspan: 2,
printBar: false,
title: gettext('PVE Manager Version'),
textField: 'pveversion',
value: ''
}
在后面添加一个item,修改后为
{
itemId: 'version',
colspan: 2,
printBar: false,
title: gettext('PVE Manager Version'),
textField: 'pveversion',
value: ''
},
{
itemId: 'thermal',
colspan: 2,
printBar: false,
title: gettext('CPU Thermal State'),
textField: 'thermalstate',
renderer:function(value){
const c0 = value.match(/Core 0.*?\+([\d\.]+)Â/)[1];
const c1 = value.match(/Core 1.*?\+([\d\.]+)Â/)[1];
const c2 = value.match(/Core 2.*?\+([\d\.]+)Â/)[1];
const c3 = value.match(/Core 3.*?\+([\d\.]+)Â/)[1];
return `Core 0: ${c0} ℃ | Core 1: ${c1} ℃ | Core 2: ${c2} ℃ | Core 3: ${c3} ℃`
}
}
三、重启pve web管理服务
systemctl restart pveproxy
至此,就已经成功添加了pve web管理端cpu温度显示。