monitoring-database-health
БесплатноЗапускает вложенные скриптыНе проверенMonitor use when you need to work with monitoring and observability. This skill provides health monitoring and alerting with comprehensive guidance and…
от jeremylongshore★ 2 961 звезда на GitHubОб этом скилле
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, ormongoshCLI tools for running health check queries- Permissions:
pg_monitorrole (PostgreSQL),PROCESSprivilege (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%
- PostgreSQL:
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'andSHOW GLOBAL STATUS LIKE 'Com_rollback' - Alert threshold: rollback ratio above 5% or throughput drops more than 50% from baseline
- PostgreSQL:
Check disk usage and growth:
- PostgreSQL:
SELECT pg_size_pretty(pg_database_size(current_database())) AS db_sizeandSELECT 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
- PostgreSQL:
Monitor cache hit ratio:
- PostgreSQL:
SELECT sum(heap_blks_hit)::float / GREATEST(sum(heap_blks_hit) + sum(heap_blks_read), 1) AS cache_hit_ratio FROM pg_statio_user_tables - MySQL:
SELECT (1 - (VARIABLE_VALUE / (SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Innodb_buffer_pool_read_requests'))) AS hit_ratio FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Innodb_buffer_pool_reads' - Alert threshold: cache hit ratio below 95% indicates shared_buffers or innodb_buffer_pool_size needs increasing
- PostgreSQL:
Check vacuum and autovacuum health (PostgreSQL):
SELECT relname, last_vacuum, last_autovacuum, n_dead_tup, n_live_tup, round(n_dead_tup::numeric / GREATEST(n_live_tup, 1) * 100, 1) AS dead_pct FROM pg_stat_user_tables WHERE n_dead_tup > 1000 ORDER BY n_dead_tup DESC LIMIT 10- Alert threshold: dead tuple percentage above 20% or autovacuum not running for more than 24 hours on active tables
Monitor replication lag (if replicas exist):
- PostgreSQL:
SELECT client_addr, state, pg_wal_lsn_diff(sent_lsn, replay_lsn) AS lag_bytes FROM pg_stat_replication - MySQL:
SHOW REPLICA STATUS\G- checkSeconds_Behind_Source - Alert threshold: lag above 30 seconds or replication stopped
- PostgreSQL:
Check for long-running queries:
- PostgreSQL:
SELECT pid, now() - query_start AS duration, state, query FROM pg_stat_activity WHERE state != 'idle' AND now() - query_start > interval '5 minutes' ORDER BY duration DESC - Alert threshold: any query running longer than 10 minutes (OLTP) or 1 hour (analytics)
- PostgreSQL:
Monitor lock contention:
- PostgreSQL:
SELECT count(*) AS waiting_queries FROM pg_stat_activity WHERE wait_event_type = 'Lock' - Alert threshold: more than 10 queries waiting for locks simultaneously
- PostgreSQL:
Compile all health checks into a single monitoring script that runs via cron every 60 seconds, outputs metrics in a structured format (JSON), and triggers alerts when thresholds are breached.
Create a health summary dashboard query that returns a single-row result with RAG (Red/Amber/Green) status for each health dimension: connections, throughput, disk, cache, vacuum, replication, queries, and locks.
Output
- Health check queries tailored to the specific database engine
- Monitoring script (shell or Python) for scheduled health checks with alerting
- Threshold configuration with default values and tuning guidance
- Dashboard summary query providing RAG status across all health dimensions
- Alert notification templates for Slack, email, or PagerDuty integration
Error Handling
| Error | Cause | Solution |
|---|---|---|
pg_stat_activity returns incomplete data |
track_activities = off in postgresql.conf |
Enable track_activities = on and track_counts = on; reload configuration |
| Health check query itself times out |
Установить monitoring-database-health в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditGrepGlobBash(psql:*)Bash(mysql:*)Bash(mongosh:*)Вложенные файлы
FAQ
Что делает скилл monitoring-database-health?
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".
Как установить скилл monitoring-database-health?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл monitoring-database-health запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub