metrics: fix crash

This commit is contained in:
Girish Ramakrishnan
2025-07-02 12:54:13 +02:00
parent 6a45d83082
commit aa35099a4d

View File

@@ -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