# 后端 pveproxy
## 去除订阅弹窗
dst1=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
grep -q '/\*patched-v01\*/' $dst1 \
|| sed -i.bak '/function(orig_cmd) {/a\/*patched-v01*/orig_cmd(); return;' $dst1 \
&& echo "$dst1 patched"
## 增加温度显示, 还需要改前端, 见下面 <前端温度显示>
dst2=/usr/share/perl5/PVE/API2/Nodes.pm
grep -q '###patched-v01###' $dst2 \
|| sed -i.bak '/$res->{cpuinfo} = PVE::ProcFSTools::read_cpuinfo();/a\###patched-v01###\n$res->{sensinfo} = `sensors -j`;' $dst2 \
&& echo "$dst2 patched"
## reboot pveproxy.service
systemctl restart pveproxy
# 前端 pvemanagerlib
## 前端温度显示
cat << 'EOF' > /tmp/pve-sensinfo.js
/*patched-v01*/
{
itemId: 'sensinfo',
colspan: 2,
printBar: false,
title: gettext('SensorInfo'),
textField: 'sensinfo',
renderer: function (value) {
const getattr = (data, field) => field.split('.').reduce((p, c) => p ? p[c] : null, data);
const unit = '°C';
const data = JSON.parse(value);
const cpuPkg = getattr(data, "coretemp-isa-0000.Package id 0.temp1_input")?.toFixed(1);
const cpus = [
getattr(data, "coretemp-isa-0000.Core 0.temp2_input"),
getattr(data, "coretemp-isa-0000.Core 1.temp3_input"),
getattr(data, "coretemp-isa-0000.Core 2.temp4_input"),
getattr(data, "coretemp-isa-0000.Core 3.temp5_input"),
];
const disks = [
getattr(data, "nvme-pci-0100.Composite.temp1_input"),
getattr(data, "nvme-pci-0100.Sensor 1.temp2_input"),
getattr(data, "nvme-pci-0100.Sensor 2.temp3_input"),
];
return `CPU温度: ${cpuPkg}${unit} (${cpus.map(d => d?.toFixed(1) + unit).join(' | ')})<br/>
硬盘温度: ${disks.map(d => d?.toFixed(1) + unit).join(' | ')}`;
},
value: '',
},
EOF
dst3=/usr/share/pve-manager/js/pvemanagerlib.js
if ! grep -q '/\*patched-v01\*/' $dst3; then
mv $dst3 $dst3.bak
awk -v add="$(cat /tmp/pve-sensinfo.js)" '{gsub(/textField[^[:alnum:]_]*cpuinfo[^[:alnum:]_]*renderer: Proxmox.Utils.render_cpu_model,[^[:alnum:]_]*value:[^[:alnum:]_]*},/, "&" add)} 1' RS='\0' $dst3.bak > $dst3
echo "$dst3 patched"
fi
# restore
# test -e $dst1.bak && mv -f $dst1.bak $dst1
# test -e $dst2.bak && mv -f $dst2.bak $dst2
# test -e $dst3.bak && mv -f $dst3.bak $dst3