]> git.proxmox.com Git - pmg-gui.git/blame - js/ServerStatus.js
quarantine list: code cleanup
[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
8051d921 11 bodyPadding: '10 0 0 0',
b99cf0d8 12 defaults: {
8051d921 13 width: 700,
c87d46fb 14 padding: '0 0 10 10',
b99cf0d8
DM
15 },
16
8051d921
DM
17 layout: 'column',
18
97c8b7b0
DM
19 controller: {
20 xclass: 'Ext.app.ViewController',
21
87517465
DC
22 openConsole: function() {
23 Proxmox.Utils.openXtermJsViewer('shell', 0, Proxmox.NodeName);
24 },
25
97c8b7b0 26 nodeCommand: function(cmd) {
28eb60c0 27 var view = this.getView();
97c8b7b0
DM
28 Proxmox.Utils.API2Request({
29 params: { command: cmd },
28eb60c0 30 url: `/nodes/${Proxmox.NodeName}/status`,
97c8b7b0 31 method: 'POST',
28eb60c0 32 waitMsgTarget: view,
97c8b7b0
DM
33 failure: function(response, opts) {
34 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
c87d46fb 35 },
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,
58 confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Restart'),
59 handler: 'nodeReboot',
c87d46fb 60 iconCls: 'fa fa-undo',
97c8b7b0
DM
61 },
62 {
63 xtype: 'proxmoxButton',
64 text: gettext('Shutdown'),
65 dangerous: true,
66 confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Shutdown'),
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
DM
76 initComponent: function() {
77 var me = this;
78
79 var nodename = Proxmox.NodeName;
80 var rrdstore = Ext.create('Proxmox.data.RRDStore', {
81 rrdurl: "/api2/json/nodes/" + nodename + "/rrddata",
82 fields: [
83 { type: 'number', name: 'loadavg' },
84 { type: 'number', name: 'maxcpu' },
05e2764b
DC
85 {
86 type: 'number',
87 name: 'cpu',
88 convert: function(val) {
89 return val*100;
c87d46fb 90 },
05e2764b
DC
91 },
92 {
93 type: 'number',
94 name: 'iowait',
95 convert: function(val) {
96 return val*100;
c87d46fb 97 },
05e2764b 98 },
b99cf0d8
DM
99 { type: 'number', name: 'memtotal' },
100 { type: 'number', name: 'memused' },
101 { type: 'number', name: 'swaptotal' },
102 { type: 'number', name: 'swapused' },
103 { type: 'number', name: 'roottotal' },
104 { type: 'number', name: 'rootused' },
105 { type: 'number', name: 'netin' },
106 { type: 'number', name: 'netout' },
c87d46fb
TL
107 { type: 'date', dateFormat: 'timestamp', name: 'time' },
108 ],
b99cf0d8
DM
109 });
110
111 Ext.apply(me, {
112 items: [
113 {
114 xtype: 'proxmoxRRDChart',
115 title: gettext('CPU usage'),
116 unit: 'percent',
c87d46fb 117 fields: ['cpu', 'iowait'],
b99cf0d8 118 fieldTitles: [gettext('CPU usage'), gettext('IO delay')],
c87d46fb 119 store: rrdstore,
b99cf0d8
DM
120 },
121 {
122 xtype: 'proxmoxRRDChart',
123 title: gettext('Server load'),
124 fields: ['loadavg'],
125 fieldTitles: [gettext('Load average')],
c87d46fb 126 store: rrdstore,
b99cf0d8
DM
127 },
128 {
129 xtype: 'proxmoxRRDChart',
130 title: gettext('Memory usage'),
131 unit: 'bytes',
c87d46fb 132 fields: ['memtotal', 'memused'],
b99cf0d8 133 fieldTitles: [gettext('Total'), gettext('Used')],
c87d46fb 134 store: rrdstore,
b99cf0d8
DM
135 },
136 {
137 xtype: 'proxmoxRRDChart',
138 title: gettext('Swap usage'),
139 unit: 'bytes',
c87d46fb 140 fields: ['swaptotal', 'swapused'],
b99cf0d8 141 fieldTitles: [gettext('Total'), gettext('Used')],
c87d46fb 142 store: rrdstore,
b99cf0d8
DM
143 },
144 {
145 xtype: 'proxmoxRRDChart',
146 title: gettext('Network traffic'),
147 unit: 'bytespersecond',
c87d46fb 148 fields: ['netin', 'netout'],
b99cf0d8 149 fieldTitles: [gettext('Ingress'), gettext('Egress')],
c87d46fb 150 store: rrdstore,
b99cf0d8
DM
151 },
152 {
153 xtype: 'proxmoxRRDChart',
154 title: gettext('Disk usage'),
155 unit: 'bytes',
c87d46fb 156 fields: ['roottotal', 'rootused'],
b99cf0d8 157 fieldTitles: [gettext('Total'), gettext('Used')],
c87d46fb
TL
158 store: rrdstore,
159 },
b99cf0d8
DM
160 ],
161 listeners: {
162 activate: function() {
163 rrdstore.startUpdate();
164 },
165 destroy: function() {
166 rrdstore.stopUpdate();
c87d46fb
TL
167 },
168 },
b99cf0d8
DM
169 });
170 me.callParent();
c87d46fb 171 },
e653eb82 172});
c87d46fb 173