Skip to content

Commit db58879

Browse files
phumpalmajormoses
authored andcommitted
Replication check should fail if master and slave are the same.
Master and slave are required parameters.
1 parent e3ae488 commit db58879

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md).
55

66
## [Unreleased]
7+
- check-postgres-replication.rb - critical if slave is undefined, localhost or master and slave are same
78

89
### Fixed
910
- check-postgres-replication.rb: fix condition where connection timeout is considered a boolean rather than an integer value (@majormoses) (@phumpal) (@VeselaHouba)

bin/check-postgres-replication.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ class CheckPostgresReplicationStatus < Sensu::Plugin::Check::CLI
4343
option(:master_host,
4444
short: '-m',
4545
long: '--master-host=HOST',
46+
required: true,
4647
description: 'PostgreSQL master HOST')
4748

4849
option(:slave_host,
4950
short: '-s',
5051
long: '--slave-host=HOST',
51-
description: 'PostgreSQL slave HOST',
52-
default: 'localhost')
52+
required: true,
53+
description: 'PostgreSQL slave HOST')
5354

5455
option(:port,
5556
short: '-P',
@@ -106,6 +107,8 @@ class CheckPostgresReplicationStatus < Sensu::Plugin::Check::CLI
106107
def run
107108
ssl_mode = config[:ssl] ? 'require' : 'prefer'
108109

110+
critical 'Master and slave cannot be the same host' if config[:master_host] == config[:slave_host]
111+
109112
# Establishing connection to the master
110113
pgpass
111114
conn_master = PG.connect(host: config[:master_host],

0 commit comments

Comments
 (0)