sensu-plugins-mongodb 1.2.2 → 1.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 +8 -1
- data/lib/sensu-plugins-mongodb/metics.rb +59 -26
- data/lib/sensu-plugins-mongodb/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b2d5a053085a584cd966e891d11bbff8500999
|
4
|
+
data.tar.gz: 19ae5997b3440b58fe9b60f96b31faa50e9ba503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e01de3b9d4aa25022540fa4f6774d9e5a1a442323a7247f3c65de126512193210ed144268cf0c6d9c865ec1cd5e3a8176e9c2ae4f5c556120c61441489ee38
|
7
|
+
data.tar.gz: 945d1d2cfe04f5f842b1109560a28af11ef0411fbadde16d8aa67833f2cfac242d97a19414c14b83af1c4aaff19cf889cd9468ed1fce27f715cdda4b1c3270cd
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
|
+
|
8
|
+
## [1.3.0]
|
9
|
+
### Added
|
10
|
+
- Support for database size metrics (@naemono)
|
11
|
+
- Tests covering returning database size metrics (@naemono)
|
12
|
+
|
7
13
|
## [1.2.2]
|
8
14
|
### Fixed
|
9
15
|
- `check-mongodb.py`: will now correctly crit on connection issues (@majormoses)
|
@@ -95,7 +101,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
95
101
|
### Added
|
96
102
|
- initial release
|
97
103
|
|
98
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mongodb/compare/1.
|
104
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mongodb/compare/1.3.0...HEAD
|
105
|
+
[1.3.0]: https://github.com/sensu-plugins/sensu-plugins-mongodb/compare/1.2.1...1.3.0
|
99
106
|
[1.2.1]: https://github.com/sensu-plugins/sensu-plugins-mongodb/compare/1.2.0...1.2.1
|
100
107
|
[1.2.0]: https://github.com/sensu-plugins/sensu-plugins-mongodb/compare/1.1.0...1.2.0
|
101
108
|
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-mongodb/compare/1.0.0...1.1.0
|
@@ -12,6 +12,7 @@ module SensuPluginsMongoDB
|
|
12
12
|
@config = config
|
13
13
|
@connected = false
|
14
14
|
@db = nil
|
15
|
+
@mongo_client = nil
|
15
16
|
end
|
16
17
|
|
17
18
|
# Connects to a mongo database.
|
@@ -22,38 +23,16 @@ module SensuPluginsMongoDB
|
|
22
23
|
raise 'Already connected to a database'
|
23
24
|
end
|
24
25
|
|
25
|
-
@connected = true
|
26
|
-
host = @config[:host]
|
27
|
-
port = @config[:port]
|
28
26
|
db_user = @config[:user]
|
29
27
|
db_password = @config[:password]
|
30
|
-
ssl = @config[:ssl]
|
31
|
-
ssl_cert = @config[:ssl_cert]
|
32
|
-
ssl_key = @config[:ssl_key]
|
33
|
-
ssl_ca_cert = @config[:ssl_ca_cert]
|
34
|
-
ssl_verify = @config[:ssl_verify]
|
35
28
|
|
36
29
|
if Gem.loaded_specs['mongo'].version < Gem::Version.new('2.0.0')
|
37
|
-
mongo_client =
|
38
|
-
@db = mongo_client.db(db_name)
|
30
|
+
@mongo_client = get_mongo_client(db_name)
|
31
|
+
@db = @mongo_client.db(db_name)
|
39
32
|
@db.authenticate(db_user, db_password) unless db_user.nil?
|
40
33
|
else
|
41
|
-
|
42
|
-
|
43
|
-
client_opts[:database] = db_name
|
44
|
-
unless db_user.nil?
|
45
|
-
client_opts[:user] = db_user
|
46
|
-
client_opts[:password] = db_password
|
47
|
-
end
|
48
|
-
if ssl
|
49
|
-
client_opts[:ssl] = true
|
50
|
-
client_opts[:ssl_cert] = ssl_cert
|
51
|
-
client_opts[:ssl_key] = ssl_key
|
52
|
-
client_opts[:ssl_ca_cert] = ssl_ca_cert
|
53
|
-
client_opts[:ssl_verify] = ssl_verify
|
54
|
-
end
|
55
|
-
mongo_client = Mongo::Client.new([address_str], client_opts)
|
56
|
-
@db = mongo_client.database
|
34
|
+
@mongo_client = get_mongo_client(db_name)
|
35
|
+
@db = @mongo_client.database
|
57
36
|
end
|
58
37
|
end
|
59
38
|
|
@@ -170,6 +149,25 @@ module SensuPluginsMongoDB
|
|
170
149
|
end
|
171
150
|
end
|
172
151
|
|
152
|
+
# Database Sizes
|
153
|
+
@mongo_client.database_names.each do |name|
|
154
|
+
@mongo_client.use(name)
|
155
|
+
db = @mongo_client.database
|
156
|
+
result = db.command(dbstats: 1).documents.first
|
157
|
+
server_metrics["databaseSizes.#{name}.collections"] = result['collections']
|
158
|
+
server_metrics["databaseSizes.#{name}.objects"] = result['objects']
|
159
|
+
server_metrics["databaseSizes.#{name}.avgObjSize"] = result['avgObjSize']
|
160
|
+
server_metrics["databaseSizes.#{name}.dataSize"] = result['dataSize']
|
161
|
+
server_metrics["databaseSizes.#{name}.storageSize"] = result['storageSize']
|
162
|
+
server_metrics["databaseSizes.#{name}.numExtents"] = result['numExtents']
|
163
|
+
server_metrics["databaseSizes.#{name}.indexes"] = result['indexes']
|
164
|
+
server_metrics["databaseSizes.#{name}.indexSize"] = result['indexSize']
|
165
|
+
server_metrics["databaseSizes.#{name}.fileSize"] = result['fileSize']
|
166
|
+
server_metrics["databaseSizes.#{name}.nsSizeMB"] = result['nsSizeMB']
|
167
|
+
end
|
168
|
+
# Reset back to previous database
|
169
|
+
@mongo_client.use(@db.name)
|
170
|
+
|
173
171
|
# Journaling (durability)
|
174
172
|
if server_status.key?('dur')
|
175
173
|
dur = server_status['dur']
|
@@ -336,5 +334,40 @@ module SensuPluginsMongoDB
|
|
336
334
|
end
|
337
335
|
clean_metrics
|
338
336
|
end
|
337
|
+
|
338
|
+
private
|
339
|
+
|
340
|
+
def get_mongo_client(db_name)
|
341
|
+
@connected = true
|
342
|
+
host = @config[:host]
|
343
|
+
port = @config[:port]
|
344
|
+
db_user = @config[:user]
|
345
|
+
db_password = @config[:password]
|
346
|
+
ssl = @config[:ssl]
|
347
|
+
ssl_cert = @config[:ssl_cert]
|
348
|
+
ssl_key = @config[:ssl_key]
|
349
|
+
ssl_ca_cert = @config[:ssl_ca_cert]
|
350
|
+
ssl_verify = @config[:ssl_verify]
|
351
|
+
|
352
|
+
if Gem.loaded_specs['mongo'].version < Gem::Version.new('2.0.0')
|
353
|
+
MongoClient.new(host, port)
|
354
|
+
else
|
355
|
+
address_str = "#{host}:#{port}"
|
356
|
+
client_opts = {}
|
357
|
+
client_opts[:database] = db_name
|
358
|
+
unless db_user.nil?
|
359
|
+
client_opts[:user] = db_user
|
360
|
+
client_opts[:password] = db_password
|
361
|
+
end
|
362
|
+
if ssl
|
363
|
+
client_opts[:ssl] = true
|
364
|
+
client_opts[:ssl_cert] = ssl_cert
|
365
|
+
client_opts[:ssl_key] = ssl_key
|
366
|
+
client_opts[:ssl_ca_cert] = ssl_ca_cert
|
367
|
+
client_opts[:ssl_verify] = ssl_verify
|
368
|
+
end
|
369
|
+
Mongo::Client.new([address_str], client_opts)
|
370
|
+
end
|
371
|
+
end
|
339
372
|
end
|
340
373
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-mongodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.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: 2017-05-
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bson
|