metrics: fix nano to msecs conversion
This commit is contained in:
@@ -41,7 +41,7 @@ async function readContainerMetric(name) {
|
||||
const blockRead = blkioStats.filter(entry => entry.op === 'read').reduce((sum, entry) => sum + entry.value, 0);
|
||||
const blockWrite = blkioStats.filter(entry => entry.op === 'write').reduce((sum, entry) => sum + entry.value, 0);
|
||||
|
||||
const cpuUsageMsecs = stats.cpu_stats.cpu_usage.total_usage / 1000; // convert to msecs (to match system metrics)
|
||||
const cpuUsageMsecs = stats.cpu_stats.cpu_usage.total_usage / 1e6; // convert from nano to msecs (to match system metrics)
|
||||
|
||||
return { networkRead, networkWrite, blockRead, blockWrite, memoryUsed, memoryMax, cpuUsageMsecs };
|
||||
}
|
||||
@@ -389,7 +389,7 @@ async function getSystemStream(options) {
|
||||
const [error, metrics] = await safe(readSystemMetrics());
|
||||
if (error) return metricsStream.destroy(error);
|
||||
|
||||
const cpuPercent = oldMetrics ? (metrics.userMsecs + metrics.sysMsecs - oldMetrics.userMsecs - oldMetrics.sysMsecs) * 0.1 / (intervalMsecs/1000) : null;
|
||||
const cpuPercent = oldMetrics ? (metrics.userMsecs + metrics.sysMsecs - oldMetrics.userMsecs - oldMetrics.sysMsecs) * 100 / intervalMsecs : null;
|
||||
const blockReadRate = oldMetrics ? (metrics.blockRead - oldMetrics.blockRead) / (intervalMsecs/1000) : null;
|
||||
const blockWriteRate = oldMetrics ? (metrics.blockWrite - oldMetrics.blockWrite) / (intervalMsecs/1000) : null;
|
||||
const networkReadRate = oldMetrics ? (metrics.networkRead - oldMetrics.networkRead) / (intervalMsecs/1000) : null;
|
||||
|
||||
Reference in New Issue
Block a user