feat: add cross-platform health check fallbacks#70
Open
airdropia wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1. Adds psutil/resource fallbacks for memory checks and os.getloadavg for load checks. 8 tests included.