sensu-plugins-postgres-mrtrotl 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +277 -0
- data/LICENSE +22 -0
- data/README.md +125 -0
- data/bin/check-postgres-alive.rb +94 -0
- data/bin/check-postgres-connections.rb +142 -0
- data/bin/check-postgres-query.rb +142 -0
- data/bin/check-postgres-replication.rb +160 -0
- data/bin/metric-postgres-connections.rb +130 -0
- data/bin/metric-postgres-dbsize.rb +105 -0
- data/bin/metric-postgres-graphite.rb +140 -0
- data/bin/metric-postgres-locks.rb +114 -0
- data/bin/metric-postgres-relation-size.rb +119 -0
- data/bin/metric-postgres-statsbgwriter.rb +113 -0
- data/bin/metric-postgres-statsdb.rb +124 -0
- data/bin/metric-postgres-statsio.rb +122 -0
- data/bin/metric-postgres-statstable.rb +124 -0
- data/bin/metric-postgres-vaccum.rb +125 -0
- data/bin/metrics-postgres-query.rb +132 -0
- data/lib/sensu-plugins-postgres/pgpass.rb +27 -0
- data/lib/sensu-plugins-postgres/pgutil.rb +15 -0
- data/lib/sensu-plugins-postgres/version.rb +11 -0
- data/lib/sensu-plugins-postgres.rb +4 -0
- metadata +330 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b36a9f6c8350c240b747e19e5107550b6782a8db
|
4
|
+
data.tar.gz: fae743abe1278399494df6403584d5da8e496ace
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9da5a7f7ae02d98482e312d44b24340abc0cbc0fa6ee86bf874e08604113f14be46cdf955ae808a0e43cffc5ab68f3c6990890b048b39ec27b68a8486cf25a99
|
7
|
+
data.tar.gz: df7b32f6212e6fc56ba73655f91f4949b88bdc1e1efbd7ba6b419241f7e31247d08474195d892b4c5a09740cdd67ee29f1ea8ad18c9acc21bee30cf41338a14a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
# Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md).
|
5
|
+
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
### Breaking Changes
|
9
|
+
- Updated asset builds to use ruby26-runtime
|
10
|
+
- Update asset builds to use libpg v12, to ensue compatibility with SCRAM password authentication introduced in postgresl 10
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- Standardize on 10 second integer for timeout option to ensure working defaults with libpg. Newer libpg libraries don't like the nil default, treats it as a string and errors out.
|
14
|
+
|
15
|
+
## [4.3.0] - 2021-09-15
|
16
|
+
|
17
|
+
### Added
|
18
|
+
- asset for generic debian build (including ubuntu) (@VeselaHouba)
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- Fixing asset build directive for centos6, using package repository archive now that centos6 is EOL
|
22
|
+
|
23
|
+
## [4.2.0] - 2020-11-29
|
24
|
+
### Added
|
25
|
+
- new `bin/metric-postgres-relation-size.rb` find largest tables (@phumpal)
|
26
|
+
|
27
|
+
## [4.1.0] - 2020-06-04
|
28
|
+
### Added
|
29
|
+
- new `metric-postgres-vaccum.rb` metric gathering script for postgres vacuum process (@phumpal)
|
30
|
+
|
31
|
+
## [4.0.2] - 2020-06-02
|
32
|
+
- Fixed `# frozen_string_literal: true` does not play nicely with mixlib-cli.
|
33
|
+
|
34
|
+
## [4.0.1] - 2020-04-20
|
35
|
+
### Fixed
|
36
|
+
- Fixing asset build directives.
|
37
|
+
|
38
|
+
## [4.0.0] - 2020-01-09
|
39
|
+
|
40
|
+
### Breaking Changes
|
41
|
+
- 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)
|
42
|
+
- `check-postgres-replication.rb`: both `--slave-host` and `master-host` arguments are now required flags where previously they had localhost defaults (@phumpal)
|
43
|
+
|
44
|
+
### Fixed
|
45
|
+
- `check-postgres-replication.rb`: fix condition where connection timeout is considered a boolean rather than an integer value (@majormoses) (@phumpal) (@VeselaHouba)
|
46
|
+
- `check-postgres-replication.rb`: critical if the master and slave are same (@phumpal)
|
47
|
+
|
48
|
+
### Added
|
49
|
+
- `check-postgres-query.rb`: Add `-r`, `--regex-pattern` to match query result against (@jindraj)
|
50
|
+
|
51
|
+
### Changes
|
52
|
+
- Updated development dependency to bundler ~> 2.1
|
53
|
+
- Updated development dependency to rake ~> 13.0
|
54
|
+
- Updated development dependency to test-kitchen ~> 1.25.0
|
55
|
+
- Updated runtime dependency to 'pg' '1.2.1' from 1.1
|
56
|
+
- Updated runtime dependency 'dentaku' '3.3.4' from 2.04
|
57
|
+
|
58
|
+
## [3.0.0] - 2019-11-20
|
59
|
+
### Breaking Changes
|
60
|
+
- Removed ruby < 2.4 since these Rubies are EOL (@phumpal)
|
61
|
+
|
62
|
+
## [2.4.0] - 2019-10-04
|
63
|
+
### Added
|
64
|
+
- Support comments in pgpass file. Keeps previous behavior and adds support for ignoring leading comments (@phumpal)
|
65
|
+
|
66
|
+
## [2.3.2] - 2019-03-12
|
67
|
+
### Fixed
|
68
|
+
- Support for PostgreSQL v10+ replication function names fixed in `bin/metric-postgres-graphite.rb` (@jfineberg)
|
69
|
+
|
70
|
+
## [2.3.1] - 2018-12-16
|
71
|
+
### Fixed
|
72
|
+
- metric-postgres-statsdb.rb: Change `Array` method from `append` to `push` to maintain compatibility w/ non-EOL Rubies (@phumpal)
|
73
|
+
|
74
|
+
## [2.3.0] - 2018-12-08
|
75
|
+
### Added
|
76
|
+
- metric-postgres-statsdb.rb: Add --all-databases option. (@cyrilgdn)
|
77
|
+
|
78
|
+
## [2.2.2] - 2018-10-27
|
79
|
+
### Fixed
|
80
|
+
- Remove unexplicit dependency on ActiveSupport (@multani)
|
81
|
+
|
82
|
+
## [2.2.1] - 2018-10-16
|
83
|
+
### Security
|
84
|
+
- updated yard dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 (@majormoses)
|
85
|
+
|
86
|
+
## [2.2.0] - 2018-10-16
|
87
|
+
### Added
|
88
|
+
- metric-postgres-statsbgwriter.rb: additional metrics (@phumpal)
|
89
|
+
- metric-postgres-statsdb.rb additional metrics (@phumpal)
|
90
|
+
|
91
|
+
## [2.1.0] - 2018-10-16
|
92
|
+
### Added
|
93
|
+
- Moves check_vsn and compute_lag to library method (@phumpal)
|
94
|
+
|
95
|
+
## [2.0.0] - 2018-10-15
|
96
|
+
### Breaking Changes
|
97
|
+
- Remove unsupported Rubies: `< 2.3.0` (@phumpal)
|
98
|
+
|
99
|
+
## [1.4.6] - 2018-05-03
|
100
|
+
### Fixed
|
101
|
+
- version number check for build strings such as `10.3 (Ubuntu 10.3-1.pgdg16.04+1)` (@jfineberg)
|
102
|
+
|
103
|
+
### Added
|
104
|
+
- tests for connecting with a pgpass file (@majormoses)
|
105
|
+
|
106
|
+
## [1.4.5] - 2018-02-15
|
107
|
+
### Fixed
|
108
|
+
- metric-postgres-graphite.rb: use the custom defined port when connecting to slave (@henkjan)
|
109
|
+
|
110
|
+
### Added
|
111
|
+
- basic skel for integration testing with postgres (@majormoses)
|
112
|
+
- added test for `./bin/check-postgres-alive.rb`
|
113
|
+
|
114
|
+
## [1.4.4] - 2017-11-08
|
115
|
+
### Fixed
|
116
|
+
- check-postgres-replication.rb: fix 9.x compatibility
|
117
|
+
|
118
|
+
## [1.4.3] - 2017-11-06
|
119
|
+
### Fixed
|
120
|
+
- check-postgres-replication.rb: maintains backwards compatibility with <= 9.6 and adds compatibility for >= 10
|
121
|
+
|
122
|
+
## [1.4.2] - 2017-09-27
|
123
|
+
### Fixed
|
124
|
+
- metric-postgres-locks.rb: Fix lock count collection (@madboxkr)
|
125
|
+
|
126
|
+
## [1.4.1] - 2017-09-26
|
127
|
+
### Fixed
|
128
|
+
- metrics-postgres-query.rb: Add a nil check to avoid failure when the query result is empty (@eheydrick)
|
129
|
+
- PR template spelling (@majormoses)
|
130
|
+
|
131
|
+
### Changed
|
132
|
+
- updated CHANGELOG guidelines location (@majormoses)
|
133
|
+
|
134
|
+
## [1.4.0] - 2017-08-04
|
135
|
+
### Added
|
136
|
+
- all checks now support using the pgpass file and is backwards compatible with the previous versions (@ahes)
|
137
|
+
|
138
|
+
## [1.3.0] - 2017-07-25
|
139
|
+
### Fixed
|
140
|
+
- Take into account reserved superuser connections in check-postgres-connections.rb (@Evesy)
|
141
|
+
|
142
|
+
### Added
|
143
|
+
- Ruby 2.4.1 testing
|
144
|
+
|
145
|
+
## [1.2.0] - 2017-07-12
|
146
|
+
### Added
|
147
|
+
- metric-postgres-statsdb.rb: Adds new metric `numbackends`. (@phumpal)
|
148
|
+
|
149
|
+
## [1.1.2] - 2017-06-02
|
150
|
+
### Fixed
|
151
|
+
- check-postgresq-replication.rb: Adds missing option for custom port.
|
152
|
+
|
153
|
+
## [1.1.1] - 2017-04-24
|
154
|
+
### Fixed
|
155
|
+
- metrics-postgres-query.rb: Restored default value to only return first value in query. (@Micasou)
|
156
|
+
|
157
|
+
## [1.1.0] - 2017-04-20
|
158
|
+
### Added
|
159
|
+
- metrics-postgres-query.rb: Add option to return multi row queries. (@Micasou)
|
160
|
+
|
161
|
+
### Fixed
|
162
|
+
- check-postgres-alive.rb: Fix connections using a custom port (#25 via @mickfeech)
|
163
|
+
- check-postgres-connections.rb: Fix connections using a custom port (#25)
|
164
|
+
- check-postgres-query.rb: Fix connections using a custom port (#25)
|
165
|
+
- check-postgres-replication.rb: Fix connections using a custom port (#25)
|
166
|
+
- metrics-postgres-connections.rb: Fix connections using a custom port (#25)
|
167
|
+
- metrics-postgres-dbsize.rb: Fix connections using a custom port (#25)
|
168
|
+
- metrics-postgres-graphite.rb: Fix connections using a custom port (#25)
|
169
|
+
- metrics-postgres-graphite.rb: Fix connections using password (@teadur)
|
170
|
+
- metrics-postgres-locks.rb: Fix connections using a custom port (#25)
|
171
|
+
- metrics-postgres-statsgbwriter.rb: Fix connections using a custom port (#25)
|
172
|
+
- metrics-postgres-statsdb.rb: Fix connections using a custom port (#25)
|
173
|
+
- metrics-postgres-statsio.rb: Fix connections using a custom port (#25)
|
174
|
+
- metrics-postgres-statstable.rb: Fix connections using a custom port (#25)
|
175
|
+
- metrics-postgres-query.rb: Fix connections using a custom port (#25)
|
176
|
+
- check-postgres-connections.rb: Fix logic to check critical first then warning (#24 via @nevins-b)
|
177
|
+
|
178
|
+
## [1.0.1] - 2017-01-04
|
179
|
+
### Fixed
|
180
|
+
- metrics-postgres-query.rb: Fix `count_tuples` option (#23) (@eheydrick)
|
181
|
+
|
182
|
+
## [1.0.0] - 2016-12-27
|
183
|
+
### Fixed
|
184
|
+
- metric-postgres-connections: Handle postgres version 9.6 and above.
|
185
|
+
|
186
|
+
### Removed
|
187
|
+
- Ruby 1.9.3 and 2.0.0 support
|
188
|
+
|
189
|
+
### Added
|
190
|
+
- Ruby 2.3.0 support
|
191
|
+
- Update all the scripts to add an optional timeout setting.
|
192
|
+
|
193
|
+
## [0.1.1] - 2016-03-24
|
194
|
+
### Added
|
195
|
+
- metric-postgres-connections: Add new metric `total`
|
196
|
+
|
197
|
+
### Fixed
|
198
|
+
- metric-postgres-connections: Correctly evaluate and collect metrics for active connections and active connections waiting on backend locks
|
199
|
+
|
200
|
+
## [0.1.0] - 2016-03-09
|
201
|
+
### Added
|
202
|
+
- Add new plugin `check-postgres-connections` that checks the number of connections to a DB
|
203
|
+
|
204
|
+
## [0.0.7] - 2015-12-10
|
205
|
+
### Changed
|
206
|
+
- fixed [ -S | -ssl ] short option
|
207
|
+
|
208
|
+
## [0.0.6] - 2015-10-08
|
209
|
+
### Changed
|
210
|
+
- standardized headers
|
211
|
+
|
212
|
+
### Added
|
213
|
+
- added plugins for querying postgres
|
214
|
+
|
215
|
+
## [0.0.5] - 2015-10-06
|
216
|
+
### Changed
|
217
|
+
- updated pg gem to 0.18.3
|
218
|
+
- Added port cli option to postgres-graphite.rb.
|
219
|
+
|
220
|
+
## [0.0.4] - 2015-08-04
|
221
|
+
### Changed
|
222
|
+
- general cleanup, no code changes
|
223
|
+
|
224
|
+
## [0.0.3] - 2015-07-14
|
225
|
+
### Changed
|
226
|
+
- updated sensu-plugin gem to 1.2.0
|
227
|
+
|
228
|
+
## [0.0.2] - 2015-06-03
|
229
|
+
### Fixed
|
230
|
+
- added binstubs
|
231
|
+
|
232
|
+
### Changed
|
233
|
+
- removed cruft from /lib
|
234
|
+
|
235
|
+
## 0.0.1 - 2015-04-30
|
236
|
+
### Added
|
237
|
+
- initial release
|
238
|
+
|
239
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.3.0...HEAD
|
240
|
+
[4.3.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.2.0...4.3.0
|
241
|
+
[4.2.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.1.0...4.2.0
|
242
|
+
[4.1.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.0.2...4.1.0
|
243
|
+
[4.0.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.0.1...4.0.2
|
244
|
+
[4.0.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/4.0.0...4.0.1
|
245
|
+
[4.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/3.0.0...4.0.0
|
246
|
+
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.4.0...3.0.0
|
247
|
+
[2.4.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.2...2.4.0
|
248
|
+
[2.3.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.1...2.3.2
|
249
|
+
[2.3.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.0...2.3.1
|
250
|
+
[2.3.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.2...2.3.0
|
251
|
+
[2.2.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.1...2.2.2
|
252
|
+
[2.2.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.0...2.2.1
|
253
|
+
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.1.0...2.2.0
|
254
|
+
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.0.0...2.1.0
|
255
|
+
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.6...2.0.0
|
256
|
+
[1.4.6]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.5...1.4.6
|
257
|
+
[1.4.5]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.4...1.4.5
|
258
|
+
[1.4.4]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.3...1.4.4
|
259
|
+
[1.4.3]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.2...1.4.3
|
260
|
+
[1.4.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.1...1.4.2
|
261
|
+
[1.4.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.4.0...1.4.1
|
262
|
+
[1.4.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.3.0...1.4.0
|
263
|
+
[1.3.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.2.0...1.3.0
|
264
|
+
[1.2.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.1.2...1.2.0
|
265
|
+
[1.1.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.1.1...1.1.2
|
266
|
+
[1.1.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.1.0...1.1.1
|
267
|
+
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.0.1...1.1.0
|
268
|
+
[1.0.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/1.0.0...1.0.1
|
269
|
+
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.1.1...1.0.0
|
270
|
+
[0.1.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.1.0...0.1.1
|
271
|
+
[0.1.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.7...0.1.0
|
272
|
+
[0.0.7]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.6...0.0.7
|
273
|
+
[0.0.6]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.5...0.0.6
|
274
|
+
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.4...0.0.5
|
275
|
+
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.3...0.0.4
|
276
|
+
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.2...0.0.3
|
277
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/0.0.1...0.0.2
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
## Sensu-Plugins-postgres
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-postgres.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-postgres)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-postgres.svg)](http://badge.fury.io/rb/sensu-plugins-postgres)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-postgres/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-postgres)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-postgres/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-postgres)
|
7
|
+
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-postgres.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-postgres)
|
8
|
+
|
9
|
+
## Functionality
|
10
|
+
|
11
|
+
## Files
|
12
|
+
* bin/check-postgres-alive.rb
|
13
|
+
* bin/check-postgres-connections.rb
|
14
|
+
* bin/metric-postgres-dbsize.rb
|
15
|
+
* bin/metric-postgres-statsbgwriter.rb
|
16
|
+
* bin/metric-postgres-statstable.rb
|
17
|
+
* bin/check-postgres-replication.rb
|
18
|
+
* bin/metric-postgres-graphite.rb
|
19
|
+
* bin/metric-postgres-statsdb.rb
|
20
|
+
* bin/metric-postgres-connections.rb
|
21
|
+
* bin/metric-postgres-locks.rb
|
22
|
+
* bin/metric-postgres-statsio.rb
|
23
|
+
* bin/check-postgres-query.rb
|
24
|
+
* bin/metrics-postgres-query.rb
|
25
|
+
* bin/metric-postgres-relation-size.rb
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Use `--help` to see command arguments.
|
30
|
+
|
31
|
+
### Sample usage
|
32
|
+
|
33
|
+
#### Check if PostgreSQL is alive
|
34
|
+
```
|
35
|
+
$ check-postgres-alive.rb -d template1 -f /var/lib/postgresql/.pgpass
|
36
|
+
CheckPostgres OK: Server version: {"version"=>"PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"}
|
37
|
+
```
|
38
|
+
|
39
|
+
### Check replication status
|
40
|
+
```
|
41
|
+
$ check-postgres-replication.rb -m psql1.local -s psql2.local -d template1 -w 5 -c 10
|
42
|
+
CheckPostgresReplicationStatus OK: replication delayed by 0.0MB :: master:B0/B4031000 slave:B0/B4031000 m_segbytes:16777216
|
43
|
+
```
|
44
|
+
|
45
|
+
### Check number of connections
|
46
|
+
```
|
47
|
+
$ export PGPASSWORD=this-is-secret-password
|
48
|
+
$ check-postgres-connections.rb -a -w 80 -c 90 -d template1 -u sensu
|
49
|
+
CheckPostgresConnections OK: PostgreSQL connections under threshold: 17%, 174 out of 997 connections
|
50
|
+
```
|
51
|
+
|
52
|
+
### Default values
|
53
|
+
|
54
|
+
| Argument | Env variable | Value |
|
55
|
+
|----------------|--------------|-----------|
|
56
|
+
| -f, --pgpass | PGPASSFILE | ~/.pgpass |
|
57
|
+
| -h, --hostname | PGHOST | localhost |
|
58
|
+
| -P, --port | PGPORT | 5432 |
|
59
|
+
| -d, --database | PGDATABASE | postgres |
|
60
|
+
| -u, --user | PGUSER | postgres |
|
61
|
+
| -p, --password | PGPASSWORD | |
|
62
|
+
|
63
|
+
Options precedence is following:
|
64
|
+
1. command line arguments
|
65
|
+
1. pgpass file
|
66
|
+
1. env variables
|
67
|
+
1. defaults
|
68
|
+
|
69
|
+
### Pgpass file
|
70
|
+
|
71
|
+
When file `~/.pgpass` is found it is used by default. You can also use `-f, --pgpass` command line argument or set `PGPASSFILE` env variable.
|
72
|
+
|
73
|
+
File format is:
|
74
|
+
|
75
|
+
```
|
76
|
+
hostname:port:database:username:password
|
77
|
+
```
|
78
|
+
|
79
|
+
Only first line is used. If database is set to `*` it is ommited.
|
80
|
+
|
81
|
+
You can ovveride `pgpass` values with command line arguments, e.g. `-h` for hostname.
|
82
|
+
|
83
|
+
|
84
|
+
## Installation
|
85
|
+
### Sensu Go Asset Installation
|
86
|
+
|
87
|
+
Assets are the best way to make use of this plugin in Sensu Go. If you're not using an asset, please consider doing so! If you're using sensuctl 5.13 or later, you can use the following command to add the asset:
|
88
|
+
|
89
|
+
sensuctl asset add sensu-plugins/sensu-plugins-postgresl
|
90
|
+
|
91
|
+
If you're using an earlier version of sensuctl, you can download the asset definition from this project's Bonsai Asset Index page.
|
92
|
+
|
93
|
+
Note: as of version 4.0.0 the plugin assets are built using the sensu-ruby26-runtime, and will also require that you have the sensu-ruby26-runtime asset and installed as part of the check configuration.
|
94
|
+
|
95
|
+
|
96
|
+
### Gem Installation
|
97
|
+
If you are unable to use the provided Sensu asset package, you can install this plugin via rubygems on a system that have ruby available.
|
98
|
+
|
99
|
+
```
|
100
|
+
gem install sensu-plugins-postgres
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
See [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html) for details.
|
105
|
+
|
106
|
+
### Known issues
|
107
|
+
|
108
|
+
When using Sensu with `EMBEDDED_RUBY=true` and installing Postgres checks with `/usr/bin/sensu-install -p sensu-plugins-postgres` you might get following error:
|
109
|
+
|
110
|
+
```
|
111
|
+
ERROR: Error installing sensu-plugins-postgres:
|
112
|
+
ERROR: Failed to build gem native extension.
|
113
|
+
[...]
|
114
|
+
checking for PQconnectdb() in -lpq... no
|
115
|
+
checking for PQconnectdb() in -llibpq... no
|
116
|
+
checking for PQconnectdb() in -lms/libpq... no
|
117
|
+
Can't find the PostgreSQL client library (libpq)
|
118
|
+
*** extconf.rb failed ***
|
119
|
+
```
|
120
|
+
|
121
|
+
The reason is that **libssl** library which comes with Sensu is incompatible with **libpq** library installed on your system. There is no easy way to fix it. You might want to install sensu-plugins-postgres globally with `gem install sensu-plugins-postgres`.
|
122
|
+
|
123
|
+
Checks are in `/usr/local/bin` directory.
|
124
|
+
|
125
|
+
## Notes
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# frozen_string_literal: false
|
3
|
+
|
4
|
+
#
|
5
|
+
# check-postgres-alive
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
#
|
9
|
+
# This plugin attempts to login to postgres with provided credentials.
|
10
|
+
#
|
11
|
+
# OUTPUT:
|
12
|
+
# plain text
|
13
|
+
#
|
14
|
+
# PLATFORMS:
|
15
|
+
# Linux
|
16
|
+
#
|
17
|
+
# DEPENDENCIES:
|
18
|
+
# gem: sensu-plugin
|
19
|
+
# gem: pg
|
20
|
+
#
|
21
|
+
# USAGE:
|
22
|
+
# ./check-postgres-alive.rb -u db_user -p db_pass -h db_host -d db
|
23
|
+
#
|
24
|
+
# NOTES:
|
25
|
+
#
|
26
|
+
# LICENSE:
|
27
|
+
# Copyright (c) 2012 Lewis Preson & Tom Bassindale
|
28
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
29
|
+
# for details.
|
30
|
+
#
|
31
|
+
|
32
|
+
require 'sensu-plugins-postgres/pgpass'
|
33
|
+
require 'sensu-plugin/check/cli'
|
34
|
+
require 'pg'
|
35
|
+
|
36
|
+
class CheckPostgres < Sensu::Plugin::Check::CLI
|
37
|
+
option :pgpass,
|
38
|
+
description: 'Pgpass file',
|
39
|
+
short: '-f FILE',
|
40
|
+
long: '--pgpass',
|
41
|
+
default: ENV['PGPASSFILE'] || "#{ENV['HOME']}/.pgpass"
|
42
|
+
|
43
|
+
option :user,
|
44
|
+
description: 'Postgres User',
|
45
|
+
short: '-u USER',
|
46
|
+
long: '--user USER'
|
47
|
+
|
48
|
+
option :password,
|
49
|
+
description: 'Postgres Password',
|
50
|
+
short: '-p PASS',
|
51
|
+
long: '--password PASS'
|
52
|
+
|
53
|
+
option :hostname,
|
54
|
+
description: 'Hostname to login to',
|
55
|
+
short: '-h HOST',
|
56
|
+
long: '--hostname HOST'
|
57
|
+
|
58
|
+
option :database,
|
59
|
+
description: 'Database schema to connect to',
|
60
|
+
short: '-d DATABASE',
|
61
|
+
long: '--database DATABASE'
|
62
|
+
|
63
|
+
option :port,
|
64
|
+
description: 'Database port',
|
65
|
+
short: '-P PORT',
|
66
|
+
long: '--port PORT'
|
67
|
+
|
68
|
+
option :timeout,
|
69
|
+
description: 'Connection timeout (seconds)',
|
70
|
+
short: '-T TIMEOUT',
|
71
|
+
long: '--timeout TIMEOUT',
|
72
|
+
default: 10,
|
73
|
+
proc: proc(&:to_i)
|
74
|
+
|
75
|
+
include Pgpass
|
76
|
+
|
77
|
+
def run
|
78
|
+
pgpass
|
79
|
+
con = PG.connect(host: config[:hostname],
|
80
|
+
dbname: config[:database],
|
81
|
+
user: config[:user],
|
82
|
+
password: config[:password],
|
83
|
+
port: config[:port],
|
84
|
+
connect_timeout: config[:timeout])
|
85
|
+
res = con.exec('select version();')
|
86
|
+
info = res.first
|
87
|
+
|
88
|
+
ok "Server version: #{info}"
|
89
|
+
rescue PG::Error => e
|
90
|
+
critical "Error message: #{e.error.split("\n").first}"
|
91
|
+
ensure
|
92
|
+
con&.close
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: false
|
3
|
+
|
4
|
+
#
|
5
|
+
# check-postgres-connections
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
# This plugin checks the number of connections to a postgresql database and
|
9
|
+
# alerts when the number or percent crosses a threshold. Defaults to checking
|
10
|
+
# number of connections unless the --percentage flag is used in which case the
|
11
|
+
# percentage of max connections is checked.
|
12
|
+
#
|
13
|
+
# OUTPUT:
|
14
|
+
# plain-text
|
15
|
+
#
|
16
|
+
# PLATFORMS:
|
17
|
+
# Linux
|
18
|
+
#
|
19
|
+
# DEPENDENCIES:
|
20
|
+
# gem: pg
|
21
|
+
# gem: sensu-plugin
|
22
|
+
#
|
23
|
+
# USAGE:
|
24
|
+
# # warn when connections hit 250, critical when 400
|
25
|
+
# check-postgres-connections.rb -u db_user -p db_pass -h db_host -d db -w 250 -c 400
|
26
|
+
# # warn when connections hit 80%, critical when 95%
|
27
|
+
# check-postgres-connections.rb -u db_user -p db_pass -h db_host -d db -w 80 -c 95 --percentage
|
28
|
+
#
|
29
|
+
# NOTES:
|
30
|
+
#
|
31
|
+
# LICENSE:
|
32
|
+
# Copyright 2016, Eric Heydrick <eheydrick@gmail.com>
|
33
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
34
|
+
# for details.
|
35
|
+
#
|
36
|
+
|
37
|
+
require 'sensu-plugins-postgres/pgpass'
|
38
|
+
require 'sensu-plugin/check/cli'
|
39
|
+
require 'pg'
|
40
|
+
|
41
|
+
class CheckPostgresConnections < Sensu::Plugin::Check::CLI
|
42
|
+
option :pgpass,
|
43
|
+
description: 'Pgpass file',
|
44
|
+
short: '-f FILE',
|
45
|
+
long: '--pgpass',
|
46
|
+
default: ENV['PGPASSFILE'] || "#{ENV['HOME']}/.pgpass"
|
47
|
+
|
48
|
+
option :user,
|
49
|
+
description: 'Postgres User',
|
50
|
+
short: '-u USER',
|
51
|
+
long: '--user USER'
|
52
|
+
|
53
|
+
option :password,
|
54
|
+
description: 'Postgres Password',
|
55
|
+
short: '-p PASS',
|
56
|
+
long: '--password PASS'
|
57
|
+
|
58
|
+
option :hostname,
|
59
|
+
description: 'Hostname to login to',
|
60
|
+
short: '-h HOST',
|
61
|
+
long: '--hostname HOST'
|
62
|
+
|
63
|
+
option :port,
|
64
|
+
description: 'Database port',
|
65
|
+
short: '-P PORT',
|
66
|
+
long: '--port PORT'
|
67
|
+
|
68
|
+
option :database,
|
69
|
+
description: 'Database name',
|
70
|
+
short: '-d DB',
|
71
|
+
long: '--db DB'
|
72
|
+
|
73
|
+
option :warning,
|
74
|
+
description: 'Warning threshold number or % of connections. (default: 200 connections)',
|
75
|
+
short: '-w WARNING',
|
76
|
+
long: '--warning WARNING',
|
77
|
+
default: 200,
|
78
|
+
proc: proc(&:to_i)
|
79
|
+
|
80
|
+
option :critical,
|
81
|
+
description: 'Critical threshold number or % of connections. (default: 250 connections)',
|
82
|
+
short: '-c CRITICAL',
|
83
|
+
long: '--critical CRITICAL',
|
84
|
+
default: 250,
|
85
|
+
proc: proc(&:to_i)
|
86
|
+
|
87
|
+
option :use_percentage,
|
88
|
+
description: 'Use percentage of max connections used instead of the absolute number of connections',
|
89
|
+
short: '-a',
|
90
|
+
long: '--percentage',
|
91
|
+
boolean: true,
|
92
|
+
default: false
|
93
|
+
|
94
|
+
option :timeout,
|
95
|
+
description: 'Connection timeout (seconds)',
|
96
|
+
short: '-T TIMEOUT',
|
97
|
+
long: '--timeout TIMEOUT',
|
98
|
+
default: 10,
|
99
|
+
proc: proc(&:to_i)
|
100
|
+
|
101
|
+
include Pgpass
|
102
|
+
|
103
|
+
def run
|
104
|
+
begin
|
105
|
+
pgpass
|
106
|
+
con = PG.connect(host: config[:hostname],
|
107
|
+
dbname: config[:database],
|
108
|
+
user: config[:user],
|
109
|
+
password: config[:password],
|
110
|
+
port: config[:port],
|
111
|
+
connect_timeout: config[:timeout])
|
112
|
+
max_conns = con.exec('SHOW max_connections').getvalue(0, 0).to_i
|
113
|
+
superuser_conns = con.exec('SHOW superuser_reserved_connections').getvalue(0, 0).to_i
|
114
|
+
available_conns = max_conns - superuser_conns
|
115
|
+
current_conns = con.exec('SELECT count(*) from pg_stat_activity').getvalue(0, 0).to_i
|
116
|
+
rescue PG::Error => e
|
117
|
+
unknown "Unable to query PostgreSQL: #{e.message}"
|
118
|
+
end
|
119
|
+
|
120
|
+
percent = (current_conns / max_conns.to_f * 100).to_i
|
121
|
+
|
122
|
+
if config[:use_percentage]
|
123
|
+
message = "PostgreSQL connections at #{percent}%, #{current_conns} out of #{available_conns} connections"
|
124
|
+
if percent >= config[:critical]
|
125
|
+
critical message
|
126
|
+
elsif percent >= config[:warning]
|
127
|
+
warning message
|
128
|
+
else
|
129
|
+
ok "PostgreSQL connections under threshold: #{percent}%, #{current_conns} out of #{available_conns} connections"
|
130
|
+
end
|
131
|
+
else
|
132
|
+
message = "PostgreSQL connections at #{current_conns} out of #{available_conns} connections"
|
133
|
+
if current_conns >= config[:critical]
|
134
|
+
critical message
|
135
|
+
elsif current_conns >= config[:warning]
|
136
|
+
warning message
|
137
|
+
else
|
138
|
+
ok "PostgreSQL connections under threshold: #{current_conns} out of #{available_conns} connections"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|