Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bryder/575e02cdc6c31c3a6d1a to your computer and use it in GitHub Desktop.
Save bryder/575e02cdc6c31c3a6d1a to your computer and use it in GitHub Desktop.
On the slave (python string)
"select pg_last_xlog_receive_location(), pg_last_xlog_replay_location(), "
"EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) AS seconds_since_last_replay, "
"pg_xlog_location_diff(pg_last_xlog_receive_location(), pg_last_xlog_replay_location()) "
"AS replay_receive_xlog_pos_delta;
On the master
use pg_xlog_location_diff with the extracted positions from the slave to do something similar
"select pg_current_xlog_location(), "
"pg_xlog_location_diff(pg_current_xlog_location(), '%s') AS slave_receive_xlog_pos_delta,"
"pg_xlog_location_diff(pg_current_xlog_location(), '%s') AS slave_replay_xlog_pos_delta;" %
( raw_data['slave']['pg_last_xlog_receive_location'],
raw_data['slave']['pg_last_xlog_replay_location'],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment