]>
Commit | Line | Data |
---|---|---|
2c1d504e | 1 | /*global Proxmox*/ |
e653eb82 DM |
2 | Ext.define('PMG.ServerStatus', { |
3 | extend: 'Ext.panel.Panel', | |
4 | alias: 'widget.pmgServerStatus', | |
5 | ||
6 | title: gettext('Status'), | |
7 | ||
8 | border: false, | |
9 | ||
b99cf0d8 DM |
10 | scrollable: true, |
11 | ||
8051d921 | 12 | bodyPadding: '10 0 0 0', |
b99cf0d8 | 13 | defaults: { |
8051d921 DM |
14 | width: 700, |
15 | padding: '0 0 10 10' | |
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 DM |
27 | nodeCommand: function(cmd) { |
28 | var me = this.getView(); | |
29 | Proxmox.Utils.API2Request({ | |
30 | params: { command: cmd }, | |
31 | url: '/nodes/' + Proxmox.NodeName + '/status', | |
32 | method: 'POST', | |
33 | waitMsgTarget: me, | |
34 | failure: function(response, opts) { | |
35 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
36 | } | |
37 | }); | |
38 | }, | |
39 | ||
40 | nodeShutdown: function() { | |
41 | this.nodeCommand('shutdown'); | |
42 | }, | |
43 | ||
44 | nodeReboot: function() { | |
45 | this.nodeCommand('reboot'); | |
46 | } | |
47 | }, | |
48 | ||
e653eb82 DM |
49 | tbar: [ |
50 | { | |
51 | text: gettext("Console"), | |
97c8b7b0 | 52 | iconCls: 'fa fa-terminal', |
87517465 | 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', | |
61 | iconCls: 'fa fa-undo' | |
62 | }, | |
63 | { | |
64 | xtype: 'proxmoxButton', | |
65 | text: gettext('Shutdown'), | |
66 | dangerous: true, | |
67 | confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Shutdown'), | |
68 | handler: 'nodeShutdown', | |
69 | iconCls: 'fa fa-power-off' | |
70 | }, | |
b99cf0d8 DM |
71 | '->', |
72 | { | |
73 | xtype: 'proxmoxRRDTypeSelector' | |
e653eb82 | 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; | |
91 | } | |
92 | }, | |
93 | { | |
94 | type: 'number', | |
95 | name: 'iowait', | |
96 | convert: function(val) { | |
97 | return val*100; | |
98 | } | |
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' }, | |
108 | { type: 'date', dateFormat: 'timestamp', name: 'time' } | |
109 | ] | |
110 | }); | |
111 | ||
112 | Ext.apply(me, { | |
113 | items: [ | |
114 | { | |
115 | xtype: 'proxmoxRRDChart', | |
116 | title: gettext('CPU usage'), | |
117 | unit: 'percent', | |
118 | fields: ['cpu','iowait'], | |
119 | fieldTitles: [gettext('CPU usage'), gettext('IO delay')], | |
120 | store: rrdstore | |
121 | }, | |
122 | { | |
123 | xtype: 'proxmoxRRDChart', | |
124 | title: gettext('Server load'), | |
125 | fields: ['loadavg'], | |
126 | fieldTitles: [gettext('Load average')], | |
127 | store: rrdstore | |
128 | }, | |
129 | { | |
130 | xtype: 'proxmoxRRDChart', | |
131 | title: gettext('Memory usage'), | |
132 | unit: 'bytes', | |
133 | fields: ['memtotal','memused'], | |
134 | fieldTitles: [gettext('Total'), gettext('Used')], | |
135 | store: rrdstore | |
136 | }, | |
137 | { | |
138 | xtype: 'proxmoxRRDChart', | |
139 | title: gettext('Swap usage'), | |
140 | unit: 'bytes', | |
141 | fields: ['swaptotal','swapused'], | |
142 | fieldTitles: [gettext('Total'), gettext('Used')], | |
143 | store: rrdstore | |
144 | }, | |
145 | { | |
146 | xtype: 'proxmoxRRDChart', | |
147 | title: gettext('Network traffic'), | |
148 | unit: 'bytespersecond', | |
149 | fields: ['netin','netout'], | |
150 | fieldTitles: [gettext('Ingress'), gettext('Egress')], | |
151 | store: rrdstore | |
152 | }, | |
153 | { | |
154 | xtype: 'proxmoxRRDChart', | |
155 | title: gettext('Disk usage'), | |
156 | unit: 'bytes', | |
157 | fields: ['roottotal','rootused'], | |
158 | fieldTitles: [gettext('Total'), gettext('Used')], | |
159 | store: rrdstore | |
160 | } | |
161 | ], | |
162 | listeners: { | |
163 | activate: function() { | |
164 | rrdstore.startUpdate(); | |
165 | }, | |
166 | destroy: function() { | |
167 | rrdstore.stopUpdate(); | |
168 | } | |
169 | } | |
170 | }); | |
171 | me.callParent(); | |
172 | } | |
e653eb82 DM |
173 | }); |
174 |