Re: Monitoring of a hot standby with a largely idle master

From: Lucas Possamai <drum(dot)lucas(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Monitoring of a hot standby with a largely idle master
Date: 2017-07-15 10:39:37
Message-ID: CAE_gQfUMzm3g2=DPXb-aw=y5Ma=5oFSvBGDA2aVRiqK1vYu4Fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2017-07-13 20:15 GMT+12:00 Michael Paquier <michael(dot)paquier(at)gmail(dot)com>:

> On Thu, Jul 13, 2017 at 5:26 AM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> >
> > I think that none of the recovery information functions
> > (https://www.postgresql.org/docs/9.6/static/functions-
> admin.html#FUNCTIONS-RECOVERY-INFO-TABLE)
> > can distinguish a hot standby which is connected to an idle master,
> versus
> > one which is disconnected. For example, because the master has crashed,
> or
> > someone has changed the firewall rules.
> >
> > Is there a way to monitor from SQL the last time the standby was able to
> > contact the master and initiate streaming with it? Other than trying to
> > write a function that parses it out of pg_log?
>
> Not directly I am afraid. One way I can think about is to poll
> periodically the state of pg_stat_replication on the primary or
> pg_stat_wal_receiver on the standby and save it in a custom table. The
> past information is not persistent as any replication-related data in
> catalogs is based on the shared memory state of the WAL senders and
> the WAL receiver, and those are wiped out at reconnection.
> --
> Michael
>
>
>
That works for me too! I do this way... cron job runs that every X minutes
and if the replication lag is higher than 1 second it sends me an email..

It works pretty well and I used bash.

Lucas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Clodoaldo Neto 2017-07-15 11:38:46 Failed DNF dependency in Fedora
Previous Message Tom Lane 2017-07-15 00:10:06 Re: puzzled by deletion performance