Bashbashmonitoringdiskalertingproduction-ready
Disk Usage Monitor
Automated disk monitoring with threshold alerts, growth rate tracking, and capacity forecast for proactive storage management.
title: "Disk Usage Monitor" description: "Automated disk monitoring with threshold alerts, growth rate tracking, and capacity forecast for proactive storage management." category: "Bash" language: "bash" tags: ["bash", "monitoring", "disk", "alerting", "production-ready"] createdAt: "2025-02-28" updatedAt: "2025-03-18"
Overview
A disk usage monitor that tracks growth rates over time, predicts when filesystems will be full, and sends alerts before capacity issues cause outages. Historical data enables trend analysis.
Code
WARN_THRESHOLD=80 CRIT_THRESHOLD=90 SLACK_WEBHOOK=https://... ./disk-monitor.shNotes
- Growth rate is calculated from 24h historical data stored in CSV
- ETA-to-full prediction uses linear extrapolation from the current growth rate
logger -t diskmonwrites to syslog for centralized log collection- Run every 15 minutes via cron for accurate growth tracking
- Clean up history older than 7 days to prevent the CSV from growing unbounded