|
24 | 24 | memoryUsageLine, |
25 | 25 | cpuLoadChart, |
26 | 26 | cpuLoadLine, |
27 | | - storagesCgart, |
| 27 | + activeusersChart, |
28 | 28 | sharesChart; |
29 | 29 |
|
30 | 30 | $(document).ready(function () { |
31 | 31 |
|
32 | 32 | var updateTimer = setInterval(updateInfo, 1000); |
33 | 33 |
|
| 34 | + resizeSystemCharts(); |
| 35 | + |
34 | 36 | function updateInfo() { |
35 | 37 | var url = OC.generateUrl('/apps/serverinfo/update'); |
36 | 38 |
|
37 | 39 | $.get(url).success(function (response) { |
38 | 40 | updateCPUStatistics(response.system.cpuload); |
39 | 41 | updateMemoryStatistics(response.system.mem_total, response.system.mem_free); |
| 42 | + updateActiveUsersStatistics(response.activeUsers); |
40 | 43 | updateStoragesStatistics(response.storage) |
41 | 44 | updateShareStatistics(response.shares); |
42 | 45 | updatePHPStatistics(response.php); |
|
45 | 48 | } |
46 | 49 | }); |
47 | 50 |
|
| 51 | + $(window).resize(function () { |
| 52 | + resizeSystemCharts(); |
| 53 | + }); |
| 54 | + |
48 | 55 | function updateCPUStatistics (cpuload) { |
49 | 56 |
|
50 | 57 | var cpu1 = cpuload[0], |
51 | 58 | cpu2 = cpuload[1], |
52 | 59 | cpu3 = cpuload[2]; |
53 | 60 |
|
54 | 61 | if (typeof cpuLoadChart === 'undefined') { |
55 | | - cpuLoadChart = new SmoothieChart(); |
| 62 | + cpuLoadChart = new SmoothieChart( |
| 63 | + { |
| 64 | + millisPerPixel:250, |
| 65 | + minValue:0, |
| 66 | + grid:{fillStyle:'rgba(0,0,0,0.03)',strokeStyle:'transparent'}, |
| 67 | + labels:{fillStyle:'rgba(0,0,0,0.4)', fontSize:12} |
| 68 | + }); |
56 | 69 | cpuLoadChart.streamTo(document.getElementById("cpuloadcanvas"), 1000/*delay*/); |
57 | 70 | cpuLoadLine = new TimeSeries(); |
58 | | - cpuLoadChart.addTimeSeries(cpuLoadLine, {lineWidth:3,strokeStyle:'#00ff00'}); |
| 71 | + cpuLoadChart.addTimeSeries(cpuLoadLine, {lineWidth:1, strokeStyle:'rgb(0, 0, 255)', fillStyle:'rgba(0, 0, 255, 0.2)'}); |
59 | 72 | } |
60 | 73 |
|
| 74 | + $('#cpuFooterInfo').text("Load average: "+cpu1+" (Last minute)"); |
61 | 75 | cpuLoadLine.append(new Date().getTime(), cpu1); |
62 | 76 | } |
63 | 77 |
|
64 | 78 | function updateMemoryStatistics (memTotal, memFree) { |
65 | 79 |
|
66 | 80 | var memTotalBytes = memTotal * 1024, |
67 | | - memUsageBytes = (memTotal - memFree) * 1024; |
| 81 | + memUsageBytes = (memTotal - memFree) * 1024, |
| 82 | + memTotalGB = memTotal / (1024 * 1024), |
| 83 | + memUsageGB = (memTotal - memFree) / (1024 * 1024); |
68 | 84 |
|
69 | 85 | if (typeof memoryUsageChart === 'undefined') { |
70 | | - memoryUsageChart = new SmoothieChart({labels:{disabled:true},maxValue:memTotalBytes,minValue:0}); |
| 86 | + memoryUsageChart = new SmoothieChart( |
| 87 | + { |
| 88 | + millisPerPixel:250, |
| 89 | + maxValue:memTotalGB, |
| 90 | + minValue:0, |
| 91 | + grid:{fillStyle:'rgba(0,0,0,0.03)',strokeStyle:'transparent'}, |
| 92 | + labels:{fillStyle:'rgba(0,0,0,0.4)', fontSize:12} |
| 93 | + }); |
71 | 94 | memoryUsageChart.streamTo(document.getElementById("memorycanvas"), 1000/*delay*/); |
72 | 95 | memoryUsageLine = new TimeSeries(); |
73 | | - memoryUsageChart.addTimeSeries(memoryUsageLine, {lineWidth:3,strokeStyle:'#00ff00'}); |
| 96 | + memoryUsageChart.addTimeSeries(memoryUsageLine, {lineWidth:1, strokeStyle:'rgb(0, 255, 0)', fillStyle:'rgba(0, 255, 0, 0.2)'}); |
74 | 97 | } |
75 | 98 |
|
76 | | - $('#memFooterInfo').text("Total: "+bytesToSize(memTotalBytes)+" - Used: "+bytesToSize(memUsageBytes)); |
77 | | - memoryUsageLine.append(new Date().getTime(), memUsageBytes); |
| 99 | + $('#memFooterInfo').text("Total: "+bytesToSize(memTotalBytes)+" - Current usage: "+bytesToSize(memUsageBytes)); |
| 100 | + memoryUsageLine.append(new Date().getTime(), memUsageGB); |
78 | 101 | } |
79 | 102 |
|
80 | 103 | /** |
|
93 | 116 | function updateStoragesStatistics (storages) { |
94 | 117 |
|
95 | 118 | var users_storages = storages.num_users, |
96 | | - files_storages = storages.num_files, |
97 | | - local_storages = storages.num_storages_local, |
98 | | - home_storages = storages.num_storages_home, |
99 | | - other_storages = storages.num_storages_other; |
| 119 | + files_storages = storages.num_files; |
100 | 120 |
|
101 | 121 | $('#numUsersStorage').text(' ' + users_storages); |
102 | 122 | $('#numFilesStorage').text(' ' + files_storages); |
| 123 | + } |
| 124 | + |
| 125 | + function updateShareStatistics (shares) { |
103 | 126 |
|
104 | | - if (typeof storagesCgart === 'undefined') { |
105 | | - var ctx = document.getElementById("storagescanvas"); |
| 127 | + var shares_data = [shares.num_shares_user, shares.num_shares_groups, shares.num_shares_link, shares.num_fed_shares_sent, shares.num_fed_shares_received], |
| 128 | + stepSize = 0; |
106 | 129 |
|
107 | | - storagesCgart = new Chart(ctx, { |
108 | | - type: 'doughnut', |
| 130 | + if (Math.max.apply(null, shares_data) < 10) {stepSize = 1;} |
| 131 | + |
| 132 | + if (typeof sharesChart === 'undefined') { |
| 133 | + var ctx = document.getElementById("sharecanvas"); |
| 134 | + |
| 135 | + sharesChart = new Chart(ctx, { |
| 136 | + type: 'bar', |
109 | 137 | data: { |
110 | | - labels: ["Local", "Home", "Others"], |
| 138 | + labels: ["Users", "Groups", "Links", "Federated sent", "Federated received"], |
111 | 139 | datasets: [{ |
112 | | - data: [local_storages, home_storages, other_storages], |
| 140 | + label: " ", |
| 141 | + data: shares_data, |
113 | 142 | backgroundColor: [ |
114 | | - 'rgba(0, 0, 255, 0.5)', |
115 | | - 'rgba(0, 255, 0, 0.5)', |
116 | | - 'rgba(255, 0, 0, 0.5)' |
| 143 | + 'rgba(0, 0, 255, 0.2)', |
| 144 | + 'rgba(0, 255, 0, 0.2)', |
| 145 | + 'rgba(255, 0, 0, 0.2)', |
| 146 | + 'rgba(0, 255, 255, 0.2)', |
| 147 | + 'rgba(255, 0, 255, 0.2)' |
117 | 148 | ], |
118 | 149 | borderColor: [ |
119 | | - 'rgba(0,0,0,0.4)', |
120 | | - 'rgba(0,0,0,0.4)', |
121 | | - 'rgba(0,0,0,0.4)' |
| 150 | + 'rgba(0, 0, 255, 1)', |
| 151 | + 'rgba(0, 255, 0, 1)', |
| 152 | + 'rgba(255, 0, 0, 1)', |
| 153 | + 'rgba(0, 255, 255, 1)', |
| 154 | + 'rgba(255, 0, 255, 1)' |
122 | 155 | ], |
123 | 156 | borderWidth: 1 |
124 | 157 | }] |
125 | 158 | }, |
126 | 159 | options: { |
| 160 | + legend: {display:false}, |
| 161 | + scales: { |
| 162 | + yAxes: [{ |
| 163 | + ticks: { |
| 164 | + min: 0, |
| 165 | + stepSize: stepSize |
| 166 | + } |
| 167 | + }] |
| 168 | + } |
127 | 169 | } |
128 | 170 | }); |
129 | 171 | } |
| 172 | + |
| 173 | + sharesChart.update(); |
130 | 174 | } |
131 | 175 |
|
132 | | - function updateShareStatistics (shares) { |
| 176 | + function updateActiveUsersStatistics (activeUsers) { |
133 | 177 |
|
134 | | - var num_shares = shares.num_shares, |
135 | | - num_shares_user = shares.num_shares_user, |
136 | | - num_shares_groups = shares.num_shares_groups, |
137 | | - num_shares_link = shares.num_shares_link, |
138 | | - num_shares_link_no_password = shares.num_shares_link_no_password, |
139 | | - num_fed_shares_sent = shares.num_fed_shares_sent, |
140 | | - num_fed_shares_received = shares.num_fed_shares_received; |
| 178 | + var activeusers_data = [activeUsers.last5minutes, activeUsers.last1hour, activeUsers.last24hours]; |
| 179 | + stepSize = 0; |
141 | 180 |
|
142 | | - $('#totalShares').text(' ' + num_shares); |
| 181 | + if (Math.max.apply(null, activeusers_data) < 10) {stepSize = 1;} |
143 | 182 |
|
144 | | - if (typeof sharesChart === 'undefined') { |
145 | | - var ctx = document.getElementById("sharecanvas"); |
| 183 | + if (typeof activeusersChart === 'undefined') { |
| 184 | + var ctx = document.getElementById("activeuserscanvas"); |
146 | 185 |
|
147 | | - sharesChart = new Chart(ctx, { |
148 | | - type: 'doughnut', |
| 186 | + activeusersChart = new Chart(ctx, { |
| 187 | + type: 'line', |
149 | 188 | data: { |
150 | | - labels: ["Users", "Groups", "Links", "No-Password Links", "Federated sent", "Federated received"], |
| 189 | + labels: ["Last 5 mins", "Last 1 hour", "Last 24 hours"], |
151 | 190 | datasets: [{ |
152 | | - data: [num_shares_user, num_shares_groups, num_shares_link, num_shares_link_no_password, num_fed_shares_sent, num_fed_shares_received], |
153 | | - backgroundColor: [ |
154 | | - 'rgba(0, 0, 255, 0.5)', |
155 | | - 'rgba(0, 255, 0, 0.5)', |
156 | | - 'rgba(255, 0, 0, 0.5)', |
157 | | - 'rgba(0, 255, 255, 0.5)', |
158 | | - 'rgba(255, 0, 255, 0.5)', |
159 | | - 'rgba(255, 255, 0, 0.5)' |
160 | | - ], |
161 | | - borderColor: [ |
162 | | - 'rgba(0,0,0,0.4)', |
163 | | - 'rgba(0,0,0,0.4)', |
164 | | - 'rgba(0,0,0,0.4)', |
165 | | - 'rgba(0,0,0,0.4)', |
166 | | - 'rgba(0,0,0,0.4)', |
167 | | - 'rgba(0,0,0,0.4)' |
168 | | - ], |
169 | | - borderWidth: 1 |
| 191 | + label: " ", |
| 192 | + data: activeusers_data, |
| 193 | + fill: false, |
| 194 | + borderColor: ['rgba(0, 0, 255, 1)'], |
| 195 | + borderWidth: 1, |
| 196 | + borderDashOffset: 0.0, |
| 197 | + borderJoinStyle: 'miter', |
| 198 | + pointBorderColor: 'rgba(0, 0, 255, 1)', |
| 199 | + pointBackgroundColor: "#fff", |
| 200 | + pointBorderWidth: 1, |
| 201 | + pointHoverRadius: 5, |
| 202 | + pointHoverBackgroundColor: "rgba(0,0,255,0.6)", |
| 203 | + pointHoverBorderColor: "rgba(0, 0, 255, 1)", |
| 204 | + pointHoverBorderWidth: 1, |
| 205 | + pointRadius: 5, |
| 206 | + pointHitRadius: 10, |
170 | 207 | }] |
171 | 208 | }, |
172 | 209 | options: { |
| 210 | + legend: {display:false}, |
| 211 | + scales: { |
| 212 | + yAxes: [{ |
| 213 | + ticks: { |
| 214 | + min: 0, |
| 215 | + stepSize: stepSize |
| 216 | + } |
| 217 | + }] |
| 218 | + } |
173 | 219 | } |
174 | 220 | }); |
175 | 221 | } |
| 222 | + |
| 223 | + $('#numFilesStorage').text(' hola' + activeUsers.last5minutes); |
176 | 224 | } |
177 | 225 |
|
178 | 226 | function updatePHPStatistics (php) { |
179 | 227 |
|
180 | 228 | $('#phpVersion').text(' ' + php.version); |
181 | | - $('#phpMemLimit').text(' ' + php.memory_limit); |
| 229 | + $('#phpMemLimit').text(' ' + bytesToSize(php.memory_limit)); |
182 | 230 | $('#phpMaxExecTime').text(' ' + php.max_execution_time); |
183 | | - $('#phpUploadMaxSize').text(' ' + php.upload_max_filesize); |
| 231 | + $('#phpUploadMaxSize').text(' ' + bytesToSize(php.upload_max_filesize)); |
184 | 232 | } |
185 | 233 |
|
186 | 234 | function updateDatabaseStatistics (database) { |
187 | 235 |
|
188 | 236 | $('#databaseType').text(' ' + database.type); |
189 | 237 | $('#databaseVersion').text(' ' + database.version); |
190 | | - $('#dataBaseSize').text(' ' + database.size); |
| 238 | + $('#dataBaseSize').text(' ' + bytesToSize(database.size)); |
| 239 | + } |
| 240 | + |
| 241 | + function resizeSystemCharts () { |
| 242 | + |
| 243 | + var cpu_canvas = document.getElementById("cpuloadcanvas"), |
| 244 | + mem_canvas = document.getElementById("memorycanvas"); |
| 245 | + |
| 246 | + var newWidth = $('#cpuSection').width(); |
| 247 | + newHeight = newWidth / 4 |
| 248 | + |
| 249 | + if (newWidth <= 100) newWidth = 100; |
| 250 | + if (newHeight > 150) newHeight = 150; |
| 251 | + |
| 252 | + cpuloadcanvas.width = newWidth; |
| 253 | + cpuloadcanvas.height = newHeight; |
| 254 | + |
| 255 | + mem_canvas.width = newWidth; |
| 256 | + mem_canvas.height = newHeight; |
191 | 257 | } |
192 | 258 |
|
193 | 259 | })(jQuery, OC); |
0 commit comments