PostgreSQL Collector

PostgreSQL collector script

Each inspection starts with a bash collector that runs on the target DB host. The script is zero-dependency, writes plain text, and is safe to run in production.

Download

pg_check.sh · 56 KB

Download

Or with curl

curl -O https://dbcheck.org/collector/pg.sh
chmod +x pg.sh

Requirements

  • bash 4+ · psql 客户端能直连本机 socket
  • 账号权限:postgres 超级用户(采集 pg_settings / pg_stat_replication 需要)
  • 环境变量 PGHOME 指向 PostgreSQL 安装目录(含 bin/psql)
  • 主备每个节点各跑一次,输出文本约 600-800 KB
  • Run it

    ./pg_check.sh 5432 postgres /data/pgsql/data \ > pg_$(hostname -s)_5432_$(date +%Y%m%d).log 2>&1 # 三参数:port / user / pgdata。脚本读 $PGHOME/bin/psql。 # 主备每个节点各跑一次(pg_check.sh 自己判断 primary/standby)。

    Output

    例:pg_demo-pg-primary_5432_20260605.log。引擎会通过文件内首行的 === primary/standby === 自动识别拓扑。

    Next

    → Upload the collector output to the PostgreSQL workspace