]>
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) { |
28eb60c0 | 28 | var view = this.getView(); |
97c8b7b0 DM |
29 | Proxmox.Utils.API2Request({ |
30 | params: { command: cmd }, | |
28eb60c0 | 31 | url: `/nodes/${Proxmox.NodeName}/status`, |
97c8b7b0 | 32 | method: 'POST', |
28eb60c0 | 33 | waitMsgTarget: view, |
97c8b7b0 DM |
34 | failure: function(response, opts) { |
35 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
c87d46fb | 36 | }, |
97c8b7b0 DM |
37 | }); |
38 | }, | |
39 | ||
40 | nodeShutdown: function() { | |
41 | this.nodeCommand('shutdown'); | |
42 | }, | |
43 | ||
44 | nodeReboot: function() { | |
45 | this.nodeCommand('reboot'); | |
c87d46fb | 46 | }, |
97c8b7b0 DM |
47 | }, |
48 | ||
e653eb82 DM |
49 | tbar: [ |
50 | { | |
51 | text: gettext("Console"), | |
97c8b7b0 | 52 | iconCls: 'fa fa-terminal', |
c87d46fb | 53 | handler: 'openConsole', |
b99cf0d8 | 54 | }, |
97c8b7b0 DM |
55 | { |
56 | xtype: 'proxmoxButton', | |
57 | text: gettext('Restart'), | |
58 | dangerous: true, | |
59 | confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Restart'), | |
60 | handler: 'nodeReboot', | |
c87d46fb | 61 | iconCls: 'fa fa-undo', |
97c8b7b0 DM |
62 | }, |
63 | { | |
64 | xtype: 'proxmoxButton', | |
65 | text: gettext('Shutdown'), | |
66 | dangerous: true, | |
67 | confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Shutdown'), | |
68 | handler: 'nodeShutdown', | |
c87d46fb | 69 | iconCls: 'fa fa-power-off', |
97c8b7b0 | 70 | }, |
b99cf0d8 DM |
71 | '->', |
72 | { | |
c87d46fb TL |
73 | xtype: 'proxmoxRRDTypeSelector', |
74 | }, | |
b99cf0d8 | 75 | ], |
e653eb82 | 76 | |
b99cf0d8 DM |
77 | initComponent: function() { |
78 | var me = this; | |
79 | ||
80 | var nodename = Proxmox.NodeName; | |
81 | var rrdstore = Ext.create('Proxmox.data.RRDStore', { | |
82 | rrdurl: "/api2/json/nodes/" + nodename + "/rrddata", | |
83 | fields: [ | |
84 | { type: 'number', name: 'loadavg' }, | |
85 | { type: 'number', name: 'maxcpu' }, | |
05e2764b DC |
86 | { |
87 | type: 'number', | |
88 | name: 'cpu', | |
89 | convert: function(val) { | |
90 | return val*100; | |
c87d46fb | 91 | }, |
05e2764b DC |
92 | }, |
93 | { | |
94 | type: 'number', | |
95 | name: 'iowait', | |
96 | convert: function(val) { | |
97 | return val*100; | |
c87d46fb | 98 | }, |
05e2764b | 99 | }, |
b99cf0d8 DM |
100 | { type: 'number', name: 'memtotal' }, |
101 | { type: 'number', name: 'memused' }, | |
102 | { type: 'number', name: 'swaptotal' }, | |
103 | { type: 'number', name: 'swapused' }, | |
104 | { type: 'number', name: 'roottotal' }, | |
105 | { type: 'number', name: 'rootused' }, | |
106 | { type: 'number', name: 'netin' }, | |
107 | { type: 'number', name: 'netout' }, | |
c87d46fb TL |
108 | { type: 'date', dateFormat: 'timestamp', name: 'time' }, |
109 | ], | |
b99cf0d8 DM |
110 | }); |
111 | ||
112 | Ext.apply(me, { | |
113 | items: [ | |
114 | { | |
115 | xtype: 'proxmoxRRDChart', | |
116 | title: gettext('CPU usage'), | |
117 | unit: 'percent', | |
c87d46fb | 118 | fields: ['cpu', 'iowait'], |
b99cf0d8 | 119 | fieldTitles: [gettext('CPU usage'), gettext('IO delay')], |
c87d46fb | 120 | store: rrdstore, |
b99cf0d8 DM |
121 | }, |
122 | { | |
123 | xtype: 'proxmoxRRDChart', | |
124 | title: gettext('Server load'), | |
125 | fields: ['loadavg'], | |
126 | fieldTitles: [gettext('Load average')], | |
c87d46fb | 127 | store: rrdstore, |
b99cf0d8 DM |
128 | }, |
129 | { | |
130 | xtype: 'proxmoxRRDChart', | |
131 | title: gettext('Memory usage'), | |
132 | unit: 'bytes', | |
c87d46fb | 133 | fields: ['memtotal', 'memused'], |
b99cf0d8 | 134 | fieldTitles: [gettext('Total'), gettext('Used')], |
c87d46fb | 135 | store: rrdstore, |
b99cf0d8 DM |
136 | }, |
137 | { | |
138 | xtype: 'proxmoxRRDChart', | |
139 | title: gettext('Swap usage'), | |
140 | unit: 'bytes', | |
c87d46fb | 141 | fields: ['swaptotal', 'swapused'], |
b99cf0d8 | 142 | fieldTitles: [gettext('Total'), gettext('Used')], |
c87d46fb | 143 | store: rrdstore, |
b99cf0d8 DM |
144 | }, |
145 | { | |
146 | xtype: 'proxmoxRRDChart', | |
147 | title: gettext('Network traffic'), | |
148 | unit: 'bytespersecond', | |
c87d46fb | 149 | fields: ['netin', 'netout'], |
b99cf0d8 | 150 | fieldTitles: [gettext('Ingress'), gettext('Egress')], |
c87d46fb | 151 | store: rrdstore, |
b99cf0d8 DM |
152 | }, |
153 | { | |
154 | xtype: 'proxmoxRRDChart', | |
155 | title: gettext('Disk usage'), | |
156 | unit: 'bytes', | |
c87d46fb | 157 | fields: ['roottotal', 'rootused'], |
b99cf0d8 | 158 | fieldTitles: [gettext('Total'), gettext('Used')], |
c87d46fb TL |
159 | store: rrdstore, |
160 | }, | |
b99cf0d8 DM |
161 | ], |
162 | listeners: { | |
f534c414 DC |
163 | resize: function(panel) { |
164 | Proxmox.Utils.updateColumns(panel); | |
165 | }, | |
b99cf0d8 DM |
166 | activate: function() { |
167 | rrdstore.startUpdate(); | |
168 | }, | |
169 | destroy: function() { | |
170 | rrdstore.stopUpdate(); | |
c87d46fb TL |
171 | }, |
172 | }, | |
b99cf0d8 DM |
173 | }); |
174 | me.callParent(); | |
c87d46fb | 175 | }, |
e653eb82 | 176 | }); |
c87d46fb | 177 |