Skip to content

fix: resolve bounty issue #1 - add cross-platform health check fallbacks#31

Closed
lequangsang01 wants to merge 1 commit into
weilixiong:mainfrom
lequangsang01:fix/bounty-1
Closed

fix: resolve bounty issue #1 - add cross-platform health check fallbacks#31
lequangsang01 wants to merge 1 commit into
weilixiong:mainfrom
lequangsang01:fix/bounty-1

Conversation

@lequangsang01

Copy link
Copy Markdown

Summary

This PR adds cross-platform fallbacks for check_memory_usage() and check_load_average() in tools/health_check.py, so non-Linux environments (macOS, Windows) report meaningful diagnostics instead of generic /proc read failures.

Changes

tools/health_check.py

  • check_memory_usage(): Refactored into a chain of fallbacks:

    1. _check_memory_linux() — reads /proc/meminfo (Linux)
    2. _check_memory_psutil() — uses psutil.virtual_memory() if available
    3. _check_memory_platform() — uses sysctl + vm_stat (macOS)
  • check_load_average(): Refactored into a chain of fallbacks:

    1. _check_load_linux() — reads /proc/loadavg (Linux)
    2. _check_load_getloadavg() — uses os.getloadavg() (macOS, Unix)

tools/test_health_check.py (new)

13 unit tests covering:

  • Linux /proc/meminfo and /proc/loadavg parsing
  • Fallback behavior when /proc files are missing
  • os.getloadavg() fallback for load average
  • Backward compatibility (JSON output format, return types)

Validation

  • All 13 tests pass: python3 tools/test_health_check.py -v
  • Verified on macOS (Apple Silicon): memory reports 68.9% used (11GB/16GB), load reports Load: 4.0 (25% of 16 cores)
  • JSON and text output remain backward compatible

Closes

Closes #1

@lequangsang01 lequangsang01 closed this by deleting the head repository Jun 29, 2026
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.

[$50 BOUNTY] [Python] Add cross-platform health check fallbacks

1 participant