Skip to content

Commit

Permalink
Add v7.4-16-pwt3.7.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexleigh committed Jul 16, 2023
1 parent 4b229c8 commit 68453fa
Show file tree
Hide file tree
Showing 7 changed files with 530 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ patch directories and the versions of the Proxmox packages they were generated a
* pve-manager 7.4-13
* proxmox-widget-toolkit 3.7.3

[v7.4-16-pwt3.7.3](v7.4-16-pwt3.7.3/patches)
* pve-manager 7.4-16
* proxmox-widget-toolkit 3.7.3

> **Warning**
> If the package versions installed on your system are different from these, the patches should not
> be applied. Instead, use the patches as a reference to make manual modifications to the affected
Expand Down Expand Up @@ -192,6 +196,12 @@ branches:
* [pve-manager/v7.4-13](https://github.com/alexleigh/pve-manager/tree/v7.4-13)
* [proxmox-widget-toolkit/v3.7.3](https://github.com/alexleigh/proxmox-widget-toolkit/tree/v3.7.3)

To build the modified files in the [v7.4-16-pwt3.7.3](v7.4-16-pwt3.7.3) directory, use the following
branches:

* [pve-manager/v7.4-16](https://github.com/alexleigh/pve-manager/tree/v7.4-16)
* [proxmox-widget-toolkit/v3.7.3](https://github.com/alexleigh/proxmox-widget-toolkit/tree/v3.7.3)

Cloning the above two repositories and this repository in the same parent directory, and invoking
`make all` in one of the versioned subdirectories, will generate all the modified files within the
versioned subdirectory. Building these files requires a development environment where, at a minimum,
Expand Down
44 changes: 44 additions & 0 deletions v7.4-16-pwt3.7.3/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
include ../defines.mk
include ../common.mk

SRCDIR=../..

all: proxmoxlib.js Nodes.pm pvemanagerlib.js pvemanager-mobile.js

.PHONY: install
install:
install -d ${TOOLKITDIR}
install -m 0644 proxmoxlib.js ${TOOLKITDIR}
install -d ${PERLLIBDIR}/PVE/API2
install -m 0644 Nodes.pm ${PERLLIBDIR}/PVE/API2
install -d ${WWWJSDIR}
install -m 0644 pvemanagerlib.js ${WWWJSDIR}
install -d ${WWWTOUCHDIR}
install -m 0644 pvemanager-mobile.js ${WWWTOUCHDIR}

.PHONY: clean
clean:
-rm -f proxmoxlib.js Nodes.pm pvemanagerlib.js pvemanager-mobile.js

.PHONY: backup
backup:
mkdir -p orig
cp -a ${TOOLKITDIR}/proxmoxlib.js orig/
cp -a ${PERLLIBDIR}/PVE/API2/Nodes.pm orig/
cp -a ${WWWJSDIR}/pvemanagerlib.js orig/
cp -a ${WWWTOUCHDIR}/pvemanager-mobile.js orig/

.PHONY: restore
restore:
install -d ${TOOLKITDIR}
install -m 0644 orig/proxmoxlib.js ${TOOLKITDIR}
install -d ${PERLLIBDIR}/PVE/API2
install -m 0644 orig/Nodes.pm ${PERLLIBDIR}/PVE/API2
install -d ${WWWJSDIR}
install -m 0644 orig/pvemanagerlib.js ${WWWJSDIR}
install -d ${WWWTOUCHDIR}
install -m 0644 orig/pvemanager-mobile.js ${WWWTOUCHDIR}

.PHONY: cleanbackup
cleanbackup:
-rm -f orig/proxmoxlib.js orig/Nodes.pm orig/pvemanagerlib.js orig/pvemanager-mobile.js
8 changes: 8 additions & 0 deletions v7.4-16-pwt3.7.3/patches/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include ../../defines.mk
include ../../common.mk

all: proxmoxlib.js.patch Nodes.pm.patch pvemanagerlib.js.patch pvemanager-mobile.js.patch

.PHONY: clean
clean:
-rm -f *.patch
104 changes: 104 additions & 0 deletions v7.4-16-pwt3.7.3/patches/Nodes.pm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
diff --git a/usr/share/perl5/PVE/API2/Nodes.pm b/../Nodes.pm
index bfe5c40..8d1a745 100644
--- a/usr/share/perl5/PVE/API2/Nodes.pm
+++ b/../Nodes.pm
@@ -396,40 +396,99 @@ __PACKAGE__->register_method({
};

$res->{swap} = {
free => $meminfo->{swapfree},
total => $meminfo->{swaptotal},
used => $meminfo->{swapused},
};

$res->{pveversion} = PVE::pvecfg::package() . "/" .
PVE::pvecfg::version_text();

my $dinfo = df('/', 1); # output is bytes

$res->{rootfs} = {
total => $dinfo->{blocks},
avail => $dinfo->{bavail},
used => $dinfo->{used},
free => $dinfo->{blocks} - $dinfo->{used},
};

+ my %sensors_config = (
+ cputemp => {
+ jsonpath => ['coretemp-isa-0000', 'Package id 0'],
+ valkey => 'temp1_input',
+ critkey => 'temp1_crit',
+ },
+ pchtemp => {
+ jsonpath => ['pch_cannonlake-virtual-0', 'temp1'],
+ valkey => 'temp1_input',
+ },
+ nvme1temp => {
+ jsonpath => ['nvme-pci-0100', 'Composite'],
+ valkey => 'temp1_input',
+ critkey => 'temp1_crit',
+ },
+ nvme2temp => {
+ jsonpath => ['nvme-pci-0200', 'Composite'],
+ valkey => 'temp1_input',
+ critkey => 'temp1_crit',
+ },
+ hd1temp => {
+ jsonpath => ['drivetemp-scsi-1-0', 'temp1'],
+ valkey => 'temp1_input',
+ critkey => 'temp1_crit',
+ },
+ hd2temp => {
+ jsonpath => ['drivetemp-scsi-2-0', 'temp1'],
+ valkey => 'temp1_input',
+ critkey => 'temp1_crit',
+ },
+ );
+ my $temp_default_val = 0;
+ my $temp_default_crit = 80;
+
+ my $sensors = eval { decode_json(`sensors -j`); };
+ if (defined($sensors)) {
+ keys %sensors_config;
+ while (my ($k, $v) = each %sensors_config) {
+ if (!defined($v->{jsonpath})) { next; }
+ my $currref = $sensors;
+ my $pathdefined = 1;
+ for my $pathseg (@{$v->{jsonpath}}) {
+ if (defined($currref->{$pathseg})) {
+ $currref = $currref->{$pathseg}
+ } else {
+ $pathdefined = 0;
+ last;
+ }
+ }
+ if (!$pathdefined) { next; }
+ $res->{$k} = {
+ used => defined($v->{valkey}) && defined($currref->{$v->{valkey}})
+ ? $currref->{$v->{valkey}} : $temp_default_val,
+ total => defined($v->{critkey}) && defined($currref->{$v->{critkey}})
+ ? $currref->{$v->{critkey}} : $temp_default_crit,
+ };
+ }
+ }
+
return $res;
}});

__PACKAGE__->register_method({
name => 'netstat',
path => 'netstat',
method => 'GET',
permissions => {
check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]],
},
description => "Read tap/vm network device interface counters",
proxyto => 'node',
parameters => {
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
},
returns => {
type => "array",
49 changes: 49 additions & 0 deletions v7.4-16-pwt3.7.3/patches/proxmoxlib.js.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js b/../proxmoxlib.js
index 91bf878..134f5cd 100644
--- a/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
+++ b/../proxmoxlib.js
@@ -1027,40 +1027,44 @@ utilities: {
if (!Ext.isNumeric(value)) {
return '';
}
return Proxmox.Utils.format_size(value);
},

render_cpu_model: function(cpu) {
let socketText = cpu.sockets > 1 ? gettext('Sockets') : gettext('Socket');
return `${cpu.cpus} x ${cpu.model} (${cpu.sockets.toString()} ${socketText})`;
},

/* this is different for nodes */
render_node_cpu_usage: function(value, record) {
return Proxmox.Utils.render_cpu_usage(value, record.cpus);
},

render_node_size_usage: function(record) {
return Proxmox.Utils.render_size_usage(record.used, record.total);
},

+ render_node_temp: function(record) {
+ return record.used.toFixed(1) + '°C (crit: ' + record.total.toFixed(1) + '°C)';
+ },
+
loadTextFromFile: function(file, callback, maxBytes) {
let maxSize = maxBytes || 8192;
if (file.size > maxSize) {
Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
return;
}
let reader = new FileReader();
reader.onload = evt => callback(evt.target.result);
reader.readAsText(file);
},

parsePropertyString: function(value, defaultKey) {
var res = {},
error;

if (typeof value !== 'string' || value === '') {
return res;
}

Ext.Array.each(value.split(','), function(p) {
Loading

0 comments on commit 68453fa

Please sign in to comment.