Skip to content

Instantly share code, notes, and snippets.

@azet azet/chk_pgsql
Last active Mar 25, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.