Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-30 Thread John R Pierce
On 11/30/2016 11:57 AM, Patrick B wrote: but there is queries like this: select now() - pg_last_xact_replay_timestamp() AS replication_delay; that need to be ran into a slave.. how can I insert that data into a table on the slave? you would insert that data into a table on the MASTER,

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-30 Thread Patrick B
2016-12-01 5:54 GMT+13:00 Melvin Davidson : > > On Wed, Nov 30, 2016 at 8:04 AM, Cachique wrote: > >> You can try pg_cron. >> https://github.com/citusdata/pg_cron >> "pg_cron is a simple cron-based job scheduler for PostgreSQL (9.5 or >> higher) that runs inside the database as an extension. It u

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-30 Thread Melvin Davidson
On Wed, Nov 30, 2016 at 8:04 AM, Cachique wrote: > You can try pg_cron. > https://github.com/citusdata/pg_cron > "pg_cron is a simple cron-based job scheduler for PostgreSQL (9.5 or > higher) that runs inside the database as an extension. It uses the same > syntax as regular cron, but it allows y

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-30 Thread Cachique
You can try pg_cron. https://github.com/citusdata/pg_cron "pg_cron is a simple cron-based job scheduler for PostgreSQL (9.5 or higher) that runs inside the database as an extension. It uses the same syntax as regular cron, but it allows you to schedule PostgreSQL commands directly from the database

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread John R Pierce
On 11/29/2016 6:01 PM, Melvin Davidson wrote: There is no reason you can't execute a cron job on production to a remote db. eg: contents of cron */5 * * * * psql -U postgres -h 123.4.56.789 -d remote_db_name -f /path_to/exec.sql ... The OP wants to run queries on the master and the s

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread Melvin Davidson
On Tue, Nov 29, 2016 at 8:55 PM, John R Pierce wrote: > On 11/29/2016 5:40 PM, Patrick B wrote: > >> >> >> Can't I do it on the DB size? Using a trigger maybe? instead of using >> Cron? >> > > triggers are only called on database events like insert, update, select. > even something like the pgag

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread John R Pierce
On 11/29/2016 5:40 PM, Patrick B wrote: Can't I do it on the DB size? Using a trigger maybe? instead of using Cron? triggers are only called on database events like insert, update, select. even something like the pgagent scheduler thats frequently bundled with pgadmin uses cron to run it

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread Patrick B
2016-11-30 14:21 GMT+13:00 John R Pierce : > On 11/29/2016 5:10 PM, Patrick B wrote: > > > Yep.. once a minute or so. And yes, I need to store a history with > timestamp. > > Any idea? :) > > > so create a table with a timestamptz, plus all the fields you want, have a > script (perl? python? wha

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread John R Pierce
On 11/29/2016 5:10 PM, Patrick B wrote: Yep.. once a minute or so. And yes, I need to store a history with timestamp. Any idea? :) so create a table with a timestamptz, plus all the fields you want, have a script (perl? python? whatever your favorite poison is with database access) that

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread Patrick B
2016-11-30 14:02 GMT+13:00 John R Pierce : > On 11/29/2016 3:31 PM, Patrick B wrote: > > I use these queries to monitor the streaming replication: > > *on master:* > select client_addr, state, sent_location, write_location, flush_location, > replay_location, sync_priority from pg_stat_replication;

Re: [GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread John R Pierce
On 11/29/2016 3:31 PM, Patrick B wrote: I use these queries to monitor the streaming replication: *on master:* select client_addr, state, sent_location, write_location, flush_location, replay_location, sync_priority from pg_stat_replication; *On slave:* select now() - pg_last_xact_replay_time

[GENERAL] Monitoring Replication - Postgres 9.2

2016-11-29 Thread Patrick B
Hi guys, I use these queries to monitor the streaming replication: *on master:* select client_addr, state, sent_location, write_location, flush_location, replay_location, sync_priority from pg_stat_replication; *On slave:* select now() - pg_last_xact_replay_timestamp() AS replication_delay; Can