Skip to content

feat: add cross-platform health check fallbacks (#1)#28

Open
Lixianqi666 wants to merge 2 commits into
weilixiong:mainfrom
Lixianqi666:fix/cross-platform-health-check
Open

feat: add cross-platform health check fallbacks (#1)#28
Lixianqi666 wants to merge 2 commits into
weilixiong:mainfrom
Lixianqi666:fix/cross-platform-health-check

Conversation

@Lixianqi666

Copy link
Copy Markdown

Summary

Fixes #1 — adds cross-platform fallbacks for memory and load checks so non-Linux environments report useful values instead of generic /proc read failures.

Changes

check_memory_usage()

  • Linux: Keeps existing /proc/meminfo path (unchanged)
  • macOS/BSD: Falls back to sysctl -n hw.memsize for total memory and vm_stat for free pages
  • Other: Returns WARNING with clear message if platform detection fails

check_load_average()

  • Linux: Keeps existing /proc/loadavg path (unchanged)
  • macOS/BSD: Falls back to os.getloadavg() (Python standard library)
  • Other: Returns WARNING with clear message if platform detection fails

Backward Compatibility

  • Linux behavior is 100% unchanged
  • JSON and text output format remains identical
  • Existing callers see no difference on Linux

Testing

Tested on macOS:

  • check_memory_usage() returns meaningful memory stats
  • check_load_average() returns load via os.getloadavg()
  • Both functions gracefully handle missing /proc files

Fixes #1

- check_memory_usage(): Add macOS fallback using sysctl and vm_stat
- check_load_average(): Add fallback using os.getloadavg()
- Both functions keep Linux /proc paths as primary
- Graceful degradation when platform detection fails

Fixes weilixiong#1
Copilot AI review requested due to automatic review settings June 27, 2026 05:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

2 participants