Skip to content

Instantly share code, notes, and snippets.

@azet
Last active March 25, 2019 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azet/68201ff87820f1b2f4dc4f8316c5008a to your computer and use it in GitHub Desktop.
Save azet/68201ff87820f1b2f4dc4f8316c5008a to your computer and use it in GitHub Desktop.
keepalived 'track_script' for PostgreSQL 'bgw_replstatus' Plugin
#!/usr/bin/env python
#
# keepalived 'track_script' for PostgreSQL 'bgw_replstatus' Plugin
#
# Author: Aaron Zauner <azet@azet.org>
# License: CC0 1.0 Public Domain (https://creativecommons.org/publicdomain/zero/1.0/)
#
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 5400))
data = s.recv(8)
if data == "MASTER":
exit(0)
else:
exit(1)
! Configuration File for keepalived
global_defs {
! notification_email {
! InfraTeam@corp.tld
! }
! notification_email_from pgsql-cluster@corp.tld
! smtp_server ...
! smtp_connect_timeout 30
router_id PGSQL_CLUSTER
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_script chk_pgsql {
script "/usr/local/sbin/chk_pgsql"
interval 2
}
vrrp_instance VI_1 {
state MASTER
interface eth1
virtual_router_id 1
priority 10
advert_int 1
authentication {
auth_type AH
auth_pass 435345984393
}
track_script {
chk_pgsql
}
virtual_ipaddress {
192.168.100.10/24 dev eth0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment