]> git.proxmox.com Git - proxmox-backup.git/blame - www/ServerStatus.js
tools/logrotate: fix compression logic
[proxmox-backup.git] / www / ServerStatus.js
CommitLineData
880fa939
DM
1Ext.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;
8acd4d9a 9 },
880fa939
DM
10 },
11 {
12 name: 'iowait',
13 // percentage
14 convert: function(value) {
15 return value*100;
8acd4d9a 16 },
880fa939
DM
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; }
8acd4d9a 36 if (ios === 0 || data.io_ticks === undefined) {
c94e1f65
DM
37 return undefined;
38 }
39 return (data.io_ticks*1000.0)/ios;
8acd4d9a 40 },
c94e1f65 41 },
880fa939 42 'loadavg',
8acd4d9a
TL
43 { type: 'date', dateFormat: 'timestamp', name: 'time' },
44 ],
880fa939 45});
ecb53af6
DM
46Ext.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);
8acd4d9a 65 },
ecb53af6
DM
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 },
8acd4d9a 76 iconCls: 'fa fa-undo',
ecb53af6
DM
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 },
8acd4d9a 86 iconCls: 'fa fa-power-off',
ecb53af6
DM
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);
8acd4d9a 94 },
653e2031
DC
95 });
96
8acd4d9a 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",
8acd4d9a 101 model: 'pve-rrd-node',
880fa939
DM
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,
8acd4d9a 112 columnWidth: 1,
880fa939
DM
113 },
114 items: [
115 {
116 xtype: 'proxmoxRRDChart',
117 title: gettext('CPU usage'),
8acd4d9a 118 fields: ['cpu', 'iowait'],
947f4525 119 fieldTitles: [gettext('CPU usage'), gettext('IO wait')],
8acd4d9a 120 store: rrdstore,
880fa939
DM
121 },
122 {
123 xtype: 'proxmoxRRDChart',
124 title: gettext('Server load'),
125 fields: ['loadavg'],
126 fieldTitles: [gettext('Load average')],
8acd4d9a 127 store: rrdstore,
880fa939
DM
128 },
129 {
130 xtype: 'proxmoxRRDChart',
131 title: gettext('Memory usage'),
8acd4d9a 132 fields: ['memtotal', 'memused'],
880fa939 133 fieldTitles: [gettext('Total'), gettext('RAM usage')],
8acd4d9a 134 store: rrdstore,
880fa939
DM
135 },
136 {
137 xtype: 'proxmoxRRDChart',
138 title: gettext('Swap usage'),
8acd4d9a 139 fields: ['swaptotal', 'swapused'],
880fa939 140 fieldTitles: [gettext('Total'), gettext('Swap usage')],
8acd4d9a 141 store: rrdstore,
880fa939
DM
142 },
143 {
144 xtype: 'proxmoxRRDChart',
145 title: gettext('Network traffic'),
8acd4d9a
TL
146 fields: ['netin', 'netout'],
147 store: rrdstore,
880fa939
DM
148 },
149 {
150 xtype: 'proxmoxRRDChart',
151 title: gettext('Root Disk usage'),
8acd4d9a 152 fields: ['total', 'used'],
880fa939 153 fieldTitles: [gettext('Total'), gettext('Disk usage')],
8acd4d9a 154 store: rrdstore,
880fa939 155 },
91e5bb49
DM
156 {
157 xtype: 'proxmoxRRDChart',
158 title: gettext('Root Disk Transfer Rate (bytes/second)'),
8acd4d9a 159 fields: ['read_bytes', 'write_bytes'],
91e5bb49 160 fieldTitles: [gettext('Read'), gettext('Write')],
8acd4d9a 161 store: rrdstore,
91e5bb49
DM
162 },
163 {
164 xtype: 'proxmoxRRDChart',
165 title: gettext('Root Disk Input/Output Operations per Second (IOPS)'),
8acd4d9a 166 fields: ['read_ios', 'write_ios'],
91e5bb49 167 fieldTitles: [gettext('Read'), gettext('Write')],
8acd4d9a 168 store: rrdstore,
91e5bb49
DM
169 },
170 {
171 xtype: 'proxmoxRRDChart',
172 title: gettext('Root Disk IO Delay (ms)'),
c94e1f65
DM
173 fields: ['io_delay'],
174 fieldTitles: [gettext('IO Delay')],
8acd4d9a 175 store: rrdstore,
91e5bb49 176 },
8acd4d9a 177 ],
880fa939
DM
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();
8acd4d9a 190 },
ecb53af6
DM
191
192});