Skip to content

fix: support macOS servers in the CPU/memory/disk/uptime monitor - #888

Closed
zerox9dev wants to merge 1 commit into
oblien:mainfrom
zerox9dev:fix/macos-server-stats
Closed

zerox9dev wants to merge 1 commit into
oblien:mainfrom
zerox9dev:fix/macos-server-stats

Conversation

@zerox9dev

@zerox9dev zerox9dev commented Sep 14, 2026 •

Copy link
Copy Markdown

Summary

  • The CPU/memory/disk/uptime monitor for self-hosted "servers" reads straight from /proc, which macOS doesn'''t have — a Mac added as an Openship deploy target always showed dashes in System Health.
  • Adds a Darwin branch (top/vm_stat/sysctl/df) and dispatches on uname -s, so one SSH round-trip still gets the stats regardless of platform. No new dependency — every command used ships with macOS.
  • The Darwin branch avoids <<< on purpose: zsh (macOS'''s default shell, and what ssh host cmd actually runs) implements here-strings via a real temp file, which made this exact probe fail with ENOSPC on a nearly-full disk — precisely the box an operator most wants a disk-usage reading from. Found and fixed while testing against a real Mac mini with 99% disk usage.
  • Caught (and fixed) a join bug of my own along the way: concatenating the two branches into one if/then/else/fi command needs an explicit ; before else/fi, or the trailing printf swallows them as arguments instead of shell keywords and the whole probe never runs on either OS. The added bash -n syntax-check test catches this class of bug directly.

Test plan

  • bunx vitest run apps/api/src/modules/system/server-stats-command.test.ts — 4 new tests: both branches parse as valid bash, the combined command still dispatches correctly, the Darwin branch has no <<<, and the Linux branch actually runs on the (Linux) CI runner and emits the documented JSON schema.
  • Manually verified the Linux branch on an Ubuntu box and the Darwin branch over a real SSH exec against a macOS 15.4 (Apple Silicon) Mac mini — both return valid, sane values.
  • tsc --noEmit — no new errors introduced.

The stats one-liner read straight from /proc, so a self-hosted server
running macOS (e.g. as an Openship "server" deploy target) always came
back with no data — the dashboard's System Health panel just showed
dashes for CPU, memory, disk and uptime.

Add a Darwin branch (top/vm_stat/sysctl/df) and dispatch on `uname -s`
so the same probe works on both platforms in one SSH round-trip. The
Darwin branch avoids `<<<` on purpose: zsh (macOS's default shell, and
what `ssh host cmd` actually runs) implements here-strings via a temp
file, which fails this exact probe with ENOSPC on a nearly-full disk —
precisely the box an operator most wants a disk reading from.
@Hydralerne

Copy link
Copy Markdown
Member

Reviewed alongside #645 against current main. Both PRs address the same macOS failure and modify the API controller that has since moved to the shared platform layer. I adapted and merged the earlier, smaller #645 into #892, retaining @chbndrhnns’s original commit and GitHub merge credit.

The integrated command also addresses the shell concern raised here: neither OS path uses here-strings, and actual macOS execution through both sh and zsh passes. It keeps used + available memory equal to total, uses an interval CPU sample, and reports incomplete probes as errors. This PR’s separate controller implementation would duplicate that fix; its active/wired/compressed “used” value and free-only “available” value would also leave the memory fields inconsistent.

Thanks for investigating the macOS probe and shell behavior. Closing this overlapping PR as superseded by the adapted #645 in #892; #608 is tracked as fixed there, awaiting main merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants