PVE默认概要中只显示CPU利用率、平均负载、内存使用率、硬盘空间、CPU型号、内核版本、管理版本等,下面的教程将添加上CPU温度以及频率信息。
注意:PVE更新后会恢复清除代码。
步骤如下:
1、添加CPU温度
在PVE的Shell下运行
apt-get install lm-sensors
安装完成后运行sensors-detect查看加载模块,默认全Yes即可。
输入sensors显示系统运行的温度状态。
root@proxmox:~# sensors qlcnic-pci-0101 Adapter: PCI adapter temp1: +79.0°C acpitz-acpi-0 Adapter: ACPI interface temp1: +27.8°C (crit = +90.0°C) temp2: +29.8°C (crit = +90.0°C) coretemp-isa-0000 Adapter: ISA adapter Package id 0: +51.0°C (high = +79.0°C, crit = +85.0°C) Core 0: +51.0°C (high = +79.0°C, crit = +85.0°C) Core 1: +47.0°C (high = +79.0°C, crit = +85.0°C) qlcnic-pci-0100 Adapter: PCI adapter temp1: +79.0°C
登录SecureFX打开/usr/share/perl5/PVE/API2,
复制备份Nodes.pm为Nodes.pm.bak,使用Notepad++打开Nodes.pm,Ctrl+F搜索PVE::pvecfg::version_text();
添加代码$res->{thermalstate} = `sensors`;到如下位置,
$res->{pveversion} = PVE::pvecfg::package() . "/" . PVE::pvecfg::version_text(); my $dinfo = df('/', 1); # output is bytes $res->{thermalstate} = `sensors`; $res->{rootfs} = { total => $dinfo->{blocks}, avail => $dinfo->{bavail}, used => $dinfo->{used}, free => $dinfo->{blocks} - $dinfo->{used}, };
打开/usr/share/pve-manager/js/,
复制备份pvemanagerlib.js为pvemanagerlib.js.bak,使用Notepad++打开pvemanagerlib.js,
Ctrl+F搜索widget.pveNodeStatus,
更改代码height: 300为height: 350。
Ext.define('PVE.node.StatusView', { extend: 'PVE.panel.StatusView', alias: 'widget.pveNodeStatus', height: 350, bodyPadding: '20 15 20 15', layout: { type: 'table', columns: 2, tableAttrs: { style: { width: '100%' } } },
Ctrl+F搜索var win = Ext.create(‘Ext.window.Window’, {
更改代码height: 400,为height: 420,
showLog: function(button, event, rec) { var me = this.getView(); var controller = this; var logView = Ext.create('Proxmox.panel.LogView', { border: false, url: "/api2/extjs/nodes/" + me.nodename + "/replication/" + rec.data.id + "/log" }); var win = Ext.create('Ext.window.Window', { items: [ logView ], layout: 'fit', width: 800, height: 420, modal: true, title: gettext("Replication Log") }); var task = {
Ctrl+F搜索textField: ‘pveversion’,将代码更改如下:
{ itemId: 'version', colspan: 2, printBar: false, title: gettext('PVE Manager Version'), textField: 'pveversion', value: '' }, #记得添加逗号 { 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]; const d0 = value.match(/Package id 0.*?\+([\d\.]+)Â/)[1]; return `Package 0: ${d0} ℃ | Core 0: ${c0} ℃ | Core 1: ${c1} ℃` } } ], updateTitle: function() { var me = this; var uptime = Proxmox.Utils.render_uptime(me.getRecordValue('uptime'));
修改完成后,在Shell中输入systemctl restart pveproxy重启PVE的Web管理服务使修改生效。
2、添加CPU频率显示
登录SecureFX打开/usr/share/perl5/PVE/API2,复制备份Nodes.pm为Nodes.pm.bak,使用Notepad++打开Nodes.pm,
在$res->{thermalstate} = `sensors`;下起一行$res->{cpusensors} = lscpu | grep MHz;
代码如下
$res->{pveversion} = PVE::pvecfg::package() . "/" . PVE::pvecfg::version_text(); my $dinfo = df('/', 1); # output is bytes $res->{thermalstate} = `sensors`; $res->{cpusensors} = `lscpu | grep MHz`; $res->{rootfs} = { total => $dinfo->{blocks}, avail => $dinfo->{bavail}, used => $dinfo->{used}, free => $dinfo->{blocks} - $dinfo->{used}, };
Ctrl+F搜索textField: ‘pveversion’,将代码更改如下:
{ itemId: 'version', colspan: 2, printBar: false, title: gettext('PVE Manager Version'), textField: 'pveversion', value: '' }, #记得添加逗号 { itemId: 'thermal', colspan: 2, printBar: false, title: gettext('设备 温度'), textField: 'thermalstate', renderer:function(value){ const c0 = value.match(/Core 0.*?\+([\d\.]+)Â/)[1]; const c1 = value.match(/Core 1.*?\+([\d\.]+)Â/)[1]; const d0 = value.match(/Package id 0.*?\+([\d\.]+)Â/)[1]; return `Package 0: ${d0} ℃ | Core 0: ${c0} ℃ | Core 1: ${c1} ℃` } }, #记得添加逗号 { itemId: 'MHz', colspan: 2, printBar: false, title: gettext('CPU 频率'), textField: 'cpusensors', renderer:function(value){ const f0 = value.match(/CPU MHz.*?([\d]+)/)[1]; const f1 = value.match(/CPU min MHz.*?([\d]+)/)[1]; const f2 = value.match(/CPU max MHz.*?([\d]+)/)[1]; return `CPU Time: ${f0} MHz | Min: ${f1} MHz | Max: ${f2} MHz` } } ],
修改完成后,在Shell中输入systemctl restart pveproxy重启PVE的Web管理服务使修改生效。
效果如下: