]>
Commit | Line | Data |
---|---|---|
e653eb82 DM |
1 | Ext.define('PMG.ServerStatus', { |
2 | extend: 'Ext.panel.Panel', | |
3 | alias: 'widget.pmgServerStatus', | |
4 | ||
5 | title: gettext('Status'), | |
6 | ||
7 | border: false, | |
8 | ||
b99cf0d8 DM |
9 | scrollable: true, |
10 | ||
f534c414 | 11 | bodyPadding: 5, |
b99cf0d8 | 12 | defaults: { |
8051d921 | 13 | width: 700, |
f534c414 DC |
14 | padding: 5, |
15 | columnWidth: 1, | |
b99cf0d8 DM |
16 | }, |
17 | ||
8051d921 DM |
18 | layout: 'column', |
19 | ||
97c8b7b0 DM |
20 | controller: { |
21 | xclass: 'Ext.app.ViewController', | |
22 | ||
87517465 DC |
23 | openConsole: function() { |
24 | Proxmox.Utils.openXtermJsViewer('shell', 0, Proxmox.NodeName); | |
25 | }, | |
26 | ||
97c8b7b0 | 27 | nodeCommand: function(cmd) { |
97c8b7b0 | 28 | Proxmox.Utils.API2Request({ |
c9d55846 TL |
29 | params: { |
30 | command: cmd, | |
31 | }, | |
28eb60c0 | 32 | url: `/nodes/${Proxmox.NodeName}/status`, |
97c8b7b0 | 33 | method: 'POST', |
c9d55846 TL |
34 | waitMsgTarget: this.getView(), |
35 | failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus), | |
97c8b7b0 DM |
36 | }); |
37 | }, | |
38 | ||
39 | nodeShutdown: function() { | |
40 | this.nodeCommand('shutdown'); | |
41 | }, | |
42 | ||
43 | nodeReboot: function() { | |
44 | this.nodeCommand('reboot'); | |
c87d46fb | 45 | }, |
97c8b7b0 DM |
46 | }, |
47 | ||
e653eb82 DM |
48 | tbar: [ |
49 | { | |
50 | text: gettext("Console"), | |
97c8b7b0 | 51 | iconCls: 'fa fa-terminal', |
c87d46fb | 52 | handler: 'openConsole', |
b99cf0d8 | 53 | }, |
97c8b7b0 DM |
54 | { |
55 | xtype: 'proxmoxButton', | |
56 | text: gettext('Restart'), | |
57 | dangerous: true, | |
c9d55846 | 58 | confirmMsg: `${gettext('Node')} '${Proxmox.NodeName}' - ${gettext('Restart')}`, |
97c8b7b0 | 59 | handler: 'nodeReboot', |
c87d46fb | 60 | iconCls: 'fa fa-undo', |
97c8b7b0 DM |
61 | }, |
62 | { | |
63 | xtype: 'proxmoxButton', | |
64 | text: gettext('Shutdown'), | |
65 | dangerous: true, | |
c9d55846 | 66 | confirmMsg: `${gettext('Node')} '${Proxmox.NodeName}' - ${gettext('Shutdown')}`, |
97c8b7b0 | 67 | handler: 'nodeShutdown', |
c87d46fb | 68 | iconCls: 'fa fa-power-off', |
97c8b7b0 | 69 | }, |
b99cf0d8 DM |
70 | '->', |
71 | { | |
c87d46fb TL |
72 | xtype: 'proxmoxRRDTypeSelector', |
73 | }, | |
b99cf0d8 | 74 | ], |
e653eb82 | 75 | |
b99cf0d8 | 76 | initComponent: function() { |
c9d55846 | 77 | let me = this; |
b99cf0d8 | 78 | |
c9d55846 TL |
79 | let nodename = Proxmox.NodeName; |
80 | let rrdstore = Ext.create('Proxmox.data.RRDStore', { | |
81 | rrdurl: `/api2/json/nodes/${nodename}/rrddata`, | |
b99cf0d8 DM |
82 | fields: [ |
83 | { type: 'number', name: 'loadavg' }, | |
84 | { type: 'number', name: 'maxcpu' }, | |
05e2764b DC |
85 | { |
86 | type: 'number', | |
87 | name: 'cpu', | |
c9d55846 | 88 | convert: val => val * 100, |
05e2764b DC |
89 | }, |
90 | { | |
91 | type: 'number', | |
92 | name: 'iowait', | |
c9d55846 | 93 | convert: val => val * 100, |
05e2764b | 94 | }, |
b99cf0d8 DM |
95 | { type: 'number', name: 'memtotal' }, |
96 | { type: 'number', name: 'memused' }, | |
97 | { type: 'number', name: 'swaptotal' }, | |
98 | { type: 'number', name: 'swapused' }, | |
99 | { type: 'number', name: 'roottotal' }, | |
100 | { type: 'number', name: 'rootused' }, | |
101 | { type: 'number', name: 'netin' }, | |
102 | { type: 'number', name: 'netout' }, | |
c87d46fb TL |
103 | { type: 'date', dateFormat: 'timestamp', name: 'time' }, |
104 | ], | |
b99cf0d8 DM |
105 | }); |
106 | ||
107 | Ext.apply(me, { | |
108 | items: [ | |
109 | { | |
110 | xtype: 'proxmoxRRDChart', | |
111 | title: gettext('CPU usage'), | |
112 | unit: 'percent', | |
c87d46fb | 113 | fields: ['cpu', 'iowait'], |
b99cf0d8 | 114 | fieldTitles: [gettext('CPU usage'), gettext('IO delay')], |
c87d46fb | 115 | store: rrdstore, |
b99cf0d8 DM |
116 | }, |
117 | { | |
118 | xtype: 'proxmoxRRDChart', | |
119 | title: gettext('Server load'), | |
120 | fields: ['loadavg'], | |
121 | fieldTitles: [gettext('Load average')], | |
c87d46fb | 122 | store: rrdstore, |
b99cf0d8 DM |
123 | }, |
124 | { | |
125 | xtype: 'proxmoxRRDChart', | |
126 | title: gettext('Memory usage'), | |
127 | unit: 'bytes', | |
c87d46fb | 128 | fields: ['memtotal', 'memused'], |
b99cf0d8 | 129 | fieldTitles: [gettext('Total'), gettext('Used')], |
c87d46fb | 130 | store: rrdstore, |
b99cf0d8 DM |
131 | }, |
132 | { | |
133 | xtype: 'proxmoxRRDChart', | |
134 | title: gettext('Swap usage'), | |
135 | unit: 'bytes', | |
c87d46fb | 136 | fields: ['swaptotal', 'swapused'], |
b99cf0d8 | 137 | fieldTitles: [gettext('Total'), gettext('Used')], |
c87d46fb | 138 | store: rrdstore, |
b99cf0d8 DM |
139 | }, |
140 | { | |
141 | xtype: 'proxmoxRRDChart', | |
142 | title: gettext('Network traffic'), | |
143 | unit: 'bytespersecond', | |
c87d46fb | 144 | fields: ['netin', 'netout'], |
b99cf0d8 | 145 | fieldTitles: [gettext('Ingress'), gettext('Egress')], |
c87d46fb | 146 | store: rrdstore, |
b99cf0d8 DM |
147 | }, |
148 | { | |
149 | xtype: 'proxmoxRRDChart', | |
150 | title: gettext('Disk usage'), | |
151 | unit: 'bytes', | |
c87d46fb | 152 | fields: ['roottotal', 'rootused'], |
b99cf0d8 | 153 | fieldTitles: [gettext('Total'), gettext('Used')], |
c87d46fb TL |
154 | store: rrdstore, |
155 | }, | |
b99cf0d8 DM |
156 | ], |
157 | listeners: { | |
c9d55846 TL |
158 | resize: panel => Proxmox.Utils.updateColumnWidth(panel), |
159 | activate: () => rrdstore.startUpdate(), | |
160 | destroy: () => rrdstore.stopUpdate(), | |
c87d46fb | 161 | }, |
b99cf0d8 | 162 | }); |
c9d55846 | 163 | |
b99cf0d8 | 164 | me.callParent(); |
5958ebdf DC |
165 | |
166 | let sp = Ext.state.Manager.getProvider(); | |
167 | me.mon(sp, 'statechange', function(provider, key, value) { | |
168 | if (key !== 'summarycolumns') { | |
169 | return; | |
170 | } | |
171 | Proxmox.Utils.updateColumnWidth(me); | |
172 | }); | |
c87d46fb | 173 | }, |
e653eb82 | 174 | }); |