Created
July 7, 2023 20:20
-
-
Save iTeeLion/efd6c128f6cfa702cc112adeaa8d2177 to your computer and use it in GitHub Desktop.
pve_node_summary.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
Ext.define('PVE.node.StatusView', { | |
extend: 'Proxmox.panel.StatusView', | |
alias: 'widget.pveNodeStatus', | |
bodyPadding: '15 5 15 5', | |
layout: { | |
type: 'table', | |
columns: 2, | |
tableAttrs: { | |
style: { | |
width: '100%', | |
}, | |
}, | |
}, | |
defaults: { | |
xtype: 'pmxInfoWidget', | |
padding: '0 10 5 10', | |
}, | |
items: [ | |
{ | |
itemId: 'cpu', | |
iconCls: 'fa fa-fw pmx-itype-icon-processor pmx-icon', | |
title: gettext('CPU usage'), | |
valueField: 'cpu', | |
maxField: 'cpuinfo', | |
renderer: Proxmox.Utils.render_node_cpu_usage, | |
}, | |
{ | |
itemId: 'wait', | |
iconCls: 'fa fa-fw fa-clock-o', | |
title: gettext('IO delay'), | |
valueField: 'wait', | |
rowspan: 2, | |
}, | |
{ | |
itemId: 'load', | |
iconCls: 'fa fa-fw fa-tasks', | |
title: gettext('Load average'), | |
printBar: false, | |
textField: 'loadavg', | |
}, | |
{ | |
xtype: 'box', | |
colspan: 2, | |
padding: '0 0 20 0', | |
}, | |
{ | |
iconCls: 'fa fa-fw pmx-itype-icon-memory pmx-icon', | |
itemId: 'memory', | |
title: gettext('RAM usage'), | |
valueField: 'memory', | |
maxField: 'memory', | |
renderer: Proxmox.Utils.render_node_size_usage, | |
}, | |
{ | |
itemId: 'ksm', | |
printBar: false, | |
title: gettext('KSM sharing'), | |
textField: 'ksm', | |
renderer: function(record) { | |
return Proxmox.Utils.render_size(record.shared); | |
}, | |
padding: '0 10 10 10', | |
}, | |
{ | |
iconCls: 'fa fa-fw fa-hdd-o', | |
itemId: 'rootfs', | |
title: '/ ' + gettext('HD space'), | |
valueField: 'rootfs', | |
maxField: 'rootfs', | |
renderer: Proxmox.Utils.render_node_size_usage, | |
}, | |
{ | |
iconCls: 'fa fa-fw fa-refresh', | |
itemId: 'swap', | |
printSize: true, | |
title: gettext('SWAP usage'), | |
valueField: 'swap', | |
maxField: 'swap', | |
renderer: Proxmox.Utils.render_node_size_usage, | |
}, | |
{ | |
xtype: 'box', | |
colspan: 2, | |
padding: '0 0 20 0', | |
}, | |
{ | |
itemId: 'cpus', | |
colspan: 2, | |
printBar: false, | |
title: gettext('CPU(s)'), | |
textField: 'cpuinfo', | |
renderer: Proxmox.Utils.render_cpu_model, | |
value: '', | |
}, | |
{ | |
itemId: 'kversion', | |
colspan: 2, | |
title: gettext('Kernel Version'), | |
printBar: false, | |
textField: 'kversion', | |
value: '', | |
}, | |
{ | |
itemId: 'version', | |
colspan: 2, | |
printBar: false, | |
title: gettext('PVE Manager Version'), | |
textField: 'pveversion', | |
value: '', | |
}, | |
{ | |
itemId: 'thermals', | |
colspan: 2, | |
printBar: false, | |
title: gettext('Thermals'), | |
textField: 'thermalstate', | |
renderer:function(value){ | |
let result = []; | |
const sensors = JSON.parse(value); | |
Object.entries(sensors).forEach(([sensor, temps]) => { | |
let sensorTemps = []; | |
Object.entries(temps).forEach(([name, temp]) => { | |
Object.entries(temp).forEach(([key, val]) => { | |
if(key.includes('_input')){ | |
sensorTemps.push(name + ': ' + val + ' °C'); | |
} | |
}); | |
}); | |
result.push(sensor + '<br>' + sensorTemps.join('<br>')) | |
}); | |
return result.join('<br><br>'); | |
} | |
} | |
], | |
updateTitle: function() { | |
var me = this; | |
var uptime = Proxmox.Utils.render_uptime(me.getRecordValue('uptime')); | |
me.setTitle(me.pveSelNode.data.node + ' (' + gettext('Uptime') + ': ' + uptime + ')'); | |
}, | |
initComponent: function() { | |
let me = this; | |
let stateProvider = Ext.state.Manager.getProvider(); | |
let repoLink = stateProvider.encodeHToken({ | |
view: "server", | |
rid: `node/${me.pveSelNode.data.node}`, | |
ltab: "tasks", | |
nodetab: "aptrepositories", | |
}); | |
me.items.unshift({ | |
xtype: 'pmxNodeInfoRepoStatus', | |
itemId: 'repositoryStatus', | |
product: 'Proxmox VE', | |
repoLink: `#${repoLink}`, | |
margin: '0 0 10 0' | |
}); | |
me.callParent(); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment