| name | monitoring-database-health |
| description | Monitor use when you need to work with monitoring and observability.
This skill provides health monitoring and alerting with comprehensive guidance and automation.
Trigger with phrases like "monitor system health", "set up alerts",
or "track metrics".
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*) |
| version | 1.25.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["database","monitoring","observability"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Database Health Monitor
Overview
Monitor database server health across PostgreSQL, MySQL, and MongoDB by tracking key performance indicators including connection utilization, query throughput, replication lag, disk usage, cache hit ratios, vacuum activity, and lock contention.
Prerequisites
- Database credentials with access to system statistics views (
pg_stat_*, performance_schema, serverStatus)
psql, mysql, or mongosh CLI tools for running health check queries
- Permissions:
pg_monitor role (PostgreSQL), PROCESS privilege (MySQL)
- Baseline metrics from a period of normal operation for threshold calibration
- Alerting channel configured (email, Slack webhook, PagerDuty)
Instructions
-
Check connection utilization:
- PostgreSQL:
SELECT count(*) AS active_connections, (SELECT setting::int FROM pg_settings WHERE name = 'max_connections') AS max_connections, round(count(*)::numeric / (SELECT setting::int FROM pg_settings WHERE name = 'max_connections') * 100, 1) AS utilization_pct FROM pg_stat_activity
- MySQL:
SELECT VARIABLE_VALUE AS connections FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Threads_connected'
- Alert threshold: utilization above 80%
-
Monitor query throughput and error rate:
- PostgreSQL:
SELECT datname, xact_commit AS commits_total, xact_rollback AS rollbacks_total, xact_rollback::float / GREATEST(xact_commit, 1) AS rollback_ratio FROM pg_stat_database WHERE datname = current_database()
- MySQL:
SHOW GLOBAL STATUS LIKE 'Com_commit' and SHOW GLOBAL STATUS LIKE 'Com_rollback'
- Alert threshold: rollback ratio above 5% or throughput drops more than 50% from baseline
-
Check disk usage and growth:
- PostgreSQL:
SELECT pg_size_pretty(pg_database_size(current_database())) AS db_size and SELECT tablename, pg_size_pretty(pg_total_relation_size(tablename::text)) AS size FROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(tablename::text) DESC LIMIT 10
- Alert threshold: disk usage above 80% or growth rate projecting full disk within 7 days
-
Monitor cache hit ratio: