Skip to content

Ossmoskosmos/aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

AWS RDS Usage Analysis Tool

A powerful command-line tool for analyzing AWS RDS instance utilization, performance, and cost optimization opportunities.

Overview

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.

Features

  • 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

Prerequisites

  • AWS CLI installed and configured with appropriate permissions
  • Bash shell environment
  • Python 3 (for advanced calculations)
  • bc command-line calculator
  • jq JSON processor
  • AWS credentials with appropriate permissions to access RDS and CloudWatch metrics

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/aws-rds-usage.git
    cd aws-rds-usage
  2. Make the script executable:

    chmod +x aws-rds-usage.sh

Usage

Basic Usage

./aws-rds-usage.sh

This will analyze all RDS instances in your default AWS region.

AWS Authentication

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.sh

Replace 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

Command-line Options

./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

Examples

Analyze instances in a specific region:

./aws-rds-usage.sh --region eu-west-1

Analyze instances with cost and trend analysis:

./aws-rds-usage.sh --cost --trend

Analyze instances with detailed metrics and debug output:

./aws-rds-usage.sh --detailed --debug

Analyze instances using a specific AWS profile with aws-vault:

aws-vault exec production -- ./aws-rds-usage.sh eu-central-1 --cost

Output Explanation

The script provides the following information for each RDS instance:

Basic Information

  • Instance identifier
  • Instance class
  • Storage size
  • Engine type and version
  • Multi-AZ status

Utilization Metrics

  • CPU utilization (current and maximum)
  • Memory utilization (current and maximum)
  • Storage utilization
  • I/O metrics (IOPS, latency, queue depth)

Recommendations

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

Cost Analysis

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

Trend Analysis

When the --trend option is used, the script analyzes:

  • CPU usage trends (increasing, decreasing, or stable)
  • Memory usage trends
  • I/O usage trends

Troubleshooting

Common Issues

  1. 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
  2. Missing Metrics

    • Some metrics may not be available for all instance types
    • Ensure the instance has been running long enough to collect metrics
  3. Calculation Errors

    • Use the --debug option to see detailed calculation information
    • Check that all required tools (Python, bc, jq) are installed

Debug Mode

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 --debug

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • AWS CloudWatch for providing the metrics data
  • AWS CLI for enabling command-line access to AWS services

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages