Skip to content

feat: add cross-platform health check fallbacks#70

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

feat: add cross-platform health check fallbacks#70
airdropia wants to merge 1 commit into
weilixiong:mainfrom
airdropia-collection:feat/cross-platform-health-check-1

Conversation

@airdropia

Copy link
Copy Markdown

Closes #1. Adds psutil/resource fallbacks for memory checks and os.getloadavg for load checks. 8 tests included.

Add cross-platform fallbacks for memory and load checks so non-Linux
environments report useful values instead of /proc read failures.

Changes to tools/health_check.py:

check_memory_usage():
- Linux: keeps existing /proc/meminfo path (unchanged)
- Non-Linux: tries psutil.virtual_memory() first
- Fallback: uses resource.getrusage() for process RSS
- Final fallback: returns WARNING with platform info

check_load_average():
- Linux: keeps existing /proc/loadavg path (unchanged)
- Non-Linux: uses os.getloadavg() (standard library, Unix)
- Windows: returns OK with 'not available' message

Tests: tests/test_health_check_cross_platform.py
- Tests return format (tuple of 3)
- Tests fallback when /proc files missing
- Tests backward compatibility (status values, string details)

Acceptance criteria met:
✅ check_memory_usage() keeps /proc/meminfo on Linux + non-Linux fallback
✅ check_load_average() keeps /proc/loadavg + falls back to os.getloadavg()
✅ Tests simulate missing /proc and verify fallback behavior
✅ JSON and text output remain backward compatible
✅ PR description explains fallback behavior

Closes 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