I have some Slaves running with Streaming Replication, and would like to monitor the streaming replication.
I'm currently using these queries:
On master:
SELECT client_hostname
, client_addr
, pg_xlog_location_diff(pg_stat_replication.sent_location, pg_stat_replication.replay_location) AS byte_lag
FROM pg_stat_replication
On slave:
select now() - pg_last_xact_replay_timestamp() AS replication_delay;
Is there any way I can create a table and put this data into it? Every minute?
I could create a PL/PGSQL function but, how to make it run every minute?