Script to check replication

From: Ashish Chauhan <Ashish(dot)Chauhan(at)support(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Script to check replication
Date: 2016-03-04 19:35:16
Message-ID: 6837D32772C03D42BF09864A2DACFF9B1D3195A0@dcmail02.supportsoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

We are running Streaming replication with Hot standby in our current production. I do have below script to check replication status and replication lag. Does anyone have script which runs every 15 mins to check replication status and send out email if replication is not running or lagging behind.

SELECT pg_last_xlog_receive_location() receive, pg_last_xlog_replay_location() replay, now() - pg_last_xact_replay_timestamp() AS replication_delay, (extract(epoch FROM now()) - extract(epoch FROM pg_last_xact_replay_timestamp()))::int lag

Thanks for your help!

Thanks,
Ashish Chauhan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message MOLINA BRAVO FELIPE DE JESUS 2016-03-04 20:03:27 query reboot pgsql 9.5.1
Previous Message David G. Johnston 2016-03-04 18:33:40 Re: multiple UNIQUE indices for FK