metrics: fix crash
This commit is contained in:
@@ -28,8 +28,8 @@ const apps = require('./apps.js'),
|
||||
async function readContainerMetric(name) {
|
||||
assert.strictEqual(typeof name, 'string');
|
||||
|
||||
const stats = await docker.getStats(name);
|
||||
if (Object.keys(stats.memory_stats).length === 0) return null; // the container is stopped. better not to inspect and check State since a race is possible
|
||||
const [error, stats] = await safe(docker.getStats(name));
|
||||
if (error || Object.keys(stats.memory_stats).length === 0) return null; // the container is missing or stopped. better not to inspect and check State since a race is possible
|
||||
|
||||
const networkRead = stats.networks ? stats.networks.eth0.rx_bytes : 0; // in host mode (turn), networks is missing
|
||||
const networkWrite = stats.networks ? stats.networks.eth0.tx_bytes : 0; // in host mode (turn), networks is missing
|
||||
|
||||
Reference in New Issue
Block a user