sed -i -e "s/Proxmox.Utils.checked_command(Ext.emptyFn);//" /usr/share/pve-manager/js/pvemanagerlib.js
apt install -y lm-sensors
sensors-detect
# 根据提示操作,一般都是直接回车
输出传感器信息:
$ sensors
k10temp-pci-00c3
Adapter: PCI adapter
Tctl: +59.0°C
nvme-pci-0100
Adapter: PCI adapter
Composite: +42.9°C (low = -0.1°C, high = +74.8°C)
(crit = +79.8°C)
amdgpu-pci-0700
Adapter: PCI adapter
vddgfx: 793.00 mV
vddnb: 762.00 mV
edge: +55.0°C
slowPPT: 1000.00 uW
nvme-pci-0600
Adapter: PCI adapter
Composite: +40.9°C (low = -273.1°C, high = +89.8°C)
(crit = +94.8°C)
Sensor 1: +40.9°C (low = -273.1°C, high = +65261.8°C)
Sensor 2: +59.9°C (low = -273.1°C, high = +65261.8°C)
修改 /usr/share/perl5/PVE/API2/Nodes.pm
文件,找到 code => sub {}
函数,在 return
前面增加:
$res->{sensinfo} = `sensors -j`;
修改配置文件 /usr/share/pve-manager/js/pvemanagerlib.js
对应位置(Ext.define('PVE.node.StatusView'){}
里面的 items
):
{
itemId: 'sensinfo',
colspan: 2,
printBar: false,
title: gettext('温度传感器'),
textField: 'sensinfo',
renderer: function (value) {
value = JSON.parse(value.replaceAll('Â', ''));
const c0 = value['amdgpu-pci-0700']['vddgfx']['in0_input'].toFixed(1);
const c1 = value['amdgpu-pci-0700']['vddnb']['in1_input'].toFixed(1);
const c2 = value['amdgpu-pci-0700']['edge']['temp1_input'].toFixed(1);
const c3 = value['amdgpu-pci-0700']['slowPPT']['power1_average'].toFixed(1);
const nvme1 = value['nvme-pci-0600']['Composite']['temp1_input'].toFixed(1);
const k = value['k10temp-pci-00c3']['Tctl']['temp1_input'].toFixed(1);
return `CPU核心温度: ${c0}℃ | ${c1}℃ | ${c2}℃ | ${c3}℃
<br>
NVME:${nvme1}℃
<br>
PCI adapter:${k}℃`;
}
},
pveum user add pve-exporter@pve -password <password> # 创建 PVE 用户
pveum acl modify / -user pve-exporter@pve -role PVEAuditor # 添加 PVEAuditor 角色
useradd -s /bin/false pve-exporter # 创建 Linux 用户
# Python 虚拟环境
apt update && apt install -y python3-venv
python3 -m venv /opt/prometheus-pve-exporter
source /opt/prometheus-pve-exporter/bin/activate
pip install prometheus-pve-exporter
创建配置文件 /etc/prometheus/pve.yml
:
default:
user: pve-exporter@pve
password: <password>
verify_ssl: false
修改文件权限:
chown -v root.pve-exporter /etc/prometheus/pve.yml
chmod -v 640 /etc/prometheus/pve.yml
创建服务文件 /etc/systemd/system/prometheus-pve-exporter.service
:
[Unit]
Description=Prometheus Proxmox VE Exporter
Documentation=https://github.com/prometheus-pve/prometheus-pve-exporter
[Service]
Restart=always
User=pve-exporter
ExecStart=/opt/prometheus-pve-exporter/bin/pve_exporter /etc/prometheus/pve.yml
[Install]
WantedBy=multi-user.target
启动服务:
systemctl daemon-reload
systemctl enable prometheus-pve-exporter.service
systemctl start prometheus-pve-exporter.service
ss -lntp | grep 9221 # 检查端口是否已成功绑定
curl --silent http://127.0.0.1:9221/pve | grep pve_version_info
修改配置文件 /etc/prometheus/prometheus.yml
:
# 新增配置:
scrape_configs:
- job_name: 'pve-exporter'
static_configs:
- targets:
- 127.0.0.1:9221
metrics_path: /pve
params:
module: [default]
重启 Prometheus:
systemctl reload prometheus
VNC 全称 Virtual Network Computing,是一种远程控制技术,可以通过 VNC 客户端远程控制 VNC 服务端。
修改配置文件 /etc/pve/local/qemu-server/<VMID>.conf
,·
args: -vnc 0.0.0.0:77
QEMU 会自动将其映射到 5977
端口,规则是 5900 + <VNC_PORT>
,在别的机器链接 <PVE_IP>:5977
即可访问。
如果需要 VNC 密码,可以设置:
args: -vnc 0.0.0.0:77,password=on
然后进入 PVE web UI 对应 VM monitor 面板,输入:
# 设置固定密码
set_password vnc foobar1 -d vnc2
# 设置限时密码(600 秒)
expire_password vnc +600 -d vnc2
参考: