From 66355bd698183ef4e987adc324a93c9661f4466e Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 14 Jul 2026 09:04:22 +0000 Subject: [PATCH] Add RAM and disk stats to health-status endpoint via SSH Co-Authored-By: Claude Sonnet 4.6 --- updater/src/index.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/updater/src/index.js b/updater/src/index.js index 7108a60..5c1c194 100644 --- a/updater/src/index.js +++ b/updater/src/index.js @@ -207,12 +207,27 @@ app.get('/health-status', async () => { return Promise.all( Object.entries(healthMap).map(async ([name, { host, port }]) => { const t0 = Date.now() - try { - await fetch(`http://${host}:${port}/health`, { signal: AbortSignal.timeout(3000) }) - return { name, up: true, ms: Date.now() - t0 } - } catch { - return { name, up: false, ms: null } + const [httpResult, freeOut, dfOut] = await Promise.all([ + fetch(`http://${host}:${port}/health`, { signal: AbortSignal.timeout(3000) }) + .then(() => ({ up: true, ms: Date.now() - t0 })) + .catch(() => ({ up: false, ms: null })), + sshGet(host, ['free', '-b']), + sshGet(host, ['df', '-k', '/']), + ]) + + let ram = null + if (freeOut) { + const m = freeOut.match(/^Mem:\s+(\d+)\s+(\d+)/m) + if (m) ram = { total: +m[1], used: +m[2] } } + + let disk = null + if (dfOut) { + const row = dfOut.trim().split('\n').pop().split(/\s+/) + if (row.length >= 3) disk = { total: +row[1] * 1024, used: +row[2] * 1024 } + } + + return { name, ...httpResult, ram, disk } }) ) })