Skip to content

Add cross-platform health check fallbacks for memory and load#60

Open
glm-5-2 wants to merge 1 commit into
weilixiong:mainfrom
glm-5-2:bounty-cross-platform-health
Open

Add cross-platform health check fallbacks for memory and load#60
glm-5-2 wants to merge 1 commit into
weilixiong:mainfrom
glm-5-2:bounty-cross-platform-health

Conversation

@glm-5-2

@glm-5-2 glm-5-2 commented Jul 11, 2026

Copy link
Copy Markdown

Bounty: $50 — Cross-platform health check fallbacks

Issue

#1

What this does

Adds cross-platform fallbacks to check_memory_usage() and check_load_average() so non-Linux environments (macOS, etc.) report useful values instead of generic warnings.

Changes

  • check_memory_usage(): Refactored to use _get_memory_info() helper
    • Linux: /proc/meminfo (primary, unchanged)
    • macOS: sysctl hw.memsize + vm_stat for page-level info
    • Universal: psutil.virtual_memory() if installed
  • check_load_average(): Refactored to use _get_load_average() helper
    • Linux: /proc/loadavg (primary, unchanged)
    • Unix/macOS: os.getloadavg() (stdlib fallback)
    • Universal: psutil.getloadavg() if installed
  • Both functions gracefully degrade to WARNING status if no method works

Backward compatibility

  • Linux behavior is unchanged
  • All existing thresholds and return formats are preserved
  • psutil is optional (try/except ImportError)

- check_memory_usage: fallback to psutil or macOS vm_stat/sysctl when /proc/meminfo unavailable
- check_load_average: fallback to os.getloadavg() or psutil when /proc/loadavg unavailable
- Non-Linux environments now report useful values instead of generic warnings
- Maintains backward compatibility with existing Linux /proc behavior
- New helper functions: _get_memory_info(), _get_load_average()
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