An automated tool for generating comprehensive inventory reports of Oracle Cloud Infrastructure (OCI) Autonomous Databases across multiple compartments. Perfect for cloud administrators, database managers, and DevOps teams managing large OCI deployments.
🎯 Key Features
- Multi-Compartment Support: Monitor databases across different environments (prod/nonprod)
- Detailed Storage Analytics: Both GB and TB measurements with precise decimal values
- Comprehensive Database Information: From basic details to advanced configurations
- Environment-Aware Reporting: Distinguish between production and non-production databases
- CSV Export: Easy integration with data analysis tools and reporting systems
📋 Prerequisites
Before using this tool, ensure you have:
- Oracle Cloud Infrastructure (OCI) CLI installed and configured
jq
command-line JSON processor- Bash shell environment (Linux/Mac/WSL)
- Appropriate OCI permissions for listing Autonomous Databases
🚀 Quick Start
1. Installation
# Clone the repository
git clone https://github.com/littleworks-inc/oci-adb-inventory.git
# Navigate to directory
cd oci-adb-inventory
# Make script executable
chmod +x get_adb_details.sh
2. Configuration
Create a compartments.txt
file with your compartment details:
ocid1.compartment.oc1..xxxx nonprod
ocid1.compartment.oc1..yyyy prod
3. Usage
# Using compartments file
./get_adb_details.sh -f compartments.txt
# Direct compartment specification
./get_adb_details.sh ocid1.compartment.oc1..xxxx ocid1.compartment.oc1..yyyy
📊 Generated Report Details
The script generates a detailed CSV report containing:
Category | Fields |
---|---|
Environment Info | Environment Type, Compartment ID |
Database Identity | Container DB ID, Database OCID, DB Name, DB Version |
Storage Metrics | Storage GB/TB, Used Storage GB/TB |
Compute Details | Compute Model, Compute Count |
Status Information | Lifecycle State |
Configuration | Maintenance Schedule, Upgrade Versions |
Backup Information | Backup Config, Backup Retention Days |
Memory Details | In Memory GB, Memory Percentage |
🔍 Code Explanation
Script Structure
├── get_adb_details.sh # Main script file
└── examples/
└── compartments.txt # Example compartments configuration
Key Components Explained
- CSV Header Generation
echo "Environment,Compartment ID,Container DB ID..." > "$output_file"
Defines the structure of the output report with all necessary fields.
- Environment Processing
read -r compartment_id environment <<< "$line"
Parses compartment ID and environment (prod/nonprod) from input file.
- OCI Data Collection
oci db autonomous-database list \
--compartment-id "$compartment_id" \
--query 'data[*]...
Retrieves detailed database information using OCI CLI.
- Storage Calculations
($row."used_storage_gb" // 0 | . / 1024 | tostring | if contains(".") then . else . + ".000" end)
Converts storage values from GB to TB with precise decimal formatting.
- Data Export
jq -r --arg env "$environment" '.[] | . as $row |...'
Formats and exports data to CSV with proper environment tagging.
🔧 Advanced Configuration
Customizing Output Format
To modify the CSV format or add new fields:
- Add new field to the CSV header
- Include the field in the OCI CLI query
- Add field to the jq output formatting
Example adding a new field:
# Add to header
echo "Environment,...,New Field" > "$output_file"
# Add to query
--query 'data[*].{
"new_field": "new-field-name",
...
}'
# Add to output
jq -r '[
$env,
.new_field,
...
] | @csv'
📈 Performance Considerations
- Script processes one compartment at a time
- Storage calculations are performed in-memory
- CSV output is appended sequentially