2020-05-26 07:32:05 +02:00
Ext . define ( 'pve-rrd-node' , {
extend : 'Ext.data.Model' ,
fields : [
{
name : 'cpu' ,
// percentage
convert : function ( value ) {
return value * 100 ;
2020-09-25 18:34:54 +02:00
} ,
2020-05-26 07:32:05 +02:00
} ,
{
name : 'iowait' ,
// percentage
convert : function ( value ) {
return value * 100 ;
2020-09-25 18:34:54 +02:00
} ,
2020-05-26 07:32:05 +02:00
} ,
'netin' ,
'netout' ,
'memtotal' ,
'memused' ,
'swaptotal' ,
'swapused' ,
2020-05-28 19:11:37 +02:00
'total' ,
'used' ,
'read_ios' ,
'read_bytes' ,
'write_ios' ,
'write_bytes' ,
'io_ticks' ,
{
name : 'io_delay' , calculate : function ( data ) {
let ios = 0 ;
if ( data . read _ios !== undefined ) { ios += data . read _ios ; }
if ( data . write _ios !== undefined ) { ios += data . write _ios ; }
2020-09-25 18:34:54 +02:00
if ( ios === 0 || data . io _ticks === undefined ) {
2020-05-28 19:11:37 +02:00
return undefined ;
}
return ( data . io _ticks * 1000.0 ) / ios ;
2020-09-25 18:34:54 +02:00
} ,
2020-05-28 19:11:37 +02:00
} ,
2020-05-26 07:32:05 +02:00
'loadavg' ,
2020-09-25 18:34:54 +02:00
{ type : 'date' , dateFormat : 'timestamp' , name : 'time' } ,
] ,
2020-05-26 07:32:05 +02:00
} ) ;
2020-04-30 12:11:08 +02:00
Ext . define ( 'PBS.ServerStatus' , {
extend : 'Ext.panel.Panel' ,
alias : 'widget.pbsServerStatus' ,
2022-05-17 10:17:04 +02:00
title : gettext ( 'Server Status' ) ,
2020-04-30 12:11:08 +02:00
2020-05-26 07:32:05 +02:00
scrollable : true ,
2020-04-30 12:11:08 +02:00
2020-11-09 16:33:22 +01:00
showVersions : function ( ) {
let me = this ;
// Note: use simply text/html here, as ExtJS grid has problems with cut&paste
let panel = Ext . createWidget ( 'component' , {
autoScroll : true ,
id : 'pkgversions' ,
padding : 5 ,
style : {
'white-space' : 'pre' ,
'font-family' : 'monospace' ,
} ,
} ) ;
let win = Ext . create ( 'Ext.window.Window' , {
title : gettext ( 'Package versions' ) ,
width : 600 ,
height : 600 ,
layout : 'fit' ,
modal : true ,
items : [ panel ] ,
buttons : [
{
xtype : 'button' ,
iconCls : 'fa fa-clipboard' ,
2024-03-14 10:32:23 +01:00
handler : async function ( button ) {
let el = document . getElementById ( 'pkgversions' ) ;
await navigator . clipboard . writeText ( el . textContent ) ;
2020-11-09 16:33:22 +01:00
} ,
text : gettext ( 'Copy' ) ,
} ,
{
text : gettext ( 'Ok' ) ,
handler : function ( ) {
this . up ( 'window' ) . close ( ) ;
} ,
} ,
] ,
} ) ;
Proxmox . Utils . API2Request ( {
waitMsgTarget : me ,
url : ` /nodes/localhost/apt/versions ` ,
method : 'GET' ,
failure : function ( response , opts ) {
win . close ( ) ;
Ext . Msg . alert ( gettext ( 'Error' ) , response . htmlStatus ) ;
} ,
success : function ( response , opts ) {
let text = '' ;
Ext . Array . each ( response . result . data , function ( rec ) {
let version = "not correctly installed" ;
let pkg = rec . Package ;
if ( rec . OldVersion && rec . OldVersion !== 'unknown' ) {
version = rec . OldVersion ;
}
if ( rec . ExtraInfo ) {
text += ` ${ pkg } : ${ version } ( ${ rec . ExtraInfo } ) \n ` ;
} else {
text += ` ${ pkg } : ${ version } \n ` ;
}
} ) ;
win . show ( ) ;
panel . update ( Ext . htmlEncode ( text ) ) ;
} ,
} ) ;
} ,
2020-04-30 12:11:08 +02:00
initComponent : function ( ) {
var me = this ;
var node _command = function ( cmd ) {
Proxmox . Utils . API2Request ( {
params : { command : cmd } ,
url : '/nodes/localhost/status' ,
method : 'POST' ,
waitMsgTarget : me ,
failure : function ( response , opts ) {
Ext . Msg . alert ( gettext ( 'Error' ) , response . htmlStatus ) ;
2020-09-25 18:34:54 +02:00
} ,
2020-04-30 12:11:08 +02:00
} ) ;
} ;
var restartBtn = Ext . create ( 'Proxmox.button.Button' , {
text : gettext ( 'Reboot' ) ,
dangerous : true ,
confirmMsg : gettext ( "Reboot backup server?" ) ,
handler : function ( ) {
node _command ( 'reboot' ) ;
} ,
2020-09-25 18:34:54 +02:00
iconCls : 'fa fa-undo' ,
2020-04-30 12:11:08 +02:00
} ) ;
var shutdownBtn = Ext . create ( 'Proxmox.button.Button' , {
text : gettext ( 'Shutdown' ) ,
dangerous : true ,
confirmMsg : gettext ( "Shutdown backup server?" ) ,
handler : function ( ) {
node _command ( 'shutdown' ) ;
} ,
2020-09-25 18:34:54 +02:00
iconCls : 'fa fa-power-off' ,
2020-04-30 12:11:08 +02:00
} ) ;
2020-07-21 11:10:40 +02:00
var consoleBtn = Ext . create ( 'Proxmox.button.Button' , {
text : gettext ( 'Console' ) ,
iconCls : 'fa fa-terminal' ,
handler : function ( ) {
Proxmox . Utils . openXtermJsViewer ( 'shell' , 0 , Proxmox . NodeName ) ;
2020-09-25 18:34:54 +02:00
} ,
2020-07-21 11:10:40 +02:00
} ) ;
2020-11-09 16:33:22 +01:00
let version _btn = new Ext . Button ( {
text : gettext ( 'Package versions' ) ,
iconCls : 'fa fa-gift' ,
handler : function ( ) {
Proxmox . Utils . checked _command ( function ( ) { me . showVersions ( ) ; } ) ;
} ,
} ) ;
me . tbar = [ version _btn , '-' , consoleBtn , '-' , restartBtn , shutdownBtn , '->' , { xtype : 'proxmoxRRDTypeSelector' } ] ;
2020-05-26 07:32:05 +02:00
var rrdstore = Ext . create ( 'Proxmox.data.RRDStore' , {
rrdurl : "/api2/json/nodes/localhost/rrd" ,
2020-09-25 18:34:54 +02:00
model : 'pve-rrd-node' ,
2020-05-26 07:32:05 +02:00
} ) ;
me . items = {
xtype : 'container' ,
itemId : 'itemcontainer' ,
layout : 'column' ,
minWidth : 700 ,
2021-04-19 13:02:06 +02:00
listeners : {
resize : function ( panel ) {
Proxmox . Utils . updateColumns ( panel ) ;
} ,
} ,
2020-05-26 07:32:05 +02:00
defaults : {
minHeight : 320 ,
padding : 5 ,
2020-09-25 18:34:54 +02:00
columnWidth : 1 ,
2020-05-26 07:32:05 +02:00
} ,
items : [
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'CPU usage' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'cpu' , 'iowait' ] ,
2020-05-29 06:12:49 +02:00
fieldTitles : [ gettext ( 'CPU usage' ) , gettext ( 'IO wait' ) ] ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-26 07:32:05 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Server load' ) ,
fields : [ 'loadavg' ] ,
fieldTitles : [ gettext ( 'Load average' ) ] ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-26 07:32:05 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Memory usage' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'memtotal' , 'memused' ] ,
2020-05-26 07:32:05 +02:00
fieldTitles : [ gettext ( 'Total' ) , gettext ( 'RAM usage' ) ] ,
2022-05-17 10:16:46 +02:00
unit : 'bytes' ,
powerOfTwo : true ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-26 07:32:05 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Swap usage' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'swaptotal' , 'swapused' ] ,
2020-05-26 07:32:05 +02:00
fieldTitles : [ gettext ( 'Total' ) , gettext ( 'Swap usage' ) ] ,
2022-05-17 10:16:46 +02:00
unit : 'bytes' ,
powerOfTwo : true ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-26 07:32:05 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Network traffic' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'netin' , 'netout' ] ,
store : rrdstore ,
2020-05-26 07:32:05 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Root Disk usage' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'total' , 'used' ] ,
2020-05-26 07:32:05 +02:00
fieldTitles : [ gettext ( 'Total' ) , gettext ( 'Disk usage' ) ] ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-26 07:32:05 +02:00
} ,
2020-05-28 12:30:54 +02:00
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Root Disk Transfer Rate (bytes/second)' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'read_bytes' , 'write_bytes' ] ,
2020-05-28 12:30:54 +02:00
fieldTitles : [ gettext ( 'Read' ) , gettext ( 'Write' ) ] ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-28 12:30:54 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Root Disk Input/Output Operations per Second (IOPS)' ) ,
2020-09-25 18:34:54 +02:00
fields : [ 'read_ios' , 'write_ios' ] ,
2020-05-28 12:30:54 +02:00
fieldTitles : [ gettext ( 'Read' ) , gettext ( 'Write' ) ] ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-28 12:30:54 +02:00
} ,
{
xtype : 'proxmoxRRDChart' ,
title : gettext ( 'Root Disk IO Delay (ms)' ) ,
2020-05-28 19:11:37 +02:00
fields : [ 'io_delay' ] ,
fieldTitles : [ gettext ( 'IO Delay' ) ] ,
2020-09-25 18:34:54 +02:00
store : rrdstore ,
2020-05-28 12:30:54 +02:00
} ,
2020-09-25 18:34:54 +02:00
] ,
2020-05-26 07:32:05 +02:00
} ;
me . listeners = {
activate : function ( ) {
rrdstore . startUpdate ( ) ;
} ,
destroy : function ( ) {
rrdstore . stopUpdate ( ) ;
} ,
} ;
2020-04-30 12:11:08 +02:00
me . callParent ( ) ;
2021-04-19 13:02:06 +02:00
let sp = Ext . state . Manager . getProvider ( ) ;
me . mon ( sp , 'statechange' , function ( provider , key , value ) {
if ( key !== 'summarycolumns' ) {
return ;
}
Proxmox . Utils . updateColumns ( me . getComponent ( 'itemcontainer' ) ) ;
} ) ;
2020-09-25 18:34:54 +02:00
} ,
2020-04-30 12:11:08 +02:00
} ) ;