| name | database-management |
| description | Database operations and health monitoring. USE FOR: PostgreSQL health check, database backup, database restore, connection string, database migration, database monitoring. DO NOT USE FOR: Azure infrastructure provisioning (use azure-cli), Terraform IaC (use terraform-cli), application code (use @devops). |
When to Use
- Database health checks
- Connection verification
- Performance monitoring
- Backup status verification
Prerequisites
- Azure CLI for Azure databases
- psql for PostgreSQL operations
- Appropriate database credentials
Commands
Azure PostgreSQL
az postgres flexible-server list -o table
az postgres flexible-server show --name <server> --resource-group <rg>
az postgres flexible-server firewall-rule list --name <server> --resource-group <rg>
az postgres flexible-server show --name <server> --resource-group <rg> --query "backup"
Connection Testing
psql "host=<host> dbname=<db> user=<user> sslmode=require" -c "SELECT version();"
psql -c "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"
Health Monitoring
psql -c "SELECT pg_size_pretty(pg_database_size(current_database()));"
psql -c "SELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))
FROM pg_tables ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;"
Best Practices
- Use private endpoints for database connectivity
- Enable SSL/TLS for all connections
- Configure automated backups
- Monitor connection pool usage
- Set up alerts for high CPU/memory
Output Format
- Command executed
- Database status summary
- Any issues detected
- Recommendations
Integration with Agents
Used by: @terraform, @sre, @test