diff options
| -rw-r--r-- | AGENTS.md | 28 | ||||
| -rw-r--r-- | MACOS.md | 71 | ||||
| -rw-r--r-- | README.md | 38 |
3 files changed, 61 insertions, 76 deletions
@@ -66,6 +66,34 @@ Network interface: chosen by `netint` config or first non-`lo`; press `n` to cyc - `go test ./...` or `mage test`. No UI tests; collector has parse tests for protocol (e.g. `ParseNetLine` for Linux-style `/proc/net/dev` output). +## macOS support + +Loadbars supports macOS with automatic window activation and OS-specific monitoring scripts. + +### Implementation details + +- **Script embedding:** Both Linux and Darwin monitoring scripts are embedded in the binary +- **OS detection:** Automatically uses the correct script based on the host: + - `localhost` on macOS → Darwin script (sysctl, vm_stat, netstat, iostat) + - `localhost` on Linux → Linux script (/proc filesystem) + - All remote hosts → Linux script (assumes remote servers are Linux) +- **Window activation:** macOS-specific code automatically brings SDL window to foreground + - Uses build tags (`activate_darwin.go` and `activate.go`) + - No external helper script needed + +### Key files + +- `internal/collector/script.go` - Embeds both scripts +- `internal/collector/collector.go` - Selects script based on host (checks if `/proc` exists for localhost) +- `internal/display/activate_darwin.go` - macOS-specific activation using `open -a` +- `internal/display/activate.go` - No-op for other platforms + +### Known limitations + +- Remote macOS hosts are not supported (assumes all remote hosts are Linux) +- macOS script doesn't provide per-core CPU statistics (iostat limitation) +- Swap usage on macOS always shows 0 (macOS uses compressed memory differently) + ## Useful references - **README.md** – User-facing usage, hotkeys, config, network interface. diff --git a/MACOS.md b/MACOS.md deleted file mode 100644 index ba6efda..0000000 --- a/MACOS.md +++ /dev/null @@ -1,71 +0,0 @@ -# macOS Support for Loadbars - -## What was implemented - -Loadbars now fully supports macOS with automatic window activation built into the binary. - -### Changes made: - -1. **Script embedding** - Both Linux and Darwin monitoring scripts are embedded in the binary -2. **OS detection** - Automatically uses the correct script based on the host: - - `localhost` on macOS → Darwin script (sysctl, vm_stat, netstat, iostat) - - `localhost` on Linux → Linux script (/proc filesystem) - - All remote hosts → Linux script (assumes remote servers are Linux) -3. **Window activation** - macOS-specific code automatically brings SDL window to foreground - - Uses build tags (`activate_darwin.go` and `activate.go`) - - No external helper script needed - -## Usage on macOS - -Simply run the binary directly: - -```bash -# Monitor localhost -./loadbars --showcores --showmem --shownet - -# Monitor remote Linux servers -./loadbars server1.example.com server2.example.com --showcores - -# Monitor both localhost and remotes -./loadbars localhost server1.example.com server2.example.com --showcores -``` - -The window will automatically appear in the foreground. - -## Building on macOS - -Requirements: -```bash -brew install sdl2 -``` - -Build: -```bash -mage build -# or -go build -o loadbars ./cmd/loadbars -``` - -## Technical details - -### Script selection logic -- `internal/collector/script.go` - Embeds both scripts -- `internal/collector/collector.go` - Selects script based on host: - - For localhost: checks if `/proc` exists to determine Linux vs macOS - - For remote hosts: always uses Linux script - -### Window activation -- `internal/display/activate_darwin.go` - macOS-specific activation using `open -a` -- `internal/display/activate.go` - No-op for other platforms -- Called automatically after SDL window creation - -### Darwin monitoring script -- Uses macOS native tools: `sysctl`, `vm_stat`, `netstat -ibn`, `iostat` -- Outputs same protocol format as Linux script (M LOADAVG, M MEMSTATS, etc.) -- Limitations: No per-core CPU stats on macOS (iostat limitation) - -## Known limitations - -- Remote macOS hosts are not supported (assumes all remote hosts are Linux) -- macOS script doesn't provide per-core CPU statistics (iostat limitation) -- Swap usage on macOS always shows 0 (macOS uses compressed memory differently) @@ -91,27 +91,29 @@ Remote hosts need no Go: the binary embeds the remote script and pipes it to `ba ## Installation -### Dependencies (Fedora/RHEL/CentOS) +### SDL2 Dependencies -To run loadbars on Fedora Linux, you need the install the SDL2 development libraries: +Loadbars requires SDL2 for the display window. Install it for your platform: + +#### Fedora Linux / RHEL / CentOS ```bash sudo dnf install SDL2-devel ``` -On Ubuntu/Debian: +#### Ubuntu / Debian ```bash sudo apt install libsdl2-dev ``` -On macOS: +#### macOS ```bash brew install sdl2 ``` -**macOS Note:** The window will automatically come to the foreground when launched. No additional scripts needed. +**macOS Note:** The window automatically comes to the foreground when launched. No additional helper scripts needed. Localhost monitoring on macOS uses native macOS tools (sysctl, vm_stat, netstat, iostat), while remote hosts are assumed to be Linux. ### Running from Source @@ -135,6 +137,32 @@ Loadbars requires SSH public/private key authentication. Make sure: - Your public key is in ~/.ssh/authorized_keys on remote servers - SSH agent is running (ssh-agent), or passwordless keys are configured +### macOS Usage + +When running loadbars on macOS: + +- **Localhost monitoring** uses macOS native tools (sysctl, vm_stat, netstat, iostat) +- **Remote hosts** are assumed to be Linux (uses the Linux script over SSH) +- **Window activation** is automatic - the SDL window will come to foreground when launched + +**Examples:** + +```bash +# Monitor localhost +./loadbars --showcores --showmem --shownet + +# Monitor remote Linux servers +./loadbars server1.example.com server2.example.com --showcores + +# Monitor both localhost and remotes +./loadbars localhost server1.example.com server2.example.com --showcores +``` + +**Known macOS limitations:** +- Remote macOS hosts are not supported (assumes all remote hosts are Linux) +- Per-core CPU statistics are not available (iostat limitation) +- Swap usage always shows 0 (macOS uses compressed memory differently) + ## Info ### Hotkeys |
