]>
Commit | Line | Data |
---|---|---|
880fa939 DM |
1 | Ext.define('pve-rrd-node', { |
2 | extend: 'Ext.data.Model', | |
3 | fields: [ | |
4 | { | |
5 | name: 'cpu', | |
6 | // percentage | |
7 | convert: function(value) { | |
8 | return value*100; | |
9 | } | |
10 | }, | |
11 | { | |
12 | name: 'iowait', | |
13 | // percentage | |
14 | convert: function(value) { | |
15 | return value*100; | |
16 | } | |
17 | }, | |
18 | 'netin', | |
19 | 'netout', | |
20 | 'memtotal', | |
21 | 'memused', | |
22 | 'swaptotal', | |
23 | 'swapused', | |
c94e1f65 DM |
24 | 'total', |
25 | 'used', | |
26 | 'read_ios', | |
27 | 'read_bytes', | |
28 | 'write_ios', | |
29 | 'write_bytes', | |
30 | 'io_ticks', | |
31 | { | |
32 | name: 'io_delay', calculate: function(data) { | |
33 | let ios = 0; | |
34 | if (data.read_ios !== undefined) { ios += data.read_ios; } | |
35 | if (data.write_ios !== undefined) { ios += data.write_ios; } | |
36 | if (ios == 0 || data.io_ticks === undefined) { | |
37 | return undefined; | |
38 | } | |
39 | return (data.io_ticks*1000.0)/ios; | |
40 | } | |
41 | }, | |
880fa939 DM |
42 | 'loadavg', |
43 | { type: 'date', dateFormat: 'timestamp', name: 'time' } | |
44 | ] | |
45 | }); | |
ecb53af6 DM |
46 | Ext.define('PBS.ServerStatus', { |
47 | extend: 'Ext.panel.Panel', | |
48 | alias: 'widget.pbsServerStatus', | |
49 | ||
50 | title: gettext('ServerStatus'), | |
51 | ||
880fa939 | 52 | scrollable: true, |
ecb53af6 DM |
53 | |
54 | initComponent: function() { | |
55 | var me = this; | |
56 | ||
57 | var node_command = function(cmd) { | |
58 | Proxmox.Utils.API2Request({ | |
59 | params: { command: cmd }, | |
60 | url: '/nodes/localhost/status', | |
61 | method: 'POST', | |
62 | waitMsgTarget: me, | |
63 | failure: function(response, opts) { | |
64 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
65 | } | |
66 | }); | |
67 | }; | |
68 | ||
69 | var restartBtn = Ext.create('Proxmox.button.Button', { | |
70 | text: gettext('Reboot'), | |
71 | dangerous: true, | |
72 | confirmMsg: gettext("Reboot backup server?"), | |
73 | handler: function() { | |
74 | node_command('reboot'); | |
75 | }, | |
76 | iconCls: 'fa fa-undo' | |
77 | }); | |
78 | ||
79 | var shutdownBtn = Ext.create('Proxmox.button.Button', { | |
80 | text: gettext('Shutdown'), | |
81 | dangerous: true, | |
82 | confirmMsg: gettext("Shutdown backup server?"), | |
83 | handler: function() { | |
84 | node_command('shutdown'); | |
85 | }, | |
86 | iconCls: 'fa fa-power-off' | |
87 | }); | |
88 | ||
653e2031 DC |
89 | var consoleBtn = Ext.create('Proxmox.button.Button', { |
90 | text: gettext('Console'), | |
91 | iconCls: 'fa fa-terminal', | |
92 | handler: function() { | |
93 | Proxmox.Utils.openXtermJsViewer('shell', 0, Proxmox.NodeName); | |
94 | } | |
95 | }); | |
96 | ||
97 | me.tbar = [ consoleBtn, restartBtn, shutdownBtn, '->', { xtype: 'proxmoxRRDTypeSelector' } ]; | |
880fa939 DM |
98 | |
99 | var rrdstore = Ext.create('Proxmox.data.RRDStore', { | |
100 | rrdurl: "/api2/json/nodes/localhost/rrd", | |
101 | model: 'pve-rrd-node' | |
102 | }); | |
103 | ||
104 | me.items = { | |
105 | xtype: 'container', | |
106 | itemId: 'itemcontainer', | |
107 | layout: 'column', | |
108 | minWidth: 700, | |
109 | defaults: { | |
110 | minHeight: 320, | |
111 | padding: 5, | |
112 | columnWidth: 1 | |
113 | }, | |
114 | items: [ | |
115 | { | |
116 | xtype: 'proxmoxRRDChart', | |
117 | title: gettext('CPU usage'), | |
118 | fields: ['cpu','iowait'], | |
947f4525 | 119 | fieldTitles: [gettext('CPU usage'), gettext('IO wait')], |
880fa939 DM |
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 | fields: ['memtotal','memused'], | |
133 | fieldTitles: [gettext('Total'), gettext('RAM usage')], | |
134 | store: rrdstore | |
135 | }, | |
136 | { | |
137 | xtype: 'proxmoxRRDChart', | |
138 | title: gettext('Swap usage'), | |
139 | fields: ['swaptotal','swapused'], | |
140 | fieldTitles: [gettext('Total'), gettext('Swap usage')], | |
141 | store: rrdstore | |
142 | }, | |
143 | { | |
144 | xtype: 'proxmoxRRDChart', | |
145 | title: gettext('Network traffic'), | |
146 | fields: ['netin','netout'], | |
147 | store: rrdstore | |
148 | }, | |
149 | { | |
150 | xtype: 'proxmoxRRDChart', | |
151 | title: gettext('Root Disk usage'), | |
91e5bb49 | 152 | fields: ['total','used'], |
880fa939 DM |
153 | fieldTitles: [gettext('Total'), gettext('Disk usage')], |
154 | store: rrdstore | |
155 | }, | |
91e5bb49 DM |
156 | { |
157 | xtype: 'proxmoxRRDChart', | |
158 | title: gettext('Root Disk Transfer Rate (bytes/second)'), | |
159 | fields: ['read_bytes','write_bytes'], | |
160 | fieldTitles: [gettext('Read'), gettext('Write')], | |
161 | store: rrdstore | |
162 | }, | |
163 | { | |
164 | xtype: 'proxmoxRRDChart', | |
165 | title: gettext('Root Disk Input/Output Operations per Second (IOPS)'), | |
166 | fields: ['read_ios','write_ios'], | |
167 | fieldTitles: [gettext('Read'), gettext('Write')], | |
168 | store: rrdstore | |
169 | }, | |
170 | { | |
171 | xtype: 'proxmoxRRDChart', | |
172 | title: gettext('Root Disk IO Delay (ms)'), | |
c94e1f65 DM |
173 | fields: ['io_delay'], |
174 | fieldTitles: [gettext('IO Delay')], | |
91e5bb49 DM |
175 | store: rrdstore |
176 | }, | |
880fa939 DM |
177 | ] |
178 | }; | |
179 | ||
180 | me.listeners = { | |
181 | activate: function() { | |
182 | rrdstore.startUpdate(); | |
183 | }, | |
184 | destroy: function() { | |
185 | rrdstore.stopUpdate(); | |
186 | }, | |
187 | }; | |
ecb53af6 DM |
188 | |
189 | me.callParent(); | |
190 | } | |
191 | ||
192 | }); |