PVE顯示CPU溫度


PVE添加CPU溫度顯示

 

先進入pve的shell,安裝 lm-sensors

 apt-get install lm-sensors

 無法安裝的話先更新一下源

apt-get update

安裝完成后,可以運行命令“sensors-detect”來探測哪些傳感器可用並加載相關的內核模塊。

執行命令“sensors”即可顯示出系統運行的溫度狀態,下面是 3205U 的顯示結果示例(Core 0和Core 1表示有兩個CPU核心):

復制代碼
root@www:~# sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +27.8°C  (crit = +105.0°C)
temp2:        +29.8°C  (crit = +105.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +54.0°C  (high = +105.0°C, crit = +105.0°C)
Core 0:        +54.0°C  (high = +105.0°C, crit = +105.0°C)
Core 1:        +52.0°C  (high = +105.0°C, crit = +105.0°C)
復制代碼

 

先備份之后要修改的兩個文件

cp /usr/share/perl5/PVE/API2/Nodes.pm /usr/share/perl5/PVE/API2/Nodes.pm.bak
cp /usr/share/pve-manager/js/pvemanagerlib.js /usr/share/pve-manager/js/pvemanagerlib.js.bak

 

修改文件內容 ' vi /usr/share/perl5/PVE/API2/Nodes.pm ' ,添加 '  $res->{thermalstate} = `sensors`;  '(注意,sensors左右兩個不是分號,而是在英文狀態下字母區上方的數字鍵區域最左側按鍵打出來的反引號)

 

 

之后修改頁面布局,增加界面高度讓新的CPU內容有地方顯示,編輯 ' vi /usr/share/pve-manager/js/pvemanagerlib.js ',修改以下兩處地方:

 

 第二處修改

 

最后增加顯示CPU溫度的代碼

復制代碼
    {
        itemId: 'thermal',
        colspan: 2,
            printBar: false,
            title: gettext('CPU溫度'),
            textField: 'thermalstate',
            renderer:function(value){
            const c0 = value.match(/Core 0.*?\+([\d\.]+)?/)[1];
            const c1 = value.match(/Core 1.*?\+([\d\.]+)?/)[1];
        return `Core: ${c0} | ${c1}`
       }     
         } 
復制代碼

 

 

修改完成后,重啟PVE的Web管理器

systemctl restart pveproxy

 

之后強制刷新頁面即可顯示,win下Ctrl + F5 ,Mac下 花鍵 + shift + R

 

文章修改自:

Proxmox VE技巧,讓PVE顯示CPU和主板溫度狀態

https://odcn.top/2019/04/09/3096/proxmox-ve%E6%8A%80%E5%B7%A7%EF%BC%8C%E8%AE%A9pve%E6%98%BE%E7%A4%BAcpu%E5%92%8C%E4%B8%BB%E6%9D%BF%E6%B8%A9%E5%BA%A6%E7%8A%B6%E6%80%81/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM