Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A7463CED706 for ; Wed, 1 Aug 2012 23:50:22 -0300 (ADT) Received: from na3sys009aog111.obsmtp.com ([74.125.149.205]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SwlUQ-0000eN-ET for pgsql-general@postgresql.org; Thu, 02 Aug 2012 02:50:21 +0000 Received: from sdcarl02.strategicdata.com.au ([203.214.67.82]) (using TLSv1) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKUBnq2jPkS0k+HE2mP7Dp3hjAyvro1VVt@postini.com; Wed, 01 Aug 2012 19:50:18 PDT Received: from [192.168.1.162] (adonai.mel.strategicdata.com.au [192.168.1.162]) by fitz-mail01.strategicdata.internal (Postfix) with ESMTP id 08E5F380D32 for ; Thu, 2 Aug 2012 12:50:00 +1000 (EST) Message-ID: <5019EAD8.9090908@strategicdata.com.au> Date: Thu, 02 Aug 2012 12:50:00 +1000 From: Toby Corkindale User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: Async replication: how to get an alert on failure References: <5019ADE5.4050800@simkorp.com.br> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201208/17 X-Sequence-Number: 189194 On 02/08/12 10:04, Edson Richter wrote: > I have few PostgreSQL servers established with replication. > Now, is there any way to receive an e-mail in case of error during > synchronization? > I mean, is there an script (cron?) I can run (maybe every 5 minutes) > that will check if replication is stolen, and send an e-mail in case of > failure? I created a little Perl script that just connects to the master and queries the pg_stat_replication statistics. It notes if (a) the client has disconnected entirely, or (b) if the client's replay position has still not reached the position that the master was in last time we checked. (So if you run the check every five minutes, you'll get a warning if the client is more than five minutes lagged behind the master)