如何使用 pg_isready 监控特定数据库?
实例:DBSPG10T1 版本:10.14 端口:6241
postgres@postgres # SELECT datname FROM pg_database;
datname
-----------
postgres
template1
template0
dbspg10t1
[postgres@HOSTNAME ~]$ if pg_isready -d postgres://localhost:6241/dbspg10t1; then echo "200 OK"; else echo "500 NOT OK"; fi
localhost:6241 - accepting connections
200 OK
数据库测试不存在,但 pg_isready 仍然返回 ok。
[postgres@HOSTNAME ~]$ if pg_isready -d postgres://localhost:6241/test; then echo "200 OK"; else echo "500 NOT OK"; fi
localhost:6241 - accepting connections
200 OK
这是语法问题吗?