dracon-system
Proactive disk space monitoring and automatic cleanup. Prevents "disk full" emergencies on development machines and servers.
Install
The binary will be at ~/.cargo/bin/dracon-system. Or install from the long-name façade repo:
Features
Disk Space Monitoring
- Early Warning (70%) - Proactive notification before space becomes critical
- Warning (80%) - State change notification
- Action (90%) - Automatic cleanup triggers
- Critical (95%) - Aggressive mitigation
Automatic Rust Target Cleanup
- Automatically cleans
target/directories when disk hits action level - Smart protection for active builds:
- Detects running
cargo,rustc,clippy-driverprocesses - Protects target dirs in their working directories
- Protects recently modified target dirs (configurable)
- Detects running
- Configurable minimum size threshold
Process Monitoring & Graduated Renice
- Monitors processes using excessive CPU
- Graduated renice based on severity:
- ≥180% CPU → nice 5 (gentle deprio)
- ≥300% CPU → nice 10 (moderate deprio)
- ≥500% CPU → nice 15 (strong deprio)
- RSS ≥4GB → nice 5 (memory hog deprio)
- RSS ≥8GB → nice 10 (heavy memory deprio)
- Never kills processes — only renices
- Auto-releases renice after process is no longer heavy
Build-Aware Monitoring
- Detects active Rust build processes
- Protects their target directories from cleanup
- Prevents breaking active compilation
Disk Space Trend Prediction
- Tracks disk usage history over time
- Predicts when disk will fill based on usage rate
- Warns if disk predicted to fill within configurable hours
Inode Monitoring
- Monitors inode usage on root filesystem
- Warns when inode usage exceeds threshold (default 85%)
- Critical for systems with many small files
Zombie Process Detection
- Detects accumulated zombie processes
- Alerts when zombie count exceeds threshold (default 20)
- Helps identify parent processes not reaping children
Large Log File Detection
- Scans configured directories for large log files
- Alerts on files exceeding size threshold (default 100 MiB)
- Helps identify runaway logging
Installation
Quick Install (User Service)
Run the repository installer from the repository root:
This will:
- Build the release binary
- Install to
~/.local/bin/dracon-system - Set up and start the systemd user service
The per-utility directories do not contain standalone installers; use the root install.sh for all utilities.
Manual Install
# Build
# Copy binary
# (Optional) Install systemd service
Server Deployment (System-wide)
For servers, you may want to run as a system service:
# Build
# Copy binary
# Create dedicated user (optional but recommended)
# Create system service file
Usage
Commands
# Show system status
# Run diagnostics
# Analyze storage hotspots
# Clean up build artifacts (dry-run)
# Actually clean up
# Run single guard check
# Run as daemon (continuous monitoring)
# Show recent events
# Manage symlinks
# Zram stats
Systemd Service Management
# Enable at login
# Start now
# Check status
# View logs
Configuration
Create ~/.dracon/utilities/system/dracon-system.toml:
[]
# Enable the guard daemon
= true
# Check interval in seconds
= 30
# Disk thresholds (percent)
= 70
= 80
= 90
= 95
# Automatic Rust target cleanup
= true
= 256
= "~/Dev" # Default; add more paths as needed
= 30
# Proactive cleanup (before disk reaches action level)
= 50
= 14
= 120
# Process monitoring
= 180
= 30
= true
= 5
= 120
# Trend prediction
= true
= 24
# Inode monitoring
= true
= 85
# Zombie process detection
= true
= 20
# Large log file detection
= true
= 100
= "/var/log,~/logs"
# Guard log rotation
= "~/.local/state/dracon/dracon-system-guard.log"
= 1
# Notifications
= true
= "notify-send"
= 300
# Sync freeze (for use with dracon-sync)
= true
= 88
# Protected paths (in addition to system defaults)
# protected_paths = ["/mnt/data", "/opt/important"]
How It Works
Threshold Actions
| State | Threshold | Actions |
|---|---|---|
| early-warn | 70% | Notification only |
| warn | 80% | Notification, state change alert |
| action | 90% | Freeze sync, auto-cleanup Rust targets |
| critical | 95% | All above, more aggressive cleanup |
Cleanup Logic
When disk hits action level (90%):
- Scan configured directories for Rust
target/dirs - Detect active
cargo/rustcprocesses - Protect target dirs in active build working directories
- Delete unprotected target dirs ≥
cleanup_min_size_mb - Also clean safe trash, package caches, Nix garbage, stale
node_modules/, and Docker resources when those policy toggles are enabled - Send notification with cleanup summary
Proactive Cleanup
When disk usage is above proactive_cleanup_percent (default 50%) but below disk_action_percent:
- Only target dirs older than
rust_target_max_age_days(default 14) and ≥cleanup_min_size_mbare removed - Active builds (running cargo/rustc) are always protected
- Runs every
proactive_cleanup_interval_cyclesguard cycles
Process Monitoring
The guard monitors processes using ≥process_cpu_percent% CPU or ≥process_rss_mb MiB RSS for >process_sustain_secs seconds:
- All heavy processes are logged to persistent JSONL file
- When
auto_renice = true, heavy processes are reniced with graduated values - Higher CPU/memory usage = higher nice value (lower priority)
- Process still gets full CPU when nothing else needs it
- Un-reniced back to nice 0 after
release_after_secsof being non-heavy
Trend Prediction
The guard tracks disk usage over time and uses linear regression to predict when the disk will fill. If the predicted time is within trend_warn_hours, it sends an early warning.
Safety Boundaries
The guard never kills processes; process mitigation is limited to renice.
Destructive cleanup paths are canonicalized first, symlinks are rejected, and configured protected paths are honored. Log truncation uses the same safety check before modifying files, so system-protected or user-protected log paths are skipped.
Binary Size
The release binary is approximately 2.9MB, making it suitable for:
- Embedded systems
- Containers
- Minimal server installs
License
AGPL-3.0-only — see the root LICENSE for details.