Skip to content

Add cross-platform fallbacks for memory and load checks - #68

Open
foxyManTou wants to merge 3 commits into
weilixiong:mainfrom
foxyManTou:main
Open

Add cross-platform fallbacks for memory and load checks#68
foxyManTou wants to merge 3 commits into
weilixiong:mainfrom
foxyManTou:main

Conversation

@foxyManTou

Copy link
Copy Markdown

Summary

Add cross-platform fallbacks for check_memory_usage() and check_load_average() so the health check tool works on macOS and other non-Linux environments.

Changes

check_memory_usage() — fallback chain:

  1. /proc/meminfo (Linux, unchanged)
  2. psutil (cross-platform, if installed)
  3. sysctl (macOS/BSD)
  4. WARNING with explanation if all fail

check_load_average() — fallback:

  1. /proc/loadavg (Linux, unchanged)
  2. os.getloadavg() (POSIX — macOS, BSD, Linux)
  3. WARNING with explanation if all fail

Testing

  • Added tools/test_health_check_fallbacks.py with 6 unit tests covering all fallback paths
  • Existing Linux /proc behavior unchanged

Fixes: Health check now reports meaningful values on non-Linux systems.

Foxy Bounty Hunter and others added 3 commits July 13, 2026 19:19
- check_memory_usage(): fallback chain: /proc/meminfo → psutil → sysctl
- check_load_average(): fallback: /proc/loadavg → os.getloadavg()
- _memory_usage_from_proc/_psutil/_sysctl helpers for clean separation
- _format_memory_result shared formatter
- Add test_health_check_fallbacks.py with unit tests for all fallback paths
- Backward compatible: Linux /proc paths unchanged

Fixes: the health check now returns meaningful values on macOS and
other non-Linux environments instead of generic /proc read failures.
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.

1 participant