Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Use node:os to expose system metrics

Richie McIlroyddc3d1baab81
diff --git a/apps/media-server/src/routes/health.ts b/apps/media-server/src/routes/health.ts
index 2ed88b3a8..b7630db7a 100644
--- a/apps/media-server/src/routes/health.ts
+++ b/apps/media-server/src/routes/health.ts
@@ -1,10 +1,6 @@
+import os from "node:os";
import { spawn } from "bun";
import { Hono } from "hono";
-import {
- canAcceptNewVideoProcess,
- getActiveVideoProcessCount,
- getSystemResources,
-} from "../lib/job-manager";
const health = new Hono();
@@ -31,7 +27,11 @@ health.get("/", async (c) => {
}
} catch {}
- const resources = getSystemResources();
+ const cpuCount = os.cpus().length;
+ const loadAvg = os.loadavg();
+ const totalMemMB = Math.round(os.totalmem() / (1024 * 1024));
+ const freeMemMB = Math.round(os.freemem() / (1024 * 1024));
+ const memoryUsagePercent = 1 - os.freemem() / os.totalmem();
return c.json({
status: ffmpegAvailable ? "ok" : "degraded",
@@ -39,9 +39,16 @@ health.get("/", async (c) => {
available: ffmpegAvailable,
version: ffmpegVersion,
},
- activeVideoProcesses: getActiveVideoProcessCount(),
- canAcceptNewVideoProcess: canAcceptNewVideoProcess(),
- resources,
+ system: {
+ cpuCount,
+ loadAvg1m: loadAvg[0],
+ loadAvg5m: loadAvg[1],
+ loadAvg15m: loadAvg[2],
+ totalMemoryMB: totalMemMB,
+ freeMemoryMB: freeMemMB,
+ memoryUsagePercent: Math.round(memoryUsagePercent * 100),
+ uptimeSeconds: Math.round(os.uptime()),
+ },
});
});