observability.svc.plus/files/postgres/pg-heartbeat
2026-02-01 20:53:55 +08:00

18 lines
644 B
Bash
Executable File

#!/bin/bash
set -uo pipefail
#==============================================================#
# File : pg-heartbeat
# Desc : generate heartbeat record to local
# Ctime : 2022-12-31
# Mtime : 2025-12-30
# Path : /pg/bin/pg-heartbeat
# Deps : psql
# License : Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright : 2018-2026 Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#
SQL="SELECT *, now()::TIME AS now, date_trunc('seconds',now()-ts) AS elapse FROM monitor.beating();"
while true; do
psql postgres -qwXc "${SQL}"
sleep 1;
done