PVE添加cpu溫度顯示---U盤安裝Proxmox VE(三)


轉自我的個人博客:PVE添加cpu溫度顯示---U盤安裝Proxmox VE(三)

 

作為放家里的小Server,對整個服務器的溫度監控還是很有必要的,當初選擇pve也是因為pve可diy程度比較高。

先上修改后的效果圖:
pve cpu溫度顯示

廢話不多說,動手吧。

一、安裝lm-sensors

apt-get install lm-sensors


安裝成功后,可以通過命令查看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行:

    293         $res->{pveversion} = PVE::pvecfg::package() . "/" .
    294             PVE::pvecfg::version_text();
    295 
    296         my $dinfo = df('/', 1);     # output is bytes
    297 

 

添加:$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

  16876 Ext.define('PVE.node.StatusView', {
  16877     extend: 'PVE.panel.StatusView',
  16878     alias: 'widget.pveNodeStatus',
  16879 
  16880     height: 300,
  16881     bodyPadding: '20 15 20 15',
  16882 
  16883     layout: {
  16884         type: 'table',
  16885         columns: 2,
  16886         tableAttrs: {
  16887             style: {
  16888                 width: '100%'
  16889             }
  16890         }
  16891     },

  


2.2、搜索PVE Manager Version

 
        
  16990         {
  16991             itemId: 'version',
  16992             colspan: 2,
  16993             printBar: false,
  16994             title: gettext('PVE Manager Version'),
  16995             textField: 'pveversion',
  16996             value: ''
  16997         }

 

在后面添加一個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溫度顯示。


免責聲明!

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



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