#!/bin/bash CHECKSQL="SELECT application_name AS name, COALESCE(client_hostname, CAST(client_addr AS TEXT)) AS client, state, sync_state AS type, pg_wal_lsn_diff(sent_lsn, replay_lsn) AS lag FROM pg_stat_replication" echo "$CHECKSQL" | psql -U postgres -h firebrand echo "$CHECKSQL" | psql -U postgres -h defiant