Skip to content

Fix cross-platform health check crashes on macOS/Windows#49

Open
scotia1973-bot wants to merge 1 commit into
weilixiong:mainfrom
scotia1973-bot:fix/cross-platform-health-check
Open

Fix cross-platform health check crashes on macOS/Windows#49
scotia1973-bot wants to merge 1 commit into
weilixiong:mainfrom
scotia1973-bot:fix/cross-platform-health-check

Conversation

@scotia1973-bot

Copy link
Copy Markdown

Summary

The health check tool reads Linux-only /proc/meminfo and /proc/loadavg directly. On macOS or Windows these files do not exist, causing crashes.

Changes

Memory check (check_memory_usage)

  • Extracted Linux /proc/meminfo parsing into _read_meminfo_linux() helper
  • Added _read_mem_macos() fallback using sysctl + vm_stat for macOS
  • Added psutil fallback as final fallback

Load average check (check_load_average)

  • Replaced /proc/loadavg with os.getloadavg() (works on both Linux and macOS)
  • Added OSError catch for Windows

Disk check (check_disk_usage)

  • Kept os.statvfs() for Linux/macOS
  • Added AttributeError catch with shutil.disk_usage() fallback for Windows

Closes #1

Replace Linux-only /proc/meminfo and /proc/loadavg with:
- Memory: /proc/meminfo parsing with macOS sysctl/vm_stat fallback
  and psutil fallback
- Load: /proc/loadavg replaced with os.getloadavg() (works on Linux
  and macOS), with OSError catch for Windows
- Disk: os.statvfs kept with shutil.disk_usage() fallback for Windows

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