sensu-plugins-postgres 2.2.2 → 2.3.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 +4 -4
- data/CHANGELOG.md +6 -1
- data/bin/metric-postgres-statsdb.rb +30 -15
- data/lib/sensu-plugins-postgres/version.rb +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 763790612d89bde8df6bed957f51c4b62fed9b0275efbb1d8021ede5a2302bc0
|
|
4
|
+
data.tar.gz: 7a7201d9f5574cc4dd304226f2484810a2c1024b709f8de310c8417b7d22b6fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9573ff56ddf073e4418ad0f2a5a0ab3ebdcb974d08b62d5163b3b32729fc8bf965911ee80cbbade49b9bb5e4c847d4d00dd680b84a9c844a13c152248cc85c17
|
|
7
|
+
data.tar.gz: 0440dd6a2b23946fbabc6c9014e678b730b992790eda9b4e26ca5290d169ab0bc674f5777b8f391663c79f43ace60b4990a94c69291fe540e2d4091c3c2a76e1
|
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.0] - 2018-12-08
|
|
9
|
+
### Added
|
|
10
|
+
- metric-postgres-statsdb.rb: Add --all-databases option. (@cyrilgdn)
|
|
11
|
+
|
|
8
12
|
## [2.2.2] - 2018-10-27
|
|
9
13
|
### Fixed
|
|
10
14
|
- Remove unexplicit dependency on ActiveSupport (@multani)
|
|
@@ -166,7 +170,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
|
166
170
|
### Added
|
|
167
171
|
- initial release
|
|
168
172
|
|
|
169
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.
|
|
173
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.3.0...HEAD
|
|
174
|
+
[2.3.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.2...2.3.0
|
|
170
175
|
[2.2.2]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.1...2.2.2
|
|
171
176
|
[2.2.1]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.2.0...2.2.1
|
|
172
177
|
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-postgres/compare/2.1.0...2.2.0
|
|
@@ -62,9 +62,17 @@ class PostgresStatsDBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
62
62
|
long: '--port PORT'
|
|
63
63
|
|
|
64
64
|
option :database,
|
|
65
|
-
description: 'Database
|
|
65
|
+
description: 'Database to connect on',
|
|
66
66
|
short: '-d DB',
|
|
67
|
-
long: '--db DB'
|
|
67
|
+
long: '--db DB',
|
|
68
|
+
default: 'postgres'
|
|
69
|
+
|
|
70
|
+
option :all_databases,
|
|
71
|
+
description: 'Get stats for all available databases',
|
|
72
|
+
short: '-a',
|
|
73
|
+
long: '--all-databases',
|
|
74
|
+
boolean: true,
|
|
75
|
+
default: false
|
|
68
76
|
|
|
69
77
|
option :scheme,
|
|
70
78
|
description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
|
|
@@ -82,21 +90,28 @@ class PostgresStatsDBMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
82
90
|
def run
|
|
83
91
|
timestamp = Time.now.to_i
|
|
84
92
|
pgpass
|
|
85
|
-
con
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
]
|
|
95
|
-
|
|
93
|
+
con = PG.connect(host: config[:hostname],
|
|
94
|
+
dbname: config[:database],
|
|
95
|
+
user: config[:user],
|
|
96
|
+
password: config[:password],
|
|
97
|
+
port: config[:port],
|
|
98
|
+
connect_timeout: config[:timeout])
|
|
99
|
+
|
|
100
|
+
query = 'SELECT * FROM pg_stat_database'
|
|
101
|
+
params = []
|
|
102
|
+
unless config[:all_databases]
|
|
103
|
+
query += ' WHERE datname = $1'
|
|
104
|
+
params.append config[:database]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
con.exec_params(query, params) do |result|
|
|
96
108
|
result.each do |row|
|
|
109
|
+
database = row['datname']
|
|
110
|
+
|
|
97
111
|
row.each do |key, value|
|
|
98
|
-
next if %w[datid stats_reset].include?(key)
|
|
99
|
-
|
|
112
|
+
next if %w[datid datname stats_reset].include?(key)
|
|
113
|
+
|
|
114
|
+
output "#{config[:scheme]}.statsdb.#{database}.#{key}", value.to_s, timestamp
|
|
100
115
|
end
|
|
101
116
|
end
|
|
102
117
|
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.
|
|
4
|
+
version: 2.3.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-
|
|
11
|
+
date: 2018-12-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sensu-plugin
|
|
@@ -126,22 +126,22 @@ dependencies:
|
|
|
126
126
|
name: mixlib-shellout
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
|
-
- - "<"
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: 2.3.0
|
|
132
129
|
- - "~>"
|
|
133
130
|
- !ruby/object:Gem::Version
|
|
134
131
|
version: '2.2'
|
|
132
|
+
- - "<"
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: 2.3.0
|
|
135
135
|
type: :development
|
|
136
136
|
prerelease: false
|
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
|
138
138
|
requirements:
|
|
139
|
-
- - "<"
|
|
140
|
-
- !ruby/object:Gem::Version
|
|
141
|
-
version: 2.3.0
|
|
142
139
|
- - "~>"
|
|
143
140
|
- !ruby/object:Gem::Version
|
|
144
141
|
version: '2.2'
|
|
142
|
+
- - "<"
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: 2.3.0
|
|
145
145
|
- !ruby/object:Gem::Dependency
|
|
146
146
|
name: pry
|
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -325,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
325
325
|
version: '0'
|
|
326
326
|
requirements: []
|
|
327
327
|
rubyforge_project:
|
|
328
|
-
rubygems_version: 2.7.
|
|
328
|
+
rubygems_version: 2.7.8
|
|
329
329
|
signing_key:
|
|
330
330
|
specification_version: 4
|
|
331
331
|
summary: Sensu plugins for postgres
|