Automated Disk Space Monitoring
Automated Disk Space Monitoring with Threshold Alerts
This guide covers automated, continuous disk space monitoring with smart alerting: get warned before problems occur, not after your server crashes.
For quick one-time disk checks, see Quick Disk Usage Check.
Why Proactive Disk Monitoring Matters
Disk full = server down. When disk hits 100%:
- Databases crash mid-transaction
- Log files can't write, hiding the real problem
- Applications fail with cryptic errors
- SSH may stop working, locking you out
The fix is simple: Alert at 80%, investigate at 90%, emergency action at 95%.
Setting Up Tiered Alerts
Configure multiple thresholds in Zuzia.app:
| Threshold | Severity | Action | Notification |
|---|---|---|---|
| 80% | Warning | Investigate, plan cleanup | |
| 90% | Critical | Immediate cleanup needed | Email + Slack |
| 95% | Emergency | Drop everything, fix now | SMS + phone |
Method 1: Check Disk Space with df Command
The df command is the standard way to check disk space usage on Linux.
Basic Disk Space Check
To see disk space for all filesystems:
# Human-readable disk space
df -h
This shows:
- Filesystem name
- Total size
- Used space
- Available space
- Usage percentage
- Mount point
Check Specific Partition
To check disk space for a specific partition:
# Check root partition
df -h /
# Check /var partition
df -h /var
# Check /home partition
df -h /home
This helps identify which partitions are approaching capacity limits.
Disk Space in Megabytes
For precise values in megabytes:
# Disk space in MB
df -m
This shows disk space in megabytes, useful for scripts and calculations.
Method 2: Check Disk Space with du Command
The du command shows disk usage for directories.
Directory Disk Usage
To see disk usage for a directory:
# Human-readable directory usage
du -h /var/log
# Summary of directory usage
du -sh /var/log
# Top 10 largest directories
du -h / | sort -rh | head -n 10
This helps identify which directories consume the most disk space.
Total Disk Usage
To see total disk usage:
# Total disk usage
du -sh /
This provides total disk usage for the root filesystem.
Method 3: Check Disk Space with lsblk Command
The lsblk command shows block devices and their mount points.
List Block Devices
# List block devices
lsblk
# With filesystem information
lsblk -f
This shows block devices, sizes, and mount points.
Method 4: Automated Disk Space Monitoring with Zuzia.app
Manual checks work while you are looking. To keep running them without you, Zuzia uses its agent and scheduled tasks.
How it works in Zuzia
- Install the Zuzia agent on the server with one command. CPU, RAM, disk, load and network metrics start reporting on their own, with alerts on a threshold, on drift from the server's normal, or on a disk fill-up forecast.
- Save the commands from this guide as a scheduled task and choose how often it runs, from every minute to once a year. The agent runs it on every host you pick.
- If a command fails, you get an alert right away by email, Slack, Discord, push (through your Pushover account) or SMS (through your Vonage account).
- The output of every run is kept, so you can look back at what changed. On paid plans, AI can read the output and alert you only when it spots a problem.
Setting it up
- Add the server in the Zuzia dashboard and install the agent.
- Create a scheduled task with the check commands below, then choose the hosts and how often it runs.
- Choose your notification channels. Turn on maintenance mode during planned work so it doesn't trigger alerts.
Method 5: Advanced Disk Space Monitoring Techniques
Calculate Disk Usage Percentage
Calculate disk usage percentage for specific partitions:
# Get disk usage percentage for root
df -h / | awk 'NR==2 {print $5}'
# Extract percentage number
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
echo "Disk usage: ${USAGE}%"
This helps create alert conditions based on usage percentage.
Compare Disk Space Over Time
By storing disk space data in Zuzia.app, you can compare current disk usage with previous measurements to detect rapid growth.
Monitor Multiple Partitions
Monitor multiple partitions simultaneously:
# Check multiple partitions
for partition in / /var /home; do
echo "=== $partition ==="
df -h $partition
done
This helps track disk usage across all critical partitions.
Real-World Use Cases for Disk Space Monitoring
Prevent Disk Space Exhaustion
Monitor disk space to prevent exhaustion:
# Check disk usage
df -h
# Alert if usage > 80%
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$USAGE" -gt 80 ]; then
echo "ALERT: Disk usage exceeded 80%"
fi
Set up Zuzia.app to check disk space hourly and alert when thresholds are exceeded.
Rapid Growth Detection
Detect rapid disk space growth:
# Track disk usage over time
df -h / | awk 'NR==2 {print $5}' > /tmp/disk-usage-$(date +%Y%m%d-%H%M).txt
Use Zuzia.app's historical data to identify rapid growth patterns and plan capacity upgrades.
Capacity Planning
Use historical disk space data to plan capacity:
# Track disk usage trends
df -h / | awk 'NR==2 {print $2, $3, $4, $5}'
Zuzia.app's historical data helps you understand disk space growth trends and plan capacity upgrades accordingly.
Best Practices for Disk Space Monitoring
1. Monitor Regularly
Check disk space at least every hour for active monitoring. Less critical systems can be checked every 6-12 hours. Use Zuzia.app automated monitoring to ensure regular checks.
2. Set Appropriate Thresholds
Set different alert thresholds:
- Warning: Disk usage > 70%
- Critical: Disk usage > 80%
- Emergency: Disk usage > 90%
3. Monitor Critical Partitions Separately
Monitor critical partitions like /, /var, /home, and /tmp separately, as they often have different usage patterns and growth rates.
4. Track Disk Space Trends
Use Zuzia.app's historical data to track disk space trends over time. Understanding how disk space grows helps plan capacity upgrades and optimize usage.
5. Plan Cleanup and Archiving
When disk usage approaches thresholds:
- Identify large files for cleanup
- Archive old data instead of deleting
- Implement log rotation
- Optimize database files if possible
Troubleshooting Common Disk Space Issues
Disk Space Full
If disk space is full:
- Check disk usage:
df -h - Find large files:
find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -n 10 - Identify files for cleanup
- Archive or delete unnecessary files
- Implement log rotation
Rapid Disk Space Growth
If disk space grows rapidly:
- Monitor disk usage frequently:
df -h - Track growth using Zuzia.app historical data
- Identify source of growth: Check logs, databases, temporary files
- Implement cleanup scripts
- Plan capacity upgrade if needed
Cannot Write to Disk
If you cannot write to disk:
- Check disk space:
df -h - Check inode usage:
df -i - Verify permissions:
ls -la /path - Check filesystem errors:
fsck -n /dev/sda1 - Free up space if needed
FAQ: Common Questions About Monitoring Disk Space
How often should I check disk space on Linux?
We recommend checking disk space every hour for active monitoring. Use Zuzia.app automated monitoring to check continuously without manual intervention. Less critical systems can be checked every 6-12 hours.
What should I do when disk usage exceeds thresholds?
When disk usage exceeds thresholds, immediately investigate: identify large files using find and du commands, clean up unnecessary files, archive old data, implement log rotation, and plan capacity upgrades if growth continues. Use Zuzia.app to track disk usage and receive alerts when thresholds are exceeded.
Can I monitor multiple partitions separately?
Yes, you can monitor multiple partitions separately: df -h / /var /home for specific partitions, or set up separate monitoring tasks for each critical partition with different thresholds. This helps focus monitoring on partitions that matter most.
How can I see disk space growth trends over time?
Zuzia.app stores all disk space data historically in its database, allowing you to view disk space growth trends over time. You can see historical data showing disk usage on different dates, identify when disk space grew rapidly, and track growth patterns to plan capacity upgrades.
What's the difference between df and du for checking disk space?
df shows filesystem-level disk space (total, used, available for mounted filesystems), while du shows directory-level disk usage (how much space directories and files consume). Use df to check overall disk space, and du to identify which directories consume the most space.
Can I monitor disk space across multiple Linux servers?
Yes, Zuzia.app allows you to add multiple servers and monitor disk space across all of them simultaneously. Each server executes disk space check commands independently, and all results are stored in Zuzia.app's database for centralized monitoring and comparison.
Does Zuzia.app use AI to analyze disk space patterns?
On paid plans, AI can read the output of your scheduled tasks and commands, explain it in plain language and alert you only when it spots a problem. Metric alerts work without AI: Zuzia alerts when CPU, RAM or load drifts from the server's normal and forecasts when a disk will fill up.