Resource Limits & Disk Quotas on Linux: ulimit, repquota
Resource Limits & Disk Quotas on Linux: ulimit, repquota
System resource limits and quotas monitoring is essential for preventing resource exhaustion and ensuring fair resource allocation. This comprehensive guide covers everything you need to know about monitoring resource limits, tracking quota usage, detecting quota exhaustion, and setting up automated quota monitoring on Linux servers.
For related resource monitoring topics, see Server Resource Monitoring. For troubleshooting quota issues, see System Resource Quota Exhaustion.
Why Resource Limits Monitoring Matters
Resource limits monitoring helps you prevent resource exhaustion, ensure fair resource allocation, detect quota violations, track resource usage trends, and maintain system stability. Without proper quota monitoring, users can exhaust resources, causing service failures, system instability, and performance degradation.
Effective quota monitoring enables you to:
- Detect quota exhaustion before it causes problems
- Track resource usage trends
- Monitor quota limit compliance
- Prevent resource abuse
- Maintain system stability
- Respond quickly to quota issues
Understanding Resource Limits and Quotas
Before diving into monitoring methods, it's important to understand resource limits and quotas:
Resource Limit Types
- CPU Limits: CPU time and priority limits
- Memory Limits: Memory usage limits
- File Limits: Open file descriptor limits
- Process Limits: Process count limits
- Disk Quotas: Disk space and inode limits
Quota Components
- Soft Limit: Warning threshold
- Hard Limit: Maximum allowed usage
- Grace Period: Time to reduce usage after soft limit
- Current Usage: Current resource consumption
Method 1: Check Disk Quotas
Disk quota monitoring helps prevent disk space exhaustion:
View Disk Quotas
# View user disk quotas
quota -u username
# View all user quotas
repquota -a
# View quotas for specific filesystem
repquota /home
# View quota summary
quota -s
Check Quota Usage
# Check current quota usage
quota -v username
# View quota limits
quota -l username
# Check quota status
quota -s username
# View quota for all users
repquota -a -s
Monitor Quota Limits
# Check if user exceeded quota
quota -u username | grep -E "exceeded|over"
# View users near quota limits
repquota -a | awk '$3 > 80 || $6 > 80'
# Check quota grace period
quota -u username | grep grace
Method 2: Monitor System Resource Limits
System resource limits prevent resource exhaustion:
View Process Limits
# View current process limits
ulimit -a
# View specific limit
ulimit -n # File descriptors
ulimit -u # Processes
ulimit -v # Virtual memory
# View limits for specific process
cat /proc/PID/limits
# View system-wide limits
cat /etc/security/limits.conf
Check User Limits
# View user limits
ulimit -a
# Check limits for specific user
su - username -c "ulimit -a"
# View limits configuration
cat /etc/security/limits.conf | grep username
# Check PAM limits
cat /etc/security/limits.d/*.conf
Monitor Resource Usage
# Check current resource usage
ps aux --sort=-%mem | head -10
# View memory usage by user
ps aux | awk '{mem[$1]+=$6} END {for (u in mem) print u, mem[u]}'
# Check file descriptor usage
lsof | wc -l
# View process count by user
ps aux | awk '{proc[$1]++} END {for (u in proc) print u, proc[u]}'
Method 3: Detect Quota Exhaustion
Detecting quota exhaustion helps prevent service failures:
Identify Quota Violations
# Check for exceeded quotas
repquota -a | grep -E "\*|exceeded"
# View users over quota
quota -a | grep -E "exceeded|over"
# Check quota grace period status
repquota -a | grep grace
# Identify users near quota limits
repquota -a | awk '$3 > 90 || $6 > 90'
Monitor Quota Trends
# Track quota usage over time
quota -u username > /tmp/quota-$(date +%Y%m%d).txt
# Compare quota usage
diff /tmp/quota-previous.txt /tmp/quota-current.txt
# Monitor quota growth rate
quota -u username | awk '/blocks/ {print $2, $3}'
Method 4: Monitor Resource Allocation
Monitoring resource allocation helps ensure fair distribution:
Track Resource Usage by User
# View disk usage by user
du -sh /home/* | sort -h
# Check memory usage by user
ps aux | awk '{mem[$1]+=$6} END {for (u in mem) print u, mem[u]/1024 "MB"}'
# View CPU usage by user
ps aux | awk '{cpu[$1]+=$3} END {for (u in cpu) print u, cpu[u] "%"}'
# Check process count by user
ps aux | awk '{proc[$1]++} END {for (u in proc) print u, proc[u]}'
Analyze Resource Distribution
# View top resource consumers
du -sh /home/* | sort -h | tail -10
# Check resource usage patterns
ps aux --sort=-%mem | head -20
# Monitor resource allocation trends
ps aux | awk '{mem[$1]+=$6; cpu[$1]+=$3} END {for (u in mem) print u, mem[u]/1024 "MB", cpu[u] "%"}'
Method 5: Automated Quota 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.
Custom Quota Monitoring Commands
Add these commands as scheduled tasks for comprehensive quota monitoring:
# Check for exceeded quotas
repquota -a | grep -E "\*|exceeded"
# View users near quota limits
repquota -a | awk '$3 > 80 || $6 > 80'
# Check quota usage summary
quota -s
# Monitor resource limits
ulimit -a
Best Practices for Quota Monitoring
1. Monitor Quotas Regularly
Don't wait for quota exhaustion:
- Use Zuzia.app for continuous quota monitoring
- Set up alerts before quotas are exceeded
- Review quota usage regularly (daily or weekly)
- Monitor quota trends over time
2. Set Appropriate Quota Limits
Configure quotas based on needs:
- Set soft limits as warnings
- Set hard limits to prevent exhaustion
- Configure grace periods appropriately
- Review and adjust limits regularly
3. Monitor Quota Trends
Track quota usage over time:
- Monitor quota growth rates
- Identify users with high usage
- Plan quota increases proactively
- On paid plans, let AI read the task output and alert you only when it spots a problem
4. Respond Quickly to Quota Alerts
Have response procedures ready:
- Define escalation procedures for quota exhaustion
- Prepare quota increase procedures
- Test quota management procedures regularly
- Document quota incident responses
5. Maintain Quota Documentation
Keep quota records:
- Document quota policies
- Maintain quota configuration
- Track quota changes
- Review quota effectiveness
Troubleshooting Quota Issues
Step 1: Identify Quota Problems
When quota issues occur:
Check Quota Status:
- View quota usage:
quota -u username - Check for exceeded quotas:
repquota -a | grep "*" - Review quota limits
- View quota usage:
Investigate Quota Violations:
- Identify users exceeding quotas
- Check quota usage details
- Review quota configuration
Step 2: Resolve Quota Issues
When quotas are exceeded:
Immediate Actions:
- Increase quotas if appropriate
- Request users reduce usage
- Clean up unnecessary files
- Extend grace periods if needed
Long-Term Solutions:
- Adjust quota policies
- Improve quota monitoring
- Plan quota capacity increases
- Optimize resource usage
FAQ: Common Questions About Quota Monitoring
How often should I check quotas on my Linux server?
For production servers, check quotas every 6-12 hours. Zuzia.app can check quotas automatically, store historical data, and alert you when quotas are exceeded. More frequent checks are needed for systems with high quota usage.
What quotas should I monitor?
Monitor disk quotas (space and inodes), memory limits, CPU limits, file descriptor limits, and process limits. Focus on quotas that affect system stability and user productivity.
Can Zuzia.app detect quota exhaustion?
Yes, Zuzia.app can detect quota exhaustion by monitoring quota usage, checking for exceeded quotas, tracking usage trends, and alerting when quotas are exceeded or near limits. Use commands that check quota status and usage.
How do I respond to quota exhaustion alerts?
When quota exhaustion alerts occur, immediately check quota status, identify users exceeding quotas, increase quotas if appropriate, request users reduce usage, clean up unnecessary files, and investigate root causes. Document all quota incidents for future reference.
Should I monitor quotas on all servers?
Yes, monitor quotas on all production servers with user accounts or resource limits. Quota exhaustion can occur on any server, and comprehensive monitoring helps prevent resource problems across your entire infrastructure.
Related guides, recipes, and problems
Related guides
- Server Resource Monitoring
- Monitoring System Resource Limits and Quotas
- Server Performance Monitoring
Related recipes
Related problems