Logo vun Postgres Daily Check

Postgres Daily Check

Communautéit
digoal
postgres-daily-check

This skill is designed to perform comprehensive daily health checks on a PostgreSQL database. It leverages a suite of specialized SQL queries and analysis logic to provide insights into database availability, performance, activity, maintenance, storage, replication, and archiving status. The skill aims to identify potential issues such as blocking locks, long-running queries, transaction ID wraparound risks, bloat in tables and indexes, connection bottlenecks, and archiving failures.

Iwwersiicht

Editeurdigoal
Repositorypostgres_skill
Skill-Nummpostgres-daily-check
Stären
39
Forks
13
Matgeliwwert Fichieren
3
LizenzGPL-3.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 3 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum digoal op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Postgres Daily Check an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/digoal/postgres_skill/tree/main/postgres-daily-check
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/digoal/postgres_skill.git /tmp/postgres_skill
mkdir -p .claude/skills
cp -r /tmp/postgres_skill/postgres-daily-check .claude/skills/postgres-daily-check
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Postgres Daily Check an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Postgres Daily Check automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Postgres Daily Check net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

PostgreSQL Daily Check Agent

This skill guides the agent in conducting a thorough daily health check of a PostgreSQL database instance. It executes a series of specialized queries to gather critical metrics and identifies potential issues, presenting them in a structured report.

Purpose

The primary goal of this skill is to empower the agent to proactively monitor the health and performance of a PostgreSQL database, alerting users to anomalies or potential problems before they escalate. It acts as an automated DBA, performing routine inspections efficiently.

Core Capabilities

The agent performs checks across several key areas:

  • Availability & Health: Verifying database responsiveness and detecting critical errors like invalid indexes, XID/MultiXactId wraparound risks, and deadlock occurrences.
  • Performance & Activity: Monitoring active sessions, long-running queries, cache efficiency, transaction rollback rates, identifying application hotspots, and tracking temporary file usage.
  • Security: Checking connection encryption status (SSL/GSSAPI) to ensure data transmission security.
  • Replication & Archiving: Ensuring data consistency and recoverability by checking replication lag, slot status, and WAL archiving health.
  • Maintenance & Storage: Analyzing disk usage, identifying bloat in tables and indexes, checking autovacuum activity, and monitoring sequence exhaustion.

Workflow

When activated, this skill executes a predefined sequence of checks. Each check involves calling a specialized script (run_postgres_check.sh) which executes specific SQL queries against the target PostgreSQL database. The results are then analyzed by the agent, and a comprehensive Markdown report is generated.

Warning Strategy Guidelines

The default warning thresholds are designed for general-purpose use. You should adjust them based on your specific workload characteristics:

OLTP Systems (Low Latency Required)

  • Long-running queries: Set threshold to 1 minute or less
  • Cache hit rate: Target >99%, warning at <97%
  • Connection usage: More aggressive thresholds (WARNING at >70%, ERROR at >90%)

Analytical/Reporting Systems

  • Long-running queries: Higher thresholds acceptable (10-30 minutes)
  • Cache hit rate: Lower hit rates expected due to large scans (warning at <90%)
  • Temp file usage: Higher tolerance for temporary files

General Recommendations

  • bgwriter maxwritten_clean: Monitor trends over time rather than single values
  • Checkpointer stats: Focus on average write/sync times per checkpoint rather than totals
  • XID/MultiXactId wraparound: Always maintain conservative thresholds regardless of workload

All thresholds in postgres_agent.py can be customized by modifying the analysis logic.

Available Skills

Each item below represents a callable skill within the run_postgres_check.sh script, designed to return structured JSON output.


1. Core Health & Availability

Skill: get_invalid_indexes

  • Description: Checks for any indexes that are in an invalid state. Invalid indexes can cause DML operations to fail or block.
  • Usage: ./run_postgres_check.sh get_invalid_indexes
  • Expected Output:
    json
    {
      "skill": "get_invalid_indexes",
      "status": "success",
      "data": [
        {"index_name": "idx_my_invalid_idx", "schema_name": "public"}
      ]
    }
  • Analysis: Reports ERROR if any invalid indexes are found.

Skill: get_xid_wraparound_risk

  • Description: Monitors the age of transaction IDs (XID) for each database to detect potential transaction ID wraparound issues.
  • Usage: ./run_postgres_check.sh get_xid_wraparound_risk
  • Expected Output:
    json
    {
      "skill": "get_xid_wraparound_risk",
      "status": "success",
      "data": [
        {"datname": "postgres", "xid_age": 1234567, "percentage_used": 0.05}
      ]
    }
  • Analysis: Reports CRITICAL ERROR if XID age >85%, WARNING if >70%.

Skill: get_multixid_wraparound_risk

  • Description: Monitors the age of MultiXactId (multi-transaction IDs) for each database. Similar to XID wraparound, MultiXactId wraparound can also lead to data loss and requires monitoring. Note: age(datminmxid) = 2147483647 (INT_MAX) indicates the MultiXactId is frozen or invalid, which is normal and not a risk.
  • Usage: ./run_postgres_check.sh get_multixid_wraparound_risk
  • Expected Output:
    json
    {
      "skill": "get_multixid_wraparound_risk",
      "status": "success",
      "data": [
        {
          "datname": "postgres",
          "mxid_age": 1234567,
          "datminmxid": 12345,
          "freeze_max_age": 400000000,
          "status": "OK",
          "remaining_to_autovacuum": 398765433
        }
      ]
    }
  • Analysis:
    • FROZEN/INVALID: datminmxid = 0 or age = INT_MAX - MultiXactIds are frozen, no risk ✅
    • OK: More than 30M MultiXactIds remaining before forced autovacuum ✅
    • WARNING: Less than 40M remaining - Getting close to threshold 🟠
    • CRITICAL: Less than 3M remaining - Approaching wraparound ❌
    • FORCE_AUTOVACUUM: Age >= autovacuum_multixact_freeze_max_age - Autovacuum will be forced 🟠
  • Official Doc: PostgreSQL Routine Maintenance - Preventing Transaction ID Wraparound Failures

Skill: get_blocking_locks

  • Description: Identifies active blocking lock situations where one session holds a lock that another is waiting for.
  • Usage: ./run_postgres_check.sh get_blocking_locks
  • Expected Output:
    json
    {
      "skill": "get_blocking_locks",
      "status": "success",
      "data": [
        {"waiting_pid": 123, "waiting_user": "app_user", "blocking_pid": 456, "blocking_user": "db_admin"}
      ]
    }
  • Analysis: Reports ERROR if any blocking locks are found.

Skill: get_deadlock_detection

  • Description: Checks for deadlocks that have occurred since the last stats reset.
  • Usage: ./run_postgres_check.sh get_deadlock_detection
  • Expected Output:
    json
    {
      "skill": "get_deadlock_detection",
      "status": "success",
      "data": [{"datname": "postgres", "deadlock_count": 0}]
    }
  • Analysis: Reports ERROR if deadlock_count > 0.

Skill: get_critical_settings

  • Description: Reviews critical PostgreSQL settings (fsync, synchronous_commit, etc.) for security and performance.
  • Usage: ./run_postgres_check.sh get_critical_settings
  • Expected Output:
    json
    {
      "skill": "get_critical_settings",
      "status": "success",
      "data": [
        {"name": "fsync", "setting": "on", "short_desc": "..."}
      ]
    }
  • Analysis: Reports CRITICAL ERROR if fsync=off.

Skill: get_connection_security_status

  • Description: Checks SSL/GSSAPI encryption status for active connections. Security audit to ensure connections use proper encryption.
  • Usage: ./run_postgres_check.sh get_connection_security_status
  • Expected Output:
    json
    {
      "skill": "get_connection_security_status",
      "status": "success",
      "data": [
        {"datname": "postgres", "usename": "app_user", "ssl_enabled": true, "ssl_version": "TLSv1.3", "connection_type": "SSL"}
      ]
    }
  • Analysis: Reports WARNING if unencrypted remote TCP connections found. SSL or GSSAPI encryption recommended for production.
  • Official Doc: PostgreSQL SSL Support, pg_stat_ssl, pg_stat_gssapi

2. Session & Connection Monitoring

Skill: get_long_running_queries

  • Description: Finds active queries running longer than threshold (default 5 minutes for general use, 1 minute recommended for OLTP systems).
  • Usage: ./run_postgres_check.sh get_long_running_queries [threshold_minutes]
  • Parameters: threshold_minutes - Threshold in minutes (default: 5)
  • Expected Output:
    json
    {
      "skill": "get_long_running_queries",
      "status": "success",
      "data": [
        {"pid": 123, "usename": "app_user", "duration": "00:06:30", "query": "SELECT ..."}
      ]
    }
  • Analysis: Reports WARNING if any long-running queries found. For OLTP systems with strict response time requirements, consider setting threshold to 1 minute.

Skill: get_idle_in_transaction_sessions

  • Description: Detects sessions "idle in transaction" longer than threshold (default 1 minute).
  • Usage: ./run_postgres_check.sh get_idle_in_transaction_sessions [threshold_minutes]
  • Analysis: Reports WARNING if any found. These hold locks and prevent VACUUM.

Skill: get_long_running_transactions

  • Description: Finds non-idle transactions running longer than threshold (default 1 hour).
  • Usage: ./run_postgres_check.sh get_long_running_transactions [threshold_hours]
  • Analysis: Lists transactions ordered by start time.

Skill: get_long_running_prepared_transactions

  • Description: Finds prepared transactions (2PC) older than threshold.
  • Usage: ./run_postgres_check.sh get_long_running_prepared_transactions [threshold_hours]
  • Analysis: Reports WARNING if any found.

Skill: get_connection_usage

  • Description: Reports current connection count vs max_connections.
  • Usage: ./run_postgres_check.sh get_connection_usage
  • Analysis: ERROR if >95%, WARNING if >80%.

Skill: get_lock_waiters

  • Description: Detailed view of all sessions waiting for locks.
  • Usage: ./run_postgres_check.sh get_lock_waiters
  • Analysis: WARNING if >5 lock waiters detected.

Skill: get_wait_events

  • Description: Shows current wait events for active sessions (what resources they are waiting on).
  • Usage: ./run_postgres_check.sh get_wait_events
  • Analysis: Lists top 10 wait events by occurrence.

3. Performance & Activity

Skill: get_cache_hit_rate

  • Description: Calculates block cache hit rate. Low rate indicates memory pressure or bad queries. Threshold should be adjusted based on workload characteristics.
  • Usage: ./run_postgres_check.sh get_cache_hit_rate
  • Analysis: WARNING if hit rate <95%. For some workloads, 90% may be acceptable. OLTP systems should target >99%, while analytical workloads may have lower hit rates due to large table scans.
  • Note: The 99% threshold may be too strict for certain workloads. Adjust based on your performance baseline.

Skill: get_rollback_rate

  • Description: Calculates transaction rollback percentage. High rate (>5%) may indicate app issues.
  • Usage: ./run_postgres_check.sh get_rollback_rate
  • Analysis: WARNING if rollback rate >5%.

Skill: get_top_sql_by_time

  • Description: Top 5 queries by total execution time from pg_stat_statements.
  • Usage: ./run_postgres_check.sh get_top_sql_by_time
  • Note: Requires pg_stat_statements extension.
  • Analysis: Lists queries with total time, avg time, and call count.

Skill: get_table_hotspots

  • Description: Tables with highest DML and scan activity.
  • Usage: ./run_postgres_check.sh get_table_hotspots
  • Analysis: Lists top 5 tables by total DML operations.

Skill: get_bgwriter_stats

  • Description: Background writer statistics and buffer allocation.
  • Usage: ./run_postgres_check.sh get_bgwriter_stats
  • Analysis: WARNING if maxwritten_clean remains high over time (persistent high values indicate bgwriter tuning issues). Occasional >0 values are normal. Consider monitoring the trend rather than single values.
  • Note: maxwritten_clean indicates the number of times the background writer stopped a cleaning scan because it had written too many buffers. While this can indicate insufficient bgwriter capacity, occasional occurrences are normal and not necessarily a concern.

Skill: get_temp_file_usage

  • Description: Shows databases with temporary file usage.
  • Usage: ./run_postgres_check.sh get_temp_file_usage
  • Analysis: Lists databases with temp file statistics.

Skill: get_total_temp_bytes

  • Description: Shows databases with total temporary file bytes exceeding threshold. More accurate than file count for disk space impact assessment.
  • Usage: ./run_postgres_check.sh get_total_temp_bytes [threshold_gb]
  • Parameters: threshold_gb - Minimum temp bytes in GB to report (default: 1GB)
  • Expected Output:
    json
    {
      "skill": "get_total_temp_bytes",
      "status": "success",
      "data": [
        {"datname": "postgres", "temp_files": 150, "temp_bytes": 2147483648, "temp_bytes_gb": 2.0}
      ]
    }
  • Analysis: Reports WARNING if total temp space >10GB. High temp usage indicates insufficient work_mem or inefficient queries.
  • Official Doc: pg_stat_database

Skill: get_io_statistics

  • Description: Reports I/O statistics including temp file usage, block reads/hits, and I/O timing. Useful for identifying I/O bottlenecks and inefficient queries.
  • Usage: ./run_postgres_check.sh get_io_statistics
  • Analysis: WARNING if temp_files > 100.

Skill: get_analyze_progress

  • Description: Monitors running ANALYZE operations, showing progress, current phase, and scan progress. Useful for identifying long-running statistics collection.
  • Usage: ./run_postgres_check.sh get_analyze_progress
  • Expected Output:
    json
    {
      "skill": "get_analyze_progress",
      "status": "success",
      "data": [{
        "pid": 12345,
        "datname": "postgres",
        "relname": "users",
        "phase": "acquiring sample rows",
        "sample_blks_total": 1000,
        "sample_blks_scanned": 500,
        "scan_progress_pct": 50.0
      }]
    }
  • Analysis: WARNING if delay_time is high (throttled by vacuum_cost_delay).

Skill: get_create_index_progress

  • Description: Monitors CREATE INDEX and REINDEX operations progress, showing phase, blocks, and tuples processed.
  • Usage: ./run_postgres_check.sh get_create_index_progress
  • Analysis: Shows current phase and progress. Useful for capacity planning.

Skill: get_cluster_progress

  • Description: Monitors CLUSTER and VACUUM FULL operations progress.
  • Usage: ./run_postgres_check.sh get_cluster_progress
  • Analysis: Shows phase, tuples scanned/written. WARNING if stuck in 'sorting tuples' phase.

Skill: get_wal_statistics

  • Description: Reports WAL activity statistics including records, FPIs, bytes written, and buffer fullness.
  • Usage: ./run_postgres_check.sh get_wal_statistics
  • Expected Output:
    json
    {
      "skill": "get_wal_statistics",
      "status": "success",
      "data": [{
        "wal_records": 500000,
        "wal_fpi": 10000,
        "wal_bytes": "2 GB",
        "wal_buffers_full": 50
      }]
    }
  • Analysis: WARNING if wal_buffers_full is high (consider increasing wal_buffers).

Skill: get_slru_stats

  • Description: Reports SLRU (Simple Least-Recently-Used) cache statistics for internal subsystems like MultiXact, CommitTs, Subtransaction, and Transaction managers. Low hit ratios may indicate undersized SLRU buffers.
  • Usage: ./run_postgres_check.sh get_slru_stats
  • Expected Output:
    json
    {
      "skill": "get_slru_stats",
      "status": "success",
      "data": [
        {"name": "transaction", "blks_hit": 84086814, "blks_read": 1768614, "hit_ratio": 97.94}
      ]
    }
  • Analysis: WARNING if hit ratio < 90% and blks_read > 1000. Low hit ratios may require tuning SLRU buffer sizes via postgresql.conf.
  • Official Doc: pg_stat_slru

Skill: get_io_statistics_v2

  • Description: Extended I/O statistics from pg_stat_io (PostgreSQL 16+), showing detailed read/write/extending statistics by backend type, object type, and context. Provides better visibility into I/O patterns than traditional pg_stat_database.
  • Usage: ./run_postgres_check.sh get_io_statistics_v2
  • Note: Only available on PostgreSQL 16 and later. Falls back gracefully on older versions.
  • Expected Output:
    json
    {
      "skill": "get_io_statistics_v2",
      "status": "success",
      "data": [
        {
          "backend_type": "client backend",
          "object": "relation",
          "context": "normal",
          "reads": 1000,
          "read_bytes": 8192000,
          "writes": 500,
          "write_bytes": 4096000,
          "hits": 50000
        }
      ]
    }
  • Analysis: Reports I/O statistics by backend type and context. Useful for understanding I/O patterns, identifying which backend types are causing I/O, and pinpointing performance bottlenecks. Compare reads vs hits to assess cache efficiency per backend type.
  • Official Doc: pg_stat_io

Skill: get_user_function_stats

  • Description: Reports user-defined function performance statistics including call counts, total execution time, and self time. Helps identify slow or frequently called functions that may need optimization.
  • Usage: ./run_postgres_check.sh get_user_function_stats
  • Note: Requires track_functions = 'all' or 'pl' in postgresql.conf. If disabled, no data will be available.
  • Expected Output:
    json
    {
      "skill": "get_user_function_stats",
      "status": "success",
      "data": [
        {
          "funcid": 16384,
          "schemaname": "public",
          "funcname": "my_function",
          "calls": 1000,
          "total_time": 5000.0,
          "self_time": 3000.0,
          "avg_time_ms": 5.0
        }
      ]
    }
  • Analysis: Lists top time-consuming functions ordered by total_time. Functions with high total_time or high avg_time_ms are candidates for optimization. Consider function refactoring, better indexing, or query optimization.
  • Official Doc: pg_stat_user_functions

Skill: get_database_conflict_stats

  • Description: Reports query cancellations due to conflicts on standby servers. Conflicts occur when standby queries conflict with WAL replay operations (e.g., dropping a table being queried, tablespace changes, or snapshot conflicts).
  • Usage: ./run_postgres_check.sh get_database_conflict_stats
  • Note: Only applicable on standby/replica servers. Will return empty on primary servers.
  • Expected Output:
    json
    {
      "skill": "get_database_conflict_stats",
      "status": "success",
      "data": [
        {
          "datname": "postgres",
          "confl_tablespace": 0,
          "confl_lock": 0,
          "confl_snapshot": 5,
          "confl_bufferpin": 0,
          "confl_deadlock": 0,
          "confl_active_logicalslot": 0
        }
      ]
    }
  • Analysis: WARNING if any conflicts detected. High snapshot conflicts indicate standby queries running too long while WAL is being replayed. Consider tuning max_standby_streaming_delay or hot_standby_feedback. Lock conflicts may require shorter queries on standby.
  • Official Doc: pg_stat_database_conflicts

Skill: get_checkpointer_stats

  • Description: Reports checkpointer activity including timed vs requested checkpoints, I/O time, and buffers written.
  • Usage: ./run_postgres_check.sh get_checkpointer_stats
  • Analysis: WARNING if requested checkpoints >> timed (tune max_wal_size) or high I/O time.

Skill: get_checkpointer_write_sync_time

  • Description: Detailed analysis of checkpointer write and sync times to identify I/O bottlenecks. Calculates average times per checkpoint.
  • Usage: ./run_postgres_check.sh get_checkpointer_write_sync_time
  • Expected Output:
    json
    {
      "skill": "get_checkpointer_write_sync_time",
      "status": "success",
      "data": [
        {
          "num_timed": 100,
          "num_requested": 50,
          "write_time_ms": 5000.0,
          "sync_time_ms": 2000.0,
          "avg_write_time_per_checkpoint_ms": 33.33,
          "avg_sync_time_per_checkpoint_ms": 13.33,
          "checkpointer_status": "OK"
        }
      ]
    }
  • Analysis: Reports WARNING if avg write/sync time per checkpoint >5000ms, or if requested checkpoints significantly exceed timed checkpoints. Helps identify storage I/O bottlenecks.
  • Official Doc: pg_stat_checkpointer

4. Replication & Archiving

Skill: get_replication_slots

  • Description: Checks physical and logical replication slots status.
  • Usage: ./run_postgres_check.sh get_replication_slots
  • Analysis: ERROR if any inactive slots found.

Skill: get_replication_status

  • Description: Checks streaming replication lag and status.
  • Usage: ./run_postgres_check.sh get_replication_status
  • Analysis: ERROR if lag >1GB, WARNING if lag >100MB.

Skill: get_logical_replication_status

  • Description: Checks logical subscription lag (send/receive delays).
  • Usage: ./run_postgres_check.sh get_logical_replication_status
  • Analysis: Lists logical subscriptions with lag seconds.

Skill: get_wal_archiver_status

  • Description: WAL archiving status and WAL directory size.
  • Usage: ./run_postgres_check.sh get_wal_archiver_status
  • Analysis: ERROR if failed_count > 0.

5. Maintenance & Storage

Skill: get_autovacuum_status

  • Description: Checks currently running autovacuum workers.
  • Usage: ./run_postgres_check.sh get_autovacuum_status
  • Analysis: Lists active autovacuum processes.

Skill: get_table_bloat

  • Description: Estimates wasted space (bloat) in top 10 largest tables.
  • Usage: ./run_postgres_check.sh get_table_bloat
  • Analysis: WARNING if bloat >20% and wasted >100MB.

Skill: get_index_bloat

  • Description: Estimates wasted space in top 10 largest indexes.
  • Usage: ./run_postgres_check.sh get_index_bloat
  • Analysis: WARNING if bloat >20% and wasted >100MB.

Skill: get_top_objects_by_size

  • Description: Top 5 largest tables and indexes by disk size.
  • Usage: ./run_postgres_check.sh get_top_objects_by_size
  • Note: Uses relpages to avoid blocking on locked tables.
  • Analysis: Lists objects with size.

Skill: get_large_unused_indexes

  • Description: Indexes >10MB that have never been scanned (idx_scan=0).
  • Usage: ./run_postgres_check.sh get_large_unused_indexes
  • Analysis: WARNING if any found (candidates for removal).

Skill: get_stale_statistics

  • Description: Tables with >10% rows modified since last ANALYZE.
  • Usage: ./run_postgres_check.sh get_stale_statistics
  • Analysis: WARNING if any found (may cause poor query plans).

Skill: get_database_sizes

  • Description: Size of top 10 largest databases.
  • Usage: ./run_postgres_check.sh get_database_sizes
  • Analysis: Lists databases with sizes.

Skill: get_sequence_exhaustion

  • Description: Sequences approaching max value (>80% used).
  • Usage: ./run_postgres_check.sh get_sequence_exhaustion
  • Analysis: WARNING if any sequences near exhaustion.

6. Freeze & Wraparound Protection

Skill: get_freeze_prediction

  • Description: Predicts which tables are approaching XID/MXID freeze thresholds.
  • Usage: ./run_postgres_check.sh get_freeze_prediction
  • Analysis: Reports CRITICAL/WARNING based on remaining ages.

7. Environment Setup

Requirements

  • psql command-line tool (PostgreSQL client, version 10+)
  • Python 3.6+ (uses only standard library, no additional packages)
  • Read access to pg_stat_statements (optional, for top SQL queries)

Configuration

Configure database connection in assets/db_config.env:

bash
export PGHOST="127.0.0.1"
export PGPORT="5432"
export PGUSER="digoal"
export PGPASSWORD="your_password"
export PGDATABASE="postgres"

Usage

bash
cd postgres-daily-check/scripts

# Run full health check (generates daily_health_report.md)
python3 postgres_agent.py

# Run individual skills
./run_postgres_check.sh get_long_running_queries
./run_postgres_check.sh get_table_bloat
./run_postgres_check.sh get_lock_waiters

Output

The agent generates daily_health_report.md with:

  • Overall status (OK / WARNING / ERROR)
  • Detailed findings for each check
  • Actionable recommendations for issues found

Skill Index

Skill NameCategoryDescription
get_invalid_indexesAvailabilityCheck for corrupted indexes
get_xid_wraparound_riskAvailabilityMonitor transaction ID wraparound
get_multixid_wraparound_riskAvailabilityMonitor MultiXactId wraparound
get_blocking_locksAvailabilityDetect lock contention
get_deadlock_detectionAvailabilityCheck for past deadlocks
get_critical_settingsAvailabilityReview critical parameters
get_connection_security_statusSecurityCheck SSL/GSSAPI encryption status
get_long_running_queriesSessionFind long-running queries
get_idle_in_transaction_sessionsSessionFind idle-in-transaction sessions
get_long_running_transactionsSessionFind long transactions
get_long_running_prepared_transactionsSessionFind stuck 2PC transactions
get_connection_usageSessionCheck connection pool usage
get_lock_waitersSessionDetailed lock wait analysis
get_wait_eventsSessionCurrent wait event analysis
get_cache_hit_ratePerformanceCache efficiency metric
get_rollback_ratePerformanceTransaction rollback ratio
get_top_sql_by_timePerformanceMost expensive queries
get_table_hotspotsPerformanceMost active tables
get_bgwriter_statsPerformanceBackground writer metrics
get_temp_file_usagePerformanceTemporary file usage
get_total_temp_bytesPerformanceTotal temp file bytes by database
get_io_statisticsPerformanceI/O statistics and timing
get_io_statistics_v2PerformanceExtended I/O statistics (pg_stat_io)
get_analyze_progressPerformanceANALYZE progress monitoring
get_create_index_progressPerformanceCREATE INDEX/REINDEX progress
get_cluster_progressPerformanceCLUSTER/VACUUM FULL progress
get_wal_statisticsPerformanceWAL activity statistics
get_checkpointer_statsPerformanceCheckpointer activity
get_checkpointer_write_sync_timePerformanceCheckpointer I/O time analysis
get_slru_statsPerformanceSLRU cache statistics
get_user_function_statsPerformanceUDF performance
get_replication_slotsReplicationReplication slot status
get_replication_statusReplicationStreaming replica lag
get_logical_replication_statusReplicationLogical subscription lag
get_wal_archiver_statusArchivingWAL archiving health
get_autovacuum_statusMaintenanceActive vacuum workers
get_table_bloatMaintenanceTable space bloat
get_index_bloatMaintenanceIndex space bloat
get_top_objects_by_sizeMaintenanceLargest objects
get_large_unused_indexesMaintenanceUnused large indexes
get_stale_statisticsMaintenanceOutdated table stats
get_database_sizesStorageDatabase sizes
get_sequence_exhaustionStorageSequence value exhaustion
get_freeze_predictionStorageFreeze storm prediction
get_database_conflict_statsStandbyRecovery conflicts

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Postgres Daily Check?

This skill is designed to perform comprehensive daily health checks on a PostgreSQL database. It leverages a suite of specialized SQL queries and analysis logic to provide insights into database availability, performance, activity, maintenance, storage, replication, and archiving status. The skill aims to identify potential issues such as blocking locks, long-running queries, transaction ID wraparound risks, bloat in tables and indexes, connection bottlenecks, and archiving failures.

Firwat Postgres Daily Check op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Postgres Daily Check besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Postgres Daily Check an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/digoal/postgres_skill/tree/main/postgres-daily-check an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Postgres Daily Check benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Postgres Daily Check benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Postgres Daily Check domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Postgres Daily Check gratis?

Jo. De Skill gëtt vum digoal ënner der Lizenz GPL-3.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇