Skip to content

Commit dfbb670

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/asset-enablement
2 parents 6c97714 + fbc7833 commit dfbb670

File tree

5 files changed

+38
-15
lines changed

5 files changed

+38
-15
lines changed

CHANGELOG.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@ 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-
### Changes
8-
- Updated development dependency to bundler ~> 2.1
9-
- Updated development dependency to rake ~> 13.0
10-
- Updated development dependency to test-kitchen ~> 1.25.0
11-
- Updated runtime dependency to 'pg' '1.2.1' from 1.1
12-
- Updated runtime dependency 'dentaku' '3.3.4' from 2.04
7+
8+
## [4.0.0] - 2020-01-09
139

1410
### Breaking Changes
1511
- Update `sensu-plugin` dependency from `~> 1.2` to `~> 4.0` you can read the changelog entries for [4.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#400---2018-02-17), [3.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#300---2018-12-04), and [2.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29)
12+
- `check-postgres-replication.rb`: both `--slave-host` and `master-host` arguments are now required flags where previously they had localhost defaults (@phumpal)
13+
14+
### Fixed
15+
- `check-postgres-replication.rb`: fix condition where connection timeout is considered a boolean rather than an integer value (@majormoses) (@phumpal) (@VeselaHouba)
16+
- `check-postgres-replication.rb`: critical if the master and slave are same (@phumpal)
17+
18+
### Added
19+
- `check-postgres-query.rb`: Add `-r`, `--regex-pattern` to match query result against (@jindraj)
20+
21+
### Changes
22+
- Updated development dependency to bundler ~> 2.1
23+
- Updated development dependency to rake ~> 13.0
24+
- Updated development dependency to test-kitchen ~> 1.25.0
25+
- Updated runtime dependency to 'pg' '1.2.1' from 1.1
26+
- Updated runtime dependency 'dentaku' '3.3.4' from 2.04
1627

1728
## [3.0.0] - 2019-11-20
1829
### Breaking Changes
@@ -195,7 +206,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
195206
### Added
196207
- initial release
197208

198-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/3.0.0...HEAD
209+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.0.0...HEAD
210+
[4.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/3.0.0...4.0.0
199211
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.4.0...3.0.0
200212
[2.4.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.2...2.4.0
201213
[2.3.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.1...2.3.2

bin/check-postgres-query.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class CheckPostgresQuery < Sensu::Plugin::Check::CLI
7575
long: '--query QUERY',
7676
required: true
7777

78+
option :regex_pattern,
79+
description: 'Regex pattern to match on query results and alert on if it does not match',
80+
short: '-r REGEX',
81+
long: '--regex-pattern REGEX'
82+
7883
option :check_tuples,
7984
description: 'Check against the number of tuples (rows) returned by the query',
8085
short: '-t',
@@ -127,6 +132,8 @@ def run
127132
critical "Results: #{res.values}"
128133
elsif config[:warning] && calc.evaluate(config[:warning], value: value)
129134
warning "Results: #{res.values}"
135+
elsif config[:regex_pattern] && (res.getvalue(0, 0) !~ /#{config[:regex_pattern]}/)
136+
critical "Query result #{res.getvalue(0, 0)} doesn't match configured regex #{config[:regex_pattern]}"
130137
else
131138
ok 'Query OK'
132139
end

bin/check-postgres-replication.rb

Lines changed: 10 additions & 6 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',
@@ -94,17 +95,20 @@ class CheckPostgresReplicationStatus < Sensu::Plugin::Check::CLI
9495
proc: lambda { |s| s.to_i }) # rubocop:disable Lambda
9596

9697
option(:timeout,
97-
short: '-T',
98-
long: '--timeout',
99-
default: nil,
100-
description: 'Connection timeout (seconds)')
98+
short: '-T TIMEOUT',
99+
long: '--timeout=TIMEOUT',
100+
default: 2,
101+
description: 'Connection timeout (seconds)',
102+
proc: proc(&:to_i))
101103

102104
include Pgpass
103105
include PgUtil
104106

105107
def run
106108
ssl_mode = config[:ssl] ? 'require' : 'prefer'
107109

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

lib/sensu-plugins-postgres/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module SensuPluginsPostgres
44
module Version
5-
MAJOR = 3
5+
MAJOR = 4
66
MINOR = 0
77
PATCH = 0
88

sensu-plugins-postgres.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
3939
s.add_runtime_dependency 'sensu-plugin', '~> 4.0'
4040

4141
s.add_runtime_dependency 'dentaku', '3.3.4'
42-
s.add_runtime_dependency 'pg', '1.2.1'
42+
s.add_runtime_dependency 'pg', '1.2.2'
4343

4444
s.add_development_dependency 'bundler', '~> 2.1'
4545
s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'

0 commit comments

Comments
 (0)