fix(api): support macOS hosts in server system stats monitoring - #645
Open
chbndrhnns wants to merge 1 commit into
Open
fix(api): support macOS hosts in server system stats monitoring#645chbndrhnns wants to merge 1 commit into
chbndrhnns wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #608
Summary
When connecting a macOS (Darwin) host via SSH (e.g. a MacBook or Mac mini), the Server Overview page showed
-for CPU, Memory, Disk, and Uptime.The background metrics streaming endpoint (
GET /system/monitor/stream) runsSTATS_COMMANDon an interval over SSH to collect live host statistics. The command was hardcoded for Linux and relied on/proc/stat,/proc/meminfo,/proc/uptime,/proc/loadavg, anddf -B1 /. On macOS:/procdoes not exist.df -B1fails withdf: illegal option -- B.This caused
STATS_COMMANDto fail on Darwin hosts, preventing the stats SSE event from emitting valid JSON and leaving the frontend cards in a perpetual empty state (-).Changes
STATS_COMMANDinapps/api/src/modules/system/server-check.controller.tsto detect the OS via[ "$(uname -s)" = "Darwin" ]:iostat -c 2(falling back tosysctl -n vm.loadavgfor load averages if needed).sysctl -n hw.memsizeand available memory viavm_stat((free + inactive + speculative) * pagesize).df -Pk /(1024-byte blocks), computing total, used, and available bytes.sysctl -n kern.boottimeand current timestamp./proc/stat,/proc/meminfo,/proc/uptime,/proc/loadavg, and POSIXdf -Pk /with safe fallbacks.apps/api/test/modules/system/server-monitoring-command.test.tsverifying structural integrity and execution against the host.Tests
STATS_COMMANDexecution on macOS (Darwin), confirming valid JSON output with all expected fields (cpu,memTotal,memUsed,memAvail,diskTotal,diskUsed,diskAvail,uptime,load1,load5,load15).apps/api/test/modules/system/server-monitoring-command.test.ts.