feat: show live disk usage on server tiles - #5484
JoshuaRileyDev wants to merge 7 commits into
Conversation
| export const getServerDiskUsage = async ( | ||
| serverId?: string, | ||
| ): Promise<ServerDiskUsage> => { | ||
| const command = "df -kP / 2>/dev/null | awk 'NR==2 {print $2, $3}'"; |
There was a problem hiding this comment.
The command reads only df's total and used columns, then calculates free space as total - used and utilization as used / total. On filesystems with reserved blocks, this counts reserved capacity as free and reports lower utilization than df itself, so the tile can materially overstate writable space. Read the available column and base both displayed values on used + available.
Knowledge Base Used:
| {isActive && ( | ||
| <div className="flex items-center gap-2 pt-3 border-t mt-auto flex-wrap"> | ||
| <ServerDiskUsage | ||
| serverId={server.serverId} | ||
| /> |
There was a problem hiding this comment.
Mounting one query per active tile creates an unbounded SSH fan-out whenever this page loads. The server list has no page-size limit, and every query creates a separate SSH client that may remain pending for roughly 100 seconds. Organizations with many or unreachable servers can therefore cause a large simultaneous connection burst. Please bound the concurrency or fetch disk usage through a throttled aggregate path.
Knowledge Base Used: Infrastructure runtime
| const [totalKb = Number.NaN, usedKb = Number.NaN] = result.stdout | ||
| .trim() | ||
| .split(/\s+/) | ||
| .map(Number); | ||
|
|
||
| if (!Number.isFinite(totalKb) || totalKb <= 0 || !Number.isFinite(usedKb)) { | ||
| throw new Error("Unable to read disk usage"); | ||
| } | ||
|
|
||
| const totalBytes = Math.round(totalKb * 1024); | ||
| const usedBytes = Math.min( | ||
| totalBytes, | ||
| Math.max(0, Math.round(usedKb * 1024)), | ||
| ); | ||
| return { | ||
| totalBytes, | ||
| usedBytes, | ||
| usagePercent: Math.round((usedBytes / totalBytes) * 100), | ||
| }; |
There was a problem hiding this comment.
The new shell-output parser and its byte and percentage calculations have no direct or integration test, despite depending on exact df output and malformed-output handling. Extracting and testing the parser with valid, empty, and malformed output would prevent platform or command-output changes from silently reducing the feature to “Unavailable.”
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Adds a focused server disk-usage readout to each active server tile.
Changes
server.diskUsagequery that runs a portabledf -kP /command locally over SSH.canary; fork-only seeding and Portless changes are excluded.Visual comparison
Test plan
pnpm exec biome check --write apps/dokploy/components/dashboard/settings/servers/show-servers.tsxpnpm --filter dokploy typecheckRisks
Rollback
Revert the commits on this branch.
The PR should not merge until its free-space and utilization calculations use actually available filesystem capacity; the SSH fan-out and missing parser tests should also be addressed.
Summary
This PR adds an authorized, SSH-backed disk-usage query and displays its result with refresh controls on every active server tile.
Reviews (1) · Last reviewed commit: "test: refresh disk usage screenshot"