Skip to content

[#1] Add cross-platform fallbacks for memory and load checks#55

Open
lushan888 wants to merge 1 commit into
weilixiong:mainfrom
lushan888:feat/cross-platform-health
Open

[#1] Add cross-platform fallbacks for memory and load checks#55
lushan888 wants to merge 1 commit into
weilixiong:mainfrom
lushan888:feat/cross-platform-health

Conversation

@lushan888

Copy link
Copy Markdown

Summary

Add cross-platform fallbacks for check_memory_usage() and check_load_average() so non-Linux environments (macOS, BSD) report useful values instead of generic /proc read failures.

Changes

  • tools/health_check.py:
    • check_memory_usage(): keeps /proc/meminfo path on Linux, falls back to psutil, then os.sysconf
    • check_load_average(): keeps /proc/loadavg path where available, falls back to os.getloadavg()
  • tools/test_health_check.py: 5 tests covering all fallback paths
  • diagnostic/build-bf2147ac.logd/json: build diagnostic artifacts

Testing

  • 5/5 tests pass (tested on macOS with psutil fallback active)
  • Memory: /proc/meminfo → psutil → os.sysconf → WARNING
  • Load: /proc/loadavgos.getloadavg() → WARNING
  • Backward compatible: JSON and text output unchanged for existing callers

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally
  • Diagnostic build log is committed in this PR
  • No generated build artifacts are committed, except the required diagnostic build log
  • Changes are scoped to the PR purpose and avoid unrelated cleanup

Closes #1

- check_memory_usage(): keep /proc/meminfo path on Linux, add psutil
  fallback, then os.sysconf as final fallback
- check_load_average(): keep /proc/loadavg where available, add
  os.getloadavg() fallback for non-Linux Unix-like systems
- Add test_health_check.py with 5 tests: memory fallback without
  /proc, psutil verification, /proc path, load fallback without
  /proc, /proc path
- All tests pass on macOS (non-Linux) with fallback active
- JSON and text output remain backward compatible

Issue: weilixiong#1
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