A powerful command-line tool for analyzing AWS RDS instance utilization, performance, and cost optimization opportunities.
This script provides detailed insights into your AWS RDS instances, helping you identify underutilized resources, performance issues, and cost optimization opportunities. It analyzes CPU, memory, storage, and I/O metrics to generate actionable recommendations.
- Comprehensive Metrics Analysis: Analyzes CPU, memory, storage, and I/O utilization
- Trend Analysis: Identifies increasing or decreasing usage patterns
- Cost Estimation: Calculates estimated monthly costs and potential savings
- Performance Monitoring: Detects performance issues like high latency or queue depth
- Smart Recommendations: Provides instance sizing recommendations based on multiple factors
- Detailed Reporting: Shows both current and maximum utilization values
- AWS CLI installed and configured with appropriate permissions
- Bash shell environment
- Python 3 (for advanced calculations)
bccommand-line calculatorjqJSON processor- AWS credentials with appropriate permissions to access RDS and CloudWatch metrics
-
Clone this repository:
git clone https://github.com/yourusername/aws-rds-usage.git cd aws-rds-usage -
Make the script executable:
chmod +x aws-rds-usage.sh
./aws-rds-usage.shThis will analyze all RDS instances in your default AWS region.
If you're using aws-vault to manage your AWS credentials, you can run the script with a specific profile:
aws-vault exec my-profile -- ./aws-rds-usage.shReplace my-profile with your AWS profile name. This ensures the script runs with the correct AWS credentials.
You can also combine this with other options:
aws-vault exec my-profile -- ./aws-rds-usage.sh --region eu-west-1 --cost --trend./aws-rds-usage.sh [options]Available options:
--region REGION: Specify AWS region (default: us-east-1)--days DAYS: Number of days to analyze (default: 7)--cost: Include cost analysis--trend: Include trend analysis--detailed: Show detailed metrics--debug: Enable debug output--help: Show help message
Analyze instances in a specific region:
./aws-rds-usage.sh --region eu-west-1Analyze instances with cost and trend analysis:
./aws-rds-usage.sh --cost --trendAnalyze instances with detailed metrics and debug output:
./aws-rds-usage.sh --detailed --debugAnalyze instances using a specific AWS profile with aws-vault:
aws-vault exec production -- ./aws-rds-usage.sh eu-central-1 --costThe script provides the following information for each RDS instance:
- Instance identifier
- Instance class
- Storage size
- Engine type and version
- Multi-AZ status
- CPU utilization (current and maximum)
- Memory utilization (current and maximum)
- Storage utilization
- I/O metrics (IOPS, latency, queue depth)
The script generates recommendations based on:
- Resource utilization patterns
- Performance issues
- Cost optimization opportunities
- Usage trends
Recommendations may include:
- Downsizing underutilized instances
- Upgrading instances with performance issues
- Maintaining current size with explanatory notes
When the --cost option is used, the script provides:
- Estimated monthly cost for the current instance
- Suggested instance class for optimization
- Estimated monthly savings or cost increase
When the --trend option is used, the script analyzes:
- CPU usage trends (increasing, decreasing, or stable)
- Memory usage trends
- I/O usage trends
-
Permission Errors
- Ensure your AWS credentials have appropriate permissions
- Check that the AWS CLI is properly configured
- Verify you're using the correct AWS profile with aws-vault
-
Missing Metrics
- Some metrics may not be available for all instance types
- Ensure the instance has been running long enough to collect metrics
-
Calculation Errors
- Use the
--debugoption to see detailed calculation information - Check that all required tools (Python, bc, jq) are installed
- Use the
Enable debug mode to see detailed information about:
- Raw metric data from CloudWatch
- Calculation steps and intermediate values
- Trend analysis details
./aws-rds-usage.sh --debugContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS CloudWatch for providing the metrics data
- AWS CLI for enabling command-line access to AWS services