# HG changeset patch # User Andrew Azores # Date 1506607633 14400 # Node ID 1887aaa6d7a5038a51a278d1258280a56bb2ac82 # Parent 4d79a8984071e9e886e30099b3b1ce0db001099c Assume system-memory data from web-gateway is in B, not MiB Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025216.html diff -r 4d79a8984071 -r 1887aaa6d7a5 mock-api/endpoints/system-memory.endpoint.js --- a/mock-api/endpoints/system-memory.endpoint.js Thu Sep 28 10:06:37 2017 -0400 +++ b/mock-api/endpoints/system-memory.endpoint.js Thu Sep 28 10:07:13 2017 -0400 @@ -15,18 +15,19 @@ } let limit = req.query.l || 1; + let gib = 1024 * 1024 * 1024; let response = []; for (let i = 0; i < limit; i++) { var data = { systemId: systemId, agentId: 'foo-agentId', timeStamp: new Date().getTime(), - total: 16384, - free: _.round(Math.random() * (16384 / 4)), - buffers: 16384 / 32, + total: 16 * gib, + free: _.round(Math.random() * (16 * gib / 4)), + buffers: 16 * gib / 32, cached: 0, - swapTotal: 16384 / 2, - swapFree: 16384 / 2, + swapTotal: 16 * gib / 2, + swapFree: 16 * gib / 2, commitLimit: 0 }; response.push(data); diff -r 4d79a8984071 -r 1887aaa6d7a5 src/app/components/system-info/system-memory/system-memory.controller.js --- a/src/app/components/system-info/system-memory/system-memory.controller.js Thu Sep 28 10:06:37 2017 -0400 +++ b/src/app/components/system-info/system-memory/system-memory.controller.js Thu Sep 28 10:07:13 2017 -0400 @@ -91,7 +91,7 @@ // TODO: this should be localized too, but c3 doesn't allow for the tooltip // formatter to be a promise, only a function, and angular-translate only // returns promises - value: memoryValue => { return memoryValue + ' MiB'; } + value: memoryValue => memoryValue + ' MiB' } }, transition: { duration: 50 }, @@ -150,15 +150,16 @@ let used = total - free; let usage = Math.round((used) / total * 100); + let mib = 1024 * 1024; // update the memory time series chart - this.lineConfig.axis.y.max = total; + this.lineConfig.axis.y.max = total / mib; this.lineData.xData.push(data.timeStamp); - this.lineData.yData0.push(total); - this.lineData.yData1.push(free); - this.lineData.yData2.push(used); - this.lineData.yData3.push(data.swapTotal); - this.lineData.yData4.push(data.swapFree); - this.lineData.yData5.push(data.buffers); + this.lineData.yData0.push(total / mib); + this.lineData.yData1.push(free / mib); + this.lineData.yData2.push(used / mib); + this.lineData.yData3.push(data.swapTotal / mib); + this.lineData.yData4.push(data.swapFree / mib); + this.lineData.yData5.push(data.buffers / mib); this._trimData(); // update the memory donut chart diff -r 4d79a8984071 -r 1887aaa6d7a5 src/app/components/system-info/system-memory/system-memory.controller.spec.js --- a/src/app/components/system-info/system-memory/system-memory.controller.spec.js Thu Sep 28 10:06:37 2017 -0400 +++ b/src/app/components/system-info/system-memory/system-memory.controller.spec.js Thu Sep 28 10:07:13 2017 -0400 @@ -100,12 +100,12 @@ systemId: 'foo-systemId', agentId: 'mock-agentId', timeStamp: Date.now(), - total: 16384, + total: 16 * 1024 * 1024, free: 0, - buffers: 1, - cached: 2, - swapTotal: 3, - swapFree: 4, + buffers: 1 * 1024, + cached: 2 * 1024, + swapTotal: 3 * 1024, + swapFree: 4 * 1024, commitLimit: 0 } } @@ -248,12 +248,12 @@ systemId: 'foo-systemId', agentId: 'mock-agentId', timeStamp: timestamp, - total: 16384, + total: 16 * 1024 * 1024 * 1024, free: 0, - buffers: 1, - cached: 2, - swapTotal: 3, - swapFree: 4, + buffers: 1 * 1024 * 1024, + cached: 2 * 1024 * 1024, + swapTotal: 3 * 1024 * 1024, + swapFree: 4 * 1024 * 1024, commitLimit: 0 } ] @@ -265,9 +265,9 @@ }); controller.lineData.should.deepEqual({ xData: ['timestamp', timestamp], - yData0: ['Total Memory', 16384], + yData0: ['Total Memory', 16 * 1024], yData1: ['Free Memory', 0], - yData2: ['Used Memory', 16384], + yData2: ['Used Memory', 16 * 1024], yData3: ['Total Swap', 3], yData4: ['Free Swap', 4], yData5: ['Buffers', 1]