⚡ Bolt: Optimize swap-ssd-health.sh parsing and fix calculation bugs - #4
Conversation
…ugs: - Replaced multiple subprocess chains with single awk passes for `sysctl`, `vm_stat`, and `smartctl` parsing. - Fixed a bug where `USED_SWAP` was incorrectly extracting the `TOTAL_SWAP` value (field $4 vs field $7). - Fixed a case sensitivity issue with 'Pageouts' detection in `vm_stat`. - Improved error handling for missing SMART attributes.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
💡 What: Optimized
ops/monitoring/swap-ssd-health.shto use efficient single-passawkparsing instead of multiple pipeline chains. Fixed critical bugs in swap usage calculation and pageouts detection.🎯 Why:
USED_SWAPwas incorrectly parsing field $4 (total) instead of field $7 (used), leading to 100% swap usage reports.vm_statoutput for 'Pageouts' varies in case across macOS versions; added case-insensitive matching.📊 Impact:
🔬 Measurement:
Verified using a test harness (
tests/test_swap_ssd_health.sh) that mockedsysctl,vm_stat,diskutil, andsmartctloutput to confirm correct parsing and calculation logic.PR created automatically by Jules for task 2568319239102810731 started by @simien