diff --git a/dashboard/src/components/SystemMetrics.vue b/dashboard/src/components/SystemMetrics.vue index 47ac8eb45..cb75a0a0b 100644 --- a/dashboard/src/components/SystemMetrics.vue +++ b/dashboard/src/components/SystemMetrics.vue @@ -70,30 +70,38 @@ async function liveRefresh() { } async function getMetrics(fromSecs) { - if (fromSecs === 0) return { cpuLabels: [], cpuData: [], memoryLabels: [], memoryData: [], swapData: [] }; + if (fromSecs === 0) return { cpuData: [], memoryData: [], swapData: [] }; const [error, result] = await systemModel.getMetrics({ fromSecs: fromSecs * 60 * 60, intervalSecs: 300 }); if (error) return console.error(error); - const cpuLabels = result.cpu.map(v => v[1]*1000); // convert to msecs - const cpuData = result.cpu.map(v => v[0]); // already scaled to cpu*100 + // time is converted to msecs . cpu is already scaled to cpu*100 + const cpuData = result.cpu.map(v => { return { x: v[1]*1000, y: v[0] };}); - const memoryLabels = result.memory.map(v => v[1]*1000); // convert to msecs - const memoryData = result.memory.map(v => (v[0] / 1024 / 1024 / 1024).toFixed(2)); + const memoryData = result.memory.map(v => { + return { + x: v[1]*1000, + y: (v[0] / 1024 / 1024 / 1024).toFixed(2) + }; + }); // assume that there is 1:1 timeline for swap and memory data - const swapData = result.swap.map(v => (v[0] / 1024 / 1024 / 1024).toFixed(2)); + const swapData = result.swap.map(v => { + return { + x: v[1]*1000, + y: (v[0] / 1024 / 1024 / 1024).toFixed(2) + }; + }); - return { cpuLabels, cpuData, memoryLabels, memoryData, swapData }; + return { cpuData, memoryData, swapData }; } async function refresh() { busy.value = true; const now = Date.now(); - const { cpuLabels, cpuData, memoryLabels, memoryData, swapData } = await getMetrics(period.value); + const { cpuData, memoryData, swapData } = await getMetrics(period.value); const cpuGraphData = { - labels: cpuLabels, datasets: [{ label: 'CPU', data: cpuData, @@ -153,7 +161,6 @@ async function refresh() { const roundedSwap = Math.ceil(systemMemory.swap / giB) * giB; const memoryGraphData = { - labels: memoryLabels, datasets: [{ label: 'RAM', data: memoryData,