sensu-plugins-postgres 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a45e79a870e70728d2a99dbc9798c077063070acb1650a0ff6324bd0c6e994f9
4
- data.tar.gz: 936bc662f06d4b821685e69a75cce0151cb45adbe355bb68e1ba01c8701e007c
3
+ metadata.gz: 3b8b321bd7b58507b107ad5537be23e4772af0c816ccb8671ab54ae17260823e
4
+ data.tar.gz: 84650ac794e8dfcdc2bfd30af486004d1b43965ae16eb7fa615630e853d27694
5
5
  SHA512:
6
- metadata.gz: 4ec5e5aeaf904d024ebeb7c3c5e259d3e8d48c78a0a575f25c3c729e5c23c8e90377178e7094f84a2b947b524f3d26a6092dc5c92e9fe648c8ad8aada38d0141
7
- data.tar.gz: cc8a86ead4f002306b6521a439e2242a59e7d3c2249b014cb940f48a7669302a91a68e2efea69934a108843570186fe482316c194ac0cdf666815d9a70394e92
6
+ metadata.gz: 21b7c966145dc4e5fa92f49ec303d7219cc1ea9578d5f790bdc7ee564e96cd7bcc3574ccffe9ad5044f35685f180b28f6bb27b9fe555ce01948a8e3a5d69071c
7
+ data.tar.gz: 82bbe1c1df6c9a8c964f5fa09dfeb9998c09cf2890e97133b6183c101c9c0f899f551dd01faf6b3b80e9513273c98b3f993ac6f3771787d277444a85f763f8e6
data/CHANGELOG.md CHANGED
@@ -5,9 +5,13 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.1.0] - 2018-10-16
9
+ ### Added
10
+ - Moves check_vsn and compute_lag to library method (@phumpal)
11
+
8
12
  ## [2.0.0] - 2018-10-15
9
13
  ### Breaking Changes
10
- - Remove unsupported Rubies: `< 2.3.0`
14
+ - Remove unsupported Rubies: `< 2.3.0` (@phumpal)
11
15
 
12
16
  ## [1.4.6] - 2018-05-03
13
17
  ### Fixed
@@ -149,7 +153,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
149
153
  ### Added
150
154
  - initial release
151
155
 
152
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.0.0...HEAD
156
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.1.0...HEAD
157
+ [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.0.0...2.1.0
153
158
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.6...2.0.0
154
159
  [1.4.6]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.5...1.4.6
155
160
  [1.4.5]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.4...1.4.5
@@ -27,6 +27,7 @@
27
27
  #
28
28
 
29
29
  require 'sensu-plugins-postgres/pgpass'
30
+ require 'sensu-plugins-postgres/pgutil'
30
31
  require 'sensu-plugin/check/cli'
31
32
  require 'pg'
32
33
 
@@ -97,18 +98,7 @@ class CheckPostgresReplicationStatus < Sensu::Plugin::Check::CLI
97
98
  description: 'Connection timeout (seconds)')
98
99
 
99
100
  include Pgpass
100
-
101
- def compute_lag(master, slave, m_segbytes)
102
- m_segment, m_offset = master.split('/')
103
- s_segment, s_offset = slave.split('/')
104
- ((m_segment.hex - s_segment.hex) * m_segbytes) + (m_offset.hex - s_offset.hex)
105
- end
106
-
107
- def check_vsn(conn)
108
- pg_vsn = conn.exec("SELECT current_setting('server_version')").getvalue(0, 0)
109
- pg_vsn = pg_vsn.split(' ')[0]
110
- Gem::Version.new(pg_vsn) < Gem::Version.new('10.0') && Gem::Version.new(pg_vsn) >= Gem::Version.new('9.0')
111
- end
101
+ include PgUtil
112
102
 
113
103
  def run
114
104
  ssl_mode = config[:ssl] ? 'require' : 'prefer'
@@ -123,7 +113,7 @@ class CheckPostgresReplicationStatus < Sensu::Plugin::Check::CLI
123
113
  sslmode: ssl_mode,
124
114
  connect_timeout: config[:timeout])
125
115
 
126
- master = if check_vsn(conn_master)
116
+ master = if check_vsn_newer_than_postgres9(conn_master)
127
117
  conn_master.exec('SELECT pg_current_xlog_location()').getvalue(0, 0)
128
118
  else
129
119
  conn_master.exec('SELECT pg_current_wal_lsn()').getvalue(0, 0)
@@ -140,7 +130,7 @@ class CheckPostgresReplicationStatus < Sensu::Plugin::Check::CLI
140
130
  sslmode: ssl_mode,
141
131
  connect_timeout: config[:timeout])
142
132
 
143
- slave = if check_vsn(conn_slave)
133
+ slave = if check_vsn_newer_than_postgres9(conn_slave)
144
134
  conn_slave.exec('SELECT pg_last_xlog_receive_location()').getvalue(0, 0)
145
135
  else
146
136
  conn_slave.exec('SELECT pg_last_wal_replay_lsn()').getvalue(0, 0)
@@ -0,0 +1,13 @@
1
+ module PgUtil
2
+ def check_vsn_newer_than_postgres9(conn)
3
+ pg_vsn = conn.exec("SELECT current_setting('server_version')").getvalue(0, 0)
4
+ pg_vsn = pg_vsn.split(' ')[0]
5
+ Gem::Version.new(pg_vsn) < Gem::Version.new('10.0') && Gem::Version.new(pg_vsn) >= Gem::Version.new('9.0')
6
+ end
7
+
8
+ def compute_lag(master, slave, m_segbytes)
9
+ m_segment, m_offset = master.split('/')
10
+ s_segment, s_offset = slave.split('/')
11
+ ((m_segment.hex - s_segment.hex) * m_segbytes) + (m_offset.hex - s_offset.hex)
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsPostgres
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
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.0.0
4
+ version: 2.1.0
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-10-16 00:00:00.000000000 Z
11
+ date: 2018-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -297,6 +297,7 @@ files:
297
297
  - bin/metrics-postgres-query.rb
298
298
  - lib/sensu-plugins-postgres.rb
299
299
  - lib/sensu-plugins-postgres/pgpass.rb
300
+ - lib/sensu-plugins-postgres/pgutil.rb
300
301
  - lib/sensu-plugins-postgres/version.rb
301
302
  homepage: https://github.com/sensu-plugins/sensu-plugins-postgres
302
303
  licenses: