From dab566cc73c3628474c0304c937f4a13784ee1bd Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Tue, 18 Mar 2025 10:53:05 +0800 Subject: [PATCH] feat: add temperature and network speed. --- .../proxmox-widget-toolkit/proxmoxlib.js | 2 +- usr/share/perl5/PVE/API2/Nodes.pm | 11 ++++++ usr/share/pve-manager/js/pvemanagerlib.js | 34 ++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js b/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js index 996f638..68d223a 100644 --- a/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js +++ b/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js @@ -563,7 +563,7 @@ utilities: { let res = response.result; if (res === null || res === undefined || !res || res .data.status.toLowerCase() !== 'active') { - Ext.Msg.show({ + void({ //Ext.Msg.show({ title: gettext('No valid subscription'), icon: Ext.Msg.WARNING, message: Proxmox.Utils.getNoSubKeyHtml(res.data.url), diff --git a/usr/share/perl5/PVE/API2/Nodes.pm b/usr/share/perl5/PVE/API2/Nodes.pm index 9cdf19d..5af5472 100644 --- a/usr/share/perl5/PVE/API2/Nodes.pm +++ b/usr/share/perl5/PVE/API2/Nodes.pm @@ -561,6 +561,17 @@ __PACKAGE__->register_method({ $res->{pveversion} = PVE::pvecfg::package() . "/" . PVE::pvecfg::version_text(); + my $net_eno1 = `ethtool eno1 | grep Speed`; + my $net_enp4s0 = `ethtool enp4s0 | grep Speed`; + my $net_enp5s0 = `ethtool enp5s0 | grep Speed`; + my $net_enp7s0 = `ethtool enp7s0 | grep Speed`; + my $net_enp8s0 = `ethtool enp8s0 | grep Speed`; + $res->{networksp} = [ $net_eno1, $net_enp4s0, $net_enp5s0, $net_enp7s0, $net_enp8s0 ]; + + my $temps = `sensors -j`; # add temps + my $gpus = `nvidia-smi | awk '{print \$3}' | sed -n '10p' | sed 's/C\$//'`; + $res->{thermal} = [ $temps, $gpus ]; + my $dinfo = df('/', 1); # output is bytes $res->{rootfs} = { diff --git a/usr/share/pve-manager/js/pvemanagerlib.js b/usr/share/pve-manager/js/pvemanagerlib.js index f8a1f5c..7e3296d 100644 --- a/usr/share/pve-manager/js/pvemanagerlib.js +++ b/usr/share/pve-manager/js/pvemanagerlib.js @@ -44913,7 +44913,7 @@ Ext.define('PVE.node.StatusView', { extend: 'Proxmox.panel.StatusView', alias: 'widget.pveNodeStatus', - height: 350, + height: 390, bodyPadding: '15 5 15 5', layout: { @@ -45048,6 +45048,38 @@ Ext.define('PVE.node.StatusView', { textField: 'pveversion', value: '', }, + { + itemId: 'thermal', + colspan: 2, + printBar: false, + title: gettext('Thermal'), + textField: 'thermal', + renderer: function (value) { + if (!Array.isArray(value)) { + return ''; + } + const temp = JSON.parse(value[0]); + const cpu0 = temp['coretemp-isa-0000']['Package id 0']['temp1_input'].toFixed(1); + // const board = temp['acpitz-acpi-0']['temp1']['temp1_input'].toFixed(1); + const nvme = temp['nvme-pci-0c00']['Composite']['temp1_input'].toFixed(1); + const gpu = Number(value[1]).toFixed(1); + return `CPU: ${cpu0}\xb0C | GPU: ${gpu}\xb0C | NVME: ${nvme}\xb0C`; + }, + }, + { + itemId: 'networksp', + colspan: 2, + printBar: false, + title: gettext('Network Speed'), + textField: 'networksp', + renderer: function (sp) { + if (!Array.isArray(sp)) { + return ''; + } + const sps = sp.map(function (s) { return String(s).match(/(?<=:\s+)(.+)/g)?.[0] }); + return sps.join(' | '); + }, + }, ], updateTitle: function() {