|
298 | 298 | }); |
299 | 299 |
|
300 | 300 | // Socket Recieves New Server Stats |
| 301 | + var activeChartArrays = []; |
301 | 302 | socket.on('proc', function (proc) { |
302 | 303 | var MemoryChart = $('#chart_memory').highcharts(); |
303 | 304 | MemoryChart.series[0].addPoint(parseInt(proc.data.memory.total / (1024 * 1024)), true, true); |
304 | 305 |
|
305 | 306 | var CPUChart = $('#chart_cpu').highcharts(); |
306 | 307 |
|
307 | | - // if({{ $server->cpu }} > 0) { |
308 | | - // CPUChart.series[0].addPoint(parseFloat(((proc.data.cpu.total / {{ $server->cpu }}) * 100).toFixed(3).toString()), true, true); |
309 | | - // } else { |
310 | | - // CPUChart.series[0].addPoint(proc.data.cpu.total, true, true); |
311 | | - // } |
| 308 | + // Remove blank values from listing |
| 309 | + var activeCores = []; |
312 | 310 | for (i = 0, length = proc.data.cpu.cores.length; i < length; i++) { |
| 311 | + if (proc.data.cpu.cores[i] > 0) { |
| 312 | + activeCores.push(proc.data.cpu.cores[i]); |
| 313 | + } |
| 314 | + } |
| 315 | +
|
| 316 | + var modifedActiveCores = { '0': 0 }; |
| 317 | + for (i = 0, length = activeCores.length; i < length; i++) { |
| 318 | + if (i > 7) { |
| 319 | + modifedActiveCores['0'] = modifedActiveCores['0'] + activeCores[i]; |
| 320 | + } else { |
| 321 | + if (activeChartArrays.indexOf(i) < 0) { |
| 322 | + activeChartArrays.push(i); |
| 323 | + } |
| 324 | + modifedActiveCores[i] = activeCores[i]; |
| 325 | + } |
| 326 | + } |
| 327 | +
|
| 328 | + console.log(activeChartArrays); |
| 329 | + console.log(modifedActiveCores); |
| 330 | +
|
| 331 | + for (i = 0, length = activeChartArrays.length; i < length; i++) { |
313 | 332 | if (typeof CPUChart.series[i] === 'undefined') { |
314 | 333 | CPUChart.addSeries({ |
315 | 334 | name: 'Core ' + i, |
316 | 335 | data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
317 | 336 | }); |
318 | 337 | } |
319 | 338 | if({{ $server->cpu }} > 0) { |
320 | | - CPUChart.series[i].addPoint(parseFloat(((proc.data.cpu.cores[i] / {{ $server->cpu }}) * 100).toFixed(3).toString()), true, true); |
| 339 | + CPUChart.series[i].addPoint(parseFloat((((modifedActiveCores[i] || 0)/ {{ $server->cpu }}) * 100).toFixed(3).toString()), true, true); |
321 | 340 | } else { |
322 | | - CPUChart.series[i].addPoint(proc.data.cpu.cores[i], true, true); |
| 341 | + CPUChart.series[i].addPoint(modifedActiveCores[i] || 0, true, true); |
323 | 342 | } |
324 | 343 | } |
325 | 344 | }); |
|
0 commit comments