60 lines
1.5 KiB
Bash
Executable File
60 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Collect infrastructure metrics
|
|
|
|
set -e
|
|
|
|
# Load shared libraries
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../../lib/init.sh"
|
|
|
|
PROJECT_ROOT="$(get_project_root)"
|
|
METRICS_FILE="$PROJECT_ROOT/docs/metrics-data.json"
|
|
OUTPUT_FILE="$PROJECT_ROOT/docs/metrics-reports/infrastructure-$(date +%Y-%m-%d).json"
|
|
|
|
log_heading "📊 Collecting Infrastructure Metrics..."
|
|
|
|
ensure_dir "$PROJECT_ROOT/docs/metrics-reports"
|
|
|
|
# Initialize metrics object
|
|
cat > "$OUTPUT_FILE" << 'EOF'
|
|
{
|
|
"date": "",
|
|
"infrastructure": {
|
|
"costs": {
|
|
"current": null,
|
|
"baseline": null,
|
|
"reduction": null,
|
|
"target": 35
|
|
},
|
|
"sharedInfrastructure": {
|
|
"totalProjects": null,
|
|
"migratedProjects": null,
|
|
"percentage": null,
|
|
"target": 80
|
|
},
|
|
"infrastructureAsCode": {
|
|
"totalInfrastructure": null,
|
|
"iacCoverage": null,
|
|
"percentage": null,
|
|
"target": 100
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# Update date
|
|
if command -v jq &> /dev/null; then
|
|
jq ".date = \"$(date -Iseconds)\"" "$OUTPUT_FILE" > "$OUTPUT_FILE.tmp"
|
|
mv "$OUTPUT_FILE.tmp" "$OUTPUT_FILE"
|
|
fi
|
|
|
|
log_success "Infrastructure metrics template created: $OUTPUT_FILE"
|
|
echo ""
|
|
log_step "To collect metrics:"
|
|
log_info " 1. Review cloud provider cost reports"
|
|
log_info " 2. Count projects using shared infrastructure"
|
|
log_info " 3. Audit infrastructure as code coverage"
|
|
log_info " 4. Update values in $OUTPUT_FILE"
|
|
log_info " 5. Run: ./scripts/metrics/update-metrics.sh infrastructure"
|
|
|