sensu-plugins-postgres 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81d24e9ab393e0ef90085644a3edb9d44cb67c3675bb43c8c4554bc7e9446c23
4
- data.tar.gz: 6d923e1508cbb8dc14f364d9e3bf8b5953ae2e2853d015734f61b15e368d70c5
3
+ metadata.gz: 43c426179d0828ff7ef0de6e2a201735baaca16d742747313360ad7bcd5faa70
4
+ data.tar.gz: 88cdc1e4577cf7d50f1a6feb026b376a58734afb4488df9b63408a5830d9ad1c
5
5
  SHA512:
6
- metadata.gz: 8fc5073d3a9161abaf35b6b2f80fe53848f08f28fa6743d3740db6ba8c4a33cbe0bd97d2f2bed39ef07dae69e121b0185d969544086de53acabe631cd2aa4bdd
7
- data.tar.gz: ba0ec9b5ed4c3b0a91e4aa11794985269ce7c82eda72b95c4781dba813fa7db5665312a3f6f8f82dd16ef12a0a89e4501a3ba6d6428031ee274e651667a3e84d
6
+ metadata.gz: f0f6523e426f54432345905d36e5a4f4e386066683bb2f9e34f209249adf96412bae11cd311c948e044261d0a16c7451e9a5f05032b386f738223939bae02112
7
+ data.tar.gz: d8262bba5ca7c0eaf358be481f279e4e87c518e2c86f8b5c62b922fe03c6ba0cb408bdffcc1600c97e9dea1e36576b9f2fefe930d16f81fb6102b4d250b3f5e8
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.3.2] - 2019-03-12
9
+ ### Fixed
10
+ - Support for PostgreSQL v10+ replication function names fixed in `bin/metric-postgres-graphite.rb` (@jfineberg)
11
+
8
12
  ## [2.3.1] - 2018-12-16
9
13
  ### Fixed
10
14
  - metric-postgres-statsdb.rb: Change `Array` method from `append` to `push` to maintain compatibility w/ non-EOL Rubies (@phumpal)
@@ -36,7 +40,7 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
36
40
 
37
41
  ## [1.4.6] - 2018-05-03
38
42
  ### Fixed
39
- - version number check for build strings such as `10.3 (Ubuntu 10.3-1.pgdg16.04+1)`
43
+ - version number check for build strings such as `10.3 (Ubuntu 10.3-1.pgdg16.04+1)` (@jfineberg)
40
44
 
41
45
  ### Added
42
46
  - tests for connecting with a pgpass file (@majormoses)
@@ -174,7 +178,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
174
178
  ### Added
175
179
  - initial release
176
180
 
177
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.1...HEAD
181
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.2...HEAD
182
+ [2.3.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.1...2.3.2
178
183
  [2.3.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.0...2.3.1
179
184
  [2.3.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.2...2.3.0
180
185
  [2.2.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.1...2.2.2
@@ -27,8 +27,9 @@
27
27
  #
28
28
 
29
29
  require 'sensu-plugins-postgres/pgpass'
30
- require 'pg'
30
+ require 'sensu-plugins-postgres/pgutil'
31
31
  require 'sensu-plugin/metric/cli'
32
+ require 'pg'
32
33
  require 'socket'
33
34
 
34
35
  class CheckpostgresReplicationStatus < Sensu::Plugin::Metric::CLI::Graphite
@@ -64,6 +65,12 @@ class CheckpostgresReplicationStatus < Sensu::Plugin::Metric::CLI::Graphite
64
65
  long: '--password=VALUE',
65
66
  description: 'Database password'
66
67
 
68
+ option :ssl,
69
+ short: '-S',
70
+ long: '--ssl',
71
+ boolean: true,
72
+ description: 'Require SSL'
73
+
67
74
  option :scheme,
68
75
  description: 'Metric naming scheme, text to prepend to metric',
69
76
  short: '-g SCHEME',
@@ -82,8 +89,11 @@ class CheckpostgresReplicationStatus < Sensu::Plugin::Metric::CLI::Graphite
82
89
  default: nil
83
90
 
84
91
  include Pgpass
92
+ include PgUtil
85
93
 
86
94
  def run
95
+ ssl_mode = config[:ssl] ? 'require' : 'prefer'
96
+
87
97
  # Establishing connections to the master
88
98
  pgpass
89
99
  conn_master = PG.connect(host: config[:master_host],
@@ -91,29 +101,35 @@ class CheckpostgresReplicationStatus < Sensu::Plugin::Metric::CLI::Graphite
91
101
  user: config[:user],
92
102
  password: config[:password],
93
103
  port: config[:port],
104
+ sslmode: ssl_mode,
94
105
  connect_timeout: config[:timeout])
95
- res1 = conn_master.exec('SELECT pg_current_xlog_location()').getvalue(0, 0)
106
+
107
+ master = if check_vsn_newer_than_postgres9(conn_master)
108
+ conn_master.exec('SELECT pg_current_xlog_location()').getvalue(0, 0)
109
+ else
110
+ conn_master.exec('SELECT pg_current_wal_lsn()').getvalue(0, 0)
111
+ end
96
112
  m_segbytes = conn_master.exec('SHOW wal_segment_size').getvalue(0, 0).sub(/\D+/, '').to_i << 20
97
113
  conn_master.close
98
114
 
99
- def lag_compute(res1, res, m_segbytes) # rubocop:disable NestedMethodDefinition
100
- m_segment, m_offset = res1.split(/\//)
101
- s_segment, s_offset = res.split(/\//)
102
- ((m_segment.hex - s_segment.hex) * m_segbytes) + (m_offset.hex - s_offset.hex)
103
- end
104
-
105
115
  # Establishing connections to the slave
106
116
  conn_slave = PG.connect(host: config[:slave_host],
107
117
  dbname: config[:database],
108
118
  user: config[:user],
109
119
  password: config[:password],
110
120
  port: config[:port],
121
+ sslmode: ssl_mode,
111
122
  connect_timeout: config[:timeout])
112
- res = conn_slave.exec('SELECT pg_last_xlog_receive_location()').getvalue(0, 0)
123
+
124
+ slave = if check_vsn_newer_than_postgres9(conn_slave)
125
+ conn_slave.exec('SELECT pg_last_xlog_receive_location()').getvalue(0, 0)
126
+ else
127
+ conn_slave.exec('SELECT pg_last_wal_replay_lsn()').getvalue(0, 0)
128
+ end
113
129
  conn_slave.close
114
130
 
115
131
  # Compute lag
116
- lag = lag_compute(res1, res, m_segbytes)
132
+ lag = compute_lag(master, slave, m_segbytes)
117
133
  output config[:scheme].to_s, lag
118
134
 
119
135
  ok
@@ -2,7 +2,7 @@ module SensuPluginsPostgres
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 3
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-17 00:00:00.000000000 Z
11
+ date: 2019-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.4'
75
+ version: '1.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.4'
82
+ version: '1.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: github-markup
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.3'
89
+ version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.3'
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: kitchen-docker
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -162,14 +162,14 @@ dependencies:
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '10.0'
165
+ version: '12.3'
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '10.0'
172
+ version: '12.3'
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: redcarpet
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -324,8 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  - !ruby/object:Gem::Version
325
325
  version: '0'
326
326
  requirements: []
327
- rubyforge_project:
328
- rubygems_version: 2.7.8
327
+ rubygems_version: 3.0.3
329
328
  signing_key:
330
329
  specification_version: 4
331
330
  summary: Sensu plugins for postgres