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://dbaclaw.com/collector/pg.sh
chmod +x pg.sh

Requirements

Run it

export PGHOME=/data/pgsql14
./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

建议把 stdout 重定向到带主机名 + 端口 + 日期的文件:

pg_<hostname>_<port>_<YYYYMMDD>.log

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

Next

→ Upload the collector output to the PostgreSQL workspace