Skip to content

[ BOUNTY] [Python] Add cross-platform health check fallbacks#12

Open
Xiaofei-Z wants to merge 2 commits into
weilixiong:mainfrom
Xiaofei-Z:cross-platform-health
Open

[ BOUNTY] [Python] Add cross-platform health check fallbacks#12
Xiaofei-Z wants to merge 2 commits into
weilixiong:mainfrom
Xiaofei-Z:cross-platform-health

Conversation

@Xiaofei-Z

Copy link
Copy Markdown

Summary

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

Changes

  • tools/health_check.py:
    • check_memory_usage(): /proc/meminfo on Linux → vm_stat+sysctl on macOS → psutil as generic fallback
    • check_load_average(): /proc/loadavg on Linux → os.getloadavg() on Unix → psutil on Windows
  • tests/test_cross_platform_health.py: 10 tests covering Linux path simulation, fallback paths, missing /proc simulation, macOS behavior

Testing

Fallback behavior:

  • Linux: /proc/meminfo and /proc/loadavg (unchanged, backward compatible)
  • macOS: vm_stat + sysctl hw.memsize for memory; os.getloadavg() for load
  • Other/Windows: psutil if available, otherwise graceful WARNING

Test coverage:

  • Memory returns valid tuple on any platform
  • Load returns valid tuple on any platform
  • Status always in (OK, WARNING, CRITICAL)
  • Non-Linux fallback does not crash
  • Linux path simulated with mock /proc files
  • Missing /proc files produce WARNING with error detail
  • 10/10 tests pass
python3 tests/test_cross_platform_health.py

Build validation:

python3 build.py

Diagnostic artifacts: diagnostic/build-9659efd1-part001..004.logd + diagnostic/build-9659efd1-metadata.json

Diagnostic password: cbc7af3146d522ee68f0

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally
  • Diagnostic build log is committed in this PR
  • Documentation has been updated (fallback behavior documented in function docstrings)
  • Configuration or schema changes are documented, if applicable
  • No generated build artifacts are committed, except the required diagnostic build log
  • Changes are scoped to the PR purpose and avoid unrelated cleanup
  • Security, privacy, and error-handling implications have been considered

Feige added 2 commits June 19, 2026 22:22
Closes weilixiong#1

- check_memory_usage(): /proc/meminfo on Linux, vm_stat on macOS, psutil as generic fallback
- check_load_average(): /proc/loadavg on Linux, os.getloadavg() on Unix, psutil on Windows
- Non-Linux environments now report useful values instead of generic /proc read failures
- 10 tests covering Linux path, fallback paths, missing /proc simulation, macOS behavior
- JSON and text output backward compatible
@Xiaofei-Z

Copy link
Copy Markdown
Author

Hi @weilixiong, submitted this for bounty #1. Adds cross-platform fallbacks: /proc/meminfo on Linux, vm_stat on macOS, psutil generic for memory; /proc/loadavg on Linux, os.getloadavg() on Unix, psutil on Windows for load average. 10 tests pass, build diagnostics included. Happy to address feedback!

yanyishuai added a commit to yanyishuai/TentOfTrials that referenced this pull request Jul 1, 2026
yanyishuai added a commit to yanyishuai/TentOfTrials that referenced this pull request Jul 2, 2026
yanyishuai added a commit to yanyishuai/TentOfTrials that referenced this pull request Jul 2, 2026
yanyishuai added a commit to yanyishuai/TentOfTrials that referenced this pull request Jul 2, 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.

1 participant