]> git.proxmox.com Git - pmg-gui.git/blame - js/ServerStatus.js
dkim settings: improve label for signing domain source selection
[pmg-gui.git] / js / ServerStatus.js
CommitLineData
e653eb82
DM
1Ext.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 48 tbar: [
c621e29b
TL
49 {
50 text: gettext('Package versions'),
51 iconCls: 'fa fa-gift',
52 handler: () => Proxmox.Utils.checked_command(() => {
53 Ext.create('Proxmox.window.PackageVersions', {
54 autoShow: true,
55 });
56 }),
57 },
e653eb82
DM
58 {
59 text: gettext("Console"),
97c8b7b0 60 iconCls: 'fa fa-terminal',
c87d46fb 61 handler: 'openConsole',
b99cf0d8 62 },
97c8b7b0
DM
63 {
64 xtype: 'proxmoxButton',
65 text: gettext('Restart'),
66 dangerous: true,
c9d55846 67 confirmMsg: `${gettext('Node')} '${Proxmox.NodeName}' - ${gettext('Restart')}`,
97c8b7b0 68 handler: 'nodeReboot',
c87d46fb 69 iconCls: 'fa fa-undo',
97c8b7b0
DM
70 },
71 {
72 xtype: 'proxmoxButton',
73 text: gettext('Shutdown'),
74 dangerous: true,
c9d55846 75 confirmMsg: `${gettext('Node')} '${Proxmox.NodeName}' - ${gettext('Shutdown')}`,
97c8b7b0 76 handler: 'nodeShutdown',
c87d46fb 77 iconCls: 'fa fa-power-off',
97c8b7b0 78 },
b99cf0d8
DM
79 '->',
80 {
c87d46fb
TL
81 xtype: 'proxmoxRRDTypeSelector',
82 },
b99cf0d8 83 ],
e653eb82 84
b99cf0d8 85 initComponent: function() {
c9d55846 86 let me = this;
b99cf0d8 87
c9d55846
TL
88 let nodename = Proxmox.NodeName;
89 let rrdstore = Ext.create('Proxmox.data.RRDStore', {
90 rrdurl: `/api2/json/nodes/${nodename}/rrddata`,
b99cf0d8
DM
91 fields: [
92 { type: 'number', name: 'loadavg' },
93 { type: 'number', name: 'maxcpu' },
05e2764b
DC
94 {
95 type: 'number',
96 name: 'cpu',
c9d55846 97 convert: val => val * 100,
05e2764b
DC
98 },
99 {
100 type: 'number',
101 name: 'iowait',
c9d55846 102 convert: val => val * 100,
05e2764b 103 },
b99cf0d8
DM
104 { type: 'number', name: 'memtotal' },
105 { type: 'number', name: 'memused' },
106 { type: 'number', name: 'swaptotal' },
107 { type: 'number', name: 'swapused' },
108 { type: 'number', name: 'roottotal' },
109 { type: 'number', name: 'rootused' },
110 { type: 'number', name: 'netin' },
111 { type: 'number', name: 'netout' },
c87d46fb
TL
112 { type: 'date', dateFormat: 'timestamp', name: 'time' },
113 ],
b99cf0d8
DM
114 });
115
116 Ext.apply(me, {
117 items: [
118 {
119 xtype: 'proxmoxRRDChart',
120 title: gettext('CPU usage'),
121 unit: 'percent',
c87d46fb 122 fields: ['cpu', 'iowait'],
b99cf0d8 123 fieldTitles: [gettext('CPU usage'), gettext('IO delay')],
c87d46fb 124 store: rrdstore,
b99cf0d8
DM
125 },
126 {
127 xtype: 'proxmoxRRDChart',
128 title: gettext('Server load'),
129 fields: ['loadavg'],
130 fieldTitles: [gettext('Load average')],
c87d46fb 131 store: rrdstore,
b99cf0d8
DM
132 },
133 {
134 xtype: 'proxmoxRRDChart',
135 title: gettext('Memory usage'),
136 unit: 'bytes',
c87d46fb 137 fields: ['memtotal', 'memused'],
b99cf0d8 138 fieldTitles: [gettext('Total'), gettext('Used')],
c87d46fb 139 store: rrdstore,
b99cf0d8
DM
140 },
141 {
142 xtype: 'proxmoxRRDChart',
143 title: gettext('Swap usage'),
144 unit: 'bytes',
c87d46fb 145 fields: ['swaptotal', 'swapused'],
b99cf0d8 146 fieldTitles: [gettext('Total'), gettext('Used')],
c87d46fb 147 store: rrdstore,
b99cf0d8
DM
148 },
149 {
150 xtype: 'proxmoxRRDChart',
151 title: gettext('Network traffic'),
152 unit: 'bytespersecond',
c87d46fb 153 fields: ['netin', 'netout'],
b99cf0d8 154 fieldTitles: [gettext('Ingress'), gettext('Egress')],
c87d46fb 155 store: rrdstore,
b99cf0d8
DM
156 },
157 {
158 xtype: 'proxmoxRRDChart',
159 title: gettext('Disk usage'),
160 unit: 'bytes',
c87d46fb 161 fields: ['roottotal', 'rootused'],
b99cf0d8 162 fieldTitles: [gettext('Total'), gettext('Used')],
c87d46fb
TL
163 store: rrdstore,
164 },
b99cf0d8
DM
165 ],
166 listeners: {
c9d55846
TL
167 resize: panel => Proxmox.Utils.updateColumnWidth(panel),
168 activate: () => rrdstore.startUpdate(),
169 destroy: () => rrdstore.stopUpdate(),
c87d46fb 170 },
b99cf0d8 171 });
c9d55846 172
b99cf0d8 173 me.callParent();
5958ebdf
DC
174
175 let sp = Ext.state.Manager.getProvider();
176 me.mon(sp, 'statechange', function(provider, key, value) {
177 if (key !== 'summarycolumns') {
178 return;
179 }
180 Proxmox.Utils.updateColumnWidth(me);
181 });
c87d46fb 182 },
e653eb82 183});