forked from alexleigh/pve-mods
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
530 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
Oops, something went wrong.