]>
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 | ||
880fa939 DM |
89 | me.tbar = [ restartBtn, shutdownBtn, '->', { xtype: 'proxmoxRRDTypeSelector' } ]; |
90 | ||
91 | var rrdstore = Ext.create('Proxmox.data.RRDStore', { | |
92 | rrdurl: "/api2/json/nodes/localhost/rrd", | |
93 | model: 'pve-rrd-node' | |
94 | }); | |
95 | ||
96 | me.items = { | |
97 | xtype: 'container', | |
98 | itemId: 'itemcontainer', | |
99 | layout: 'column', | |
100 | minWidth: 700, | |
101 | defaults: { | |
102 | minHeight: 320, | |
103 | padding: 5, | |
104 | columnWidth: 1 | |
105 | }, | |
106 | items: [ | |
107 | { | |
108 | xtype: 'proxmoxRRDChart', | |
109 | title: gettext('CPU usage'), | |
110 | fields: ['cpu','iowait'], | |
947f4525 | 111 | fieldTitles: [gettext('CPU usage'), gettext('IO wait')], |
880fa939 DM |
112 | store: rrdstore |
113 | }, | |
114 | { | |
115 | xtype: 'proxmoxRRDChart', | |
116 | title: gettext('Server load'), | |
117 | fields: ['loadavg'], | |
118 | fieldTitles: [gettext('Load average')], | |
119 | store: rrdstore | |
120 | }, | |
121 | { | |
122 | xtype: 'proxmoxRRDChart', | |
123 | title: gettext('Memory usage'), | |
124 | fields: ['memtotal','memused'], | |
125 | fieldTitles: [gettext('Total'), gettext('RAM usage')], | |
126 | store: rrdstore | |
127 | }, | |
128 | { | |
129 | xtype: 'proxmoxRRDChart', | |
130 | title: gettext('Swap usage'), | |
131 | fields: ['swaptotal','swapused'], | |
132 | fieldTitles: [gettext('Total'), gettext('Swap usage')], | |
133 | store: rrdstore | |
134 | }, | |
135 | { | |
136 | xtype: 'proxmoxRRDChart', | |
137 | title: gettext('Network traffic'), | |
138 | fields: ['netin','netout'], | |
139 | store: rrdstore | |
140 | }, | |
141 | { | |
142 | xtype: 'proxmoxRRDChart', | |
143 | title: gettext('Root Disk usage'), | |
91e5bb49 | 144 | fields: ['total','used'], |
880fa939 DM |
145 | fieldTitles: [gettext('Total'), gettext('Disk usage')], |
146 | store: rrdstore | |
147 | }, | |
91e5bb49 DM |
148 | { |
149 | xtype: 'proxmoxRRDChart', | |
150 | title: gettext('Root Disk Transfer Rate (bytes/second)'), | |
151 | fields: ['read_bytes','write_bytes'], | |
152 | fieldTitles: [gettext('Read'), gettext('Write')], | |
153 | store: rrdstore | |
154 | }, | |
155 | { | |
156 | xtype: 'proxmoxRRDChart', | |
157 | title: gettext('Root Disk Input/Output Operations per Second (IOPS)'), | |
158 | fields: ['read_ios','write_ios'], | |
159 | fieldTitles: [gettext('Read'), gettext('Write')], | |
160 | store: rrdstore | |
161 | }, | |
162 | { | |
163 | xtype: 'proxmoxRRDChart', | |
164 | title: gettext('Root Disk IO Delay (ms)'), | |
c94e1f65 DM |
165 | fields: ['io_delay'], |
166 | fieldTitles: [gettext('IO Delay')], | |
91e5bb49 DM |
167 | store: rrdstore |
168 | }, | |
880fa939 DM |
169 | ] |
170 | }; | |
171 | ||
172 | me.listeners = { | |
173 | activate: function() { | |
174 | rrdstore.startUpdate(); | |
175 | }, | |
176 | destroy: function() { | |
177 | rrdstore.stopUpdate(); | |
178 | }, | |
179 | }; | |
ecb53af6 DM |
180 | |
181 | me.callParent(); | |
182 | } | |
183 | ||
184 | }); |