diff --git a/index.js b/index.js index 17867b8..a0f0a31 100644 --- a/index.js +++ b/index.js @@ -35,13 +35,13 @@ function getCpuPercent() { function getDisk() { try { - const out = execSync("df / --output=size,used,avail -B1", { - encoding: "utf-8", - }); - const parts = out.trim().split("\n")[1].trim().split(/\s+/).map(Number); - const totalGB = +(parts[0] / 1e9).toFixed(1); - const usedGB = +(parts[1] / 1e9).toFixed(1); - const freeGB = +(parts[2] / 1e9).toFixed(1); + // Alpine df doesn't support --output, use standard POSIX format + const out = execSync("df -k /", { encoding: "utf-8" }); + const parts = out.trim().split("\n")[1].trim().split(/\s+/); + // df -k columns: Filesystem, 1K-blocks, Used, Available, Use%, Mounted + const totalGB = +(parseInt(parts[1], 10) / 1e6).toFixed(1); + const usedGB = +(parseInt(parts[2], 10) / 1e6).toFixed(1); + const freeGB = +(parseInt(parts[3], 10) / 1e6).toFixed(1); const usagePercent = totalGB > 0 ? Math.round((usedGB / totalGB) * 100) : 0; return { totalGB, usedGB, freeGB, usagePercent }; } catch {