DISCLAIMER: README and some parts of the scripts generated by AI.
A lightweight, self-contained daily disk usage monitoring and reporting system for Linux servers. It tracks folder sizes over time, calculates daily and 30-day deltas, generates a clean HTML report (optimized for email), and can send it automatically.
The system consists of two main scripts:
- A data collection script that records folder sizes into a CSV log.
- A report generation script that processes the CSV, computes deltas, strips common path prefixes, and produces a professional HTML report.
All configuration is centralized in /etc/default/folder-usage.
- HTML Report with clean table layout and monospace font for easy reading in email clients.
- Usage shown in MB (with thousand separators) instead of bytes or GB.
- Daily and 30-day deltas calculated and displayed in MB (positive in green, negative in red).
- Significant growth alerts highlighted when daily growth exceeds a configurable threshold (in MB).
- Automatic common prefix stripping — if all monitored folders share the same root (e.g.
/var/log/applications/), only the relative name is shown in the table for cleaner output. - Robust handling of missing data (shows "N/A" gracefully).
- Email delivery with proper HTML content-type headers (supports
mailandsendmail). - Configurable alert threshold with backward compatibility for old GB-based settings.
- Simple CSV-based storage (easy to query or archive).
Daily Cron (00:05) → collect-folder-usage.sh
↓
CSV_LOG (date,folder,bytes,human)
↓
Daily Cron (06:00) → folder-usage-report.sh
↓
HTML Report (/tmp/folderusage-report.html)
↓
Email (optional) or local file
Create or edit /etc/default/folder-usage:
# List of folders to monitor (full paths)
MONITORED_FOLDERS=(
"/var/log/app1"
"/var/log/app2"
"/var/log/applications/backend"
"/var/log/applications/frontend"
)
# Path to the CSV log file (will be appended daily)
CSV_LOG="/var/log/folder-usage.csv"
# Email address to receive the daily report (leave empty to disable email)
REPORT_EMAIL="sysadmin@example.com"
# Alert threshold for significant daily growth (in MB)
GROWTH_ALERT_THRESHOLD_MB=300
# Optional: legacy variable still supported (converted automatically to MB)
# GROWTH_ALERT_THRESHOLD_GB=1Notes:
- The array
MONITORED_FOLDERScan contain any number of paths. - The common prefix detection works best when all paths share the same root directory.
- Make sure the user running the scripts has read access to the monitored folders and write access to
CSV_LOG.
This script should run daily (recommended: early morning) to record current sizes.
This is the main script that produces the HTML report and sends the email.
It:
- Reads the last entry for each folder on "today", "yesterday", and "~30 days ago".
- Converts sizes to MB.
- Calculates deltas.
- Detects and removes the common path prefix for cleaner display.
- Generates a self-contained HTML report.
- Sends it via email if
REPORT_EMAILis set.
# Collect folder sizes every day at 00:05
5 0 * * * /usr/local/bin/folder-usage-logger.sh
# Generate and email the report every day at 06:00
0 6 * * * /usr/local/bin/folder-usage-report.shThe HTML report includes:
- Title with current date
- Generation timestamp
- Note about common prefix removed (if applicable)
- Clean table with columns:
- Path (shortened)
- Today (MB)
- Yesterday (MB)
- ~30 days ago (MB)
- Δ Daily (MB) — color coded
- Δ 30d (MB) — color coded
- Highlighted alert rows for significant daily growth
- Footer with config and threshold information
- Missing data for a date → shows "N/A"
- Non-numeric sizes → safely handled
- Paths with special HTML characters → properly escaped
- Single folder or no common prefix → falls back gracefully
- Large numbers → formatted with thousand separators
- Email client compatibility → basic inline CSS + proper MIME headers
- The CSV file grows over time. There is no rotation in-place.
- You can query historical data directly with
awkor import into spreadsheets.